Create std::wstrings out of const wchar_t* so a copy is created every time.

Signed-off-by: allexzander <blackslayer4@gmail.com>
This commit is contained in:
allexzander 2021-04-02 11:51:09 +03:00
parent 454226b3ea
commit 0a33e99053
2 changed files with 9 additions and 7 deletions

View file

@ -450,7 +450,7 @@ bool deleteSyncRootRegistryKey(const QString &syncRootPath, const QString &provi
return true;
}
OCC::Result<void, QString> OCC::CfApiWrapper::registerSyncRoot(const QString path, const QString providerName, const QString providerVersion, const QString folderAlias, const QString displayName, const QString accountDisplayName)
OCC::Result<void, QString> OCC::CfApiWrapper::registerSyncRoot(const QString &path, const QString &providerName, const QString &providerVersion, const QString &folderAlias, const QString &displayName, const QString &accountDisplayName)
{
// even if we fail to register our sync root with shell, we can still proceed with using the VFS
const auto createRegistryKeyResult = createSyncRootRegistryKeys(providerName, folderAlias, displayName, accountDisplayName, path);
@ -460,9 +460,11 @@ OCC::Result<void, QString> OCC::CfApiWrapper::registerSyncRoot(const QString pat
qCWarning(lcCfApiWrapper) << "Failed to create the registry key for path:" << path;
}
const auto p = path.toStdWString();
const auto name = providerName.toStdWString();
const auto version = providerVersion.toStdWString();
// API is somehow keeping the pointers for longer than one would expect or freeing them itself
// the internal format of QString is likely the right one for wstring on Windows so there's in fact not necessarily a need to copy
const auto p = std::wstring(path.toStdWString().data());
const auto name = std::wstring(providerName.toStdWString().data());
const auto version = std::wstring(providerVersion.toStdWString().data());
CF_SYNC_REGISTRATION info;
info.ProviderName = name.data();
@ -489,7 +491,7 @@ OCC::Result<void, QString> OCC::CfApiWrapper::registerSyncRoot(const QString pat
}
}
OCC::Result<void, QString> OCC::CfApiWrapper::unregisterSyncRoot(const QString path, const QString providerName, const QString accountDisplayName)
OCC::Result<void, QString> OCC::CfApiWrapper::unregisterSyncRoot(const QString &path, const QString &providerName, const QString &accountDisplayName)
{
const auto deleteRegistryKeyResult = deleteSyncRootRegistryKey(path, providerName, accountDisplayName);
Q_ASSERT(deleteRegistryKeyResult);

View file

@ -71,8 +71,8 @@ private:
std::unique_ptr<CF_PLACEHOLDER_BASIC_INFO, Deleter> _data;
};
OWNCLOUDSYNC_EXPORT Result<void, QString> registerSyncRoot(const QString path, const QString providerName, const QString providerVersion, const QString folderAlias, const QString displayName, const QString accountDisplayName);
OWNCLOUDSYNC_EXPORT Result<void, QString> unregisterSyncRoot(const QString path, const QString providerName, const QString accountDisplayName);
OWNCLOUDSYNC_EXPORT Result<void, QString> registerSyncRoot(const QString &path, const QString &providerName, const QString &providerVersion, const QString &folderAlias, const QString &displayName, const QString &accountDisplayName);
OWNCLOUDSYNC_EXPORT Result<void, QString> unregisterSyncRoot(const QString &path, const QString &providerName, const QString &accountDisplayName);
OWNCLOUDSYNC_EXPORT Result<ConnectionKey, QString> connectSyncRoot(const QString &path, VfsCfApi *context);
OWNCLOUDSYNC_EXPORT Result<void, QString> disconnectSyncRoot(ConnectionKey &&key);