mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
perf(Settings): Make personal settings saving consistently async
The function is documented as async, but is only async when called from a different thread. Save is called from within Settings, it looks like only from public functions that would be called on other threads, but make it async regardless of calling thread for consistency. There is already a sync function that is used, so safety is not lost.
This commit is contained in:
parent
4f45f30ef9
commit
a1f7c71feb
|
@ -75,6 +75,7 @@ Settings::Settings(IMessageBoxManager& messageBoxManager_)
|
|||
settingsThread = new QThread();
|
||||
settingsThread->setObjectName("qTox Settings");
|
||||
settingsThread->start(QThread::LowPriority);
|
||||
qRegisterMetaType<const ToxEncrypt*>("const ToxEncrypt*");
|
||||
moveToThread(settingsThread);
|
||||
loadGlobal();
|
||||
}
|
||||
|
@ -762,10 +763,9 @@ void Settings::savePersonal(Profile* profile)
|
|||
qDebug() << "Could not save personal settings because there is no active profile";
|
||||
return;
|
||||
}
|
||||
if (QThread::currentThread() != settingsThread)
|
||||
return (void)QMetaObject::invokeMethod(this, "savePersonal",
|
||||
Q_ARG(Profile*, profile));
|
||||
savePersonal(profile->getName(), profile->getPasskey());
|
||||
QMetaObject::invokeMethod(this, "savePersonal",
|
||||
Q_ARG(QString, profile->getName()),
|
||||
Q_ARG(const ToxEncrypt*, profile->getPasskey()));
|
||||
}
|
||||
|
||||
void Settings::savePersonal(QString profileName, const ToxEncrypt* passkey)
|
||||
|
|
|
@ -158,6 +158,7 @@ public:
|
|||
void createPersonal(const QString& basename) const;
|
||||
|
||||
void savePersonal();
|
||||
void savePersonal(Profile* profile);
|
||||
|
||||
void loadGlobal();
|
||||
void loadPersonal(QString profileName, const ToxEncrypt* passKey, bool newProfile);
|
||||
|
@ -573,15 +574,14 @@ public:
|
|||
|
||||
private:
|
||||
struct friendProp;
|
||||
void savePersonal(QString profileName, const ToxEncrypt* passkey);
|
||||
friendProp& getOrInsertFriendPropRef(const ToxPk& id);
|
||||
static ICoreSettings::ProxyType fixInvalidProxyType(ICoreSettings::ProxyType proxyType);
|
||||
|
||||
template <typename T>
|
||||
bool setVal(T& savedVal, T newVal);
|
||||
|
||||
public slots:
|
||||
void savePersonal(Profile* profile);
|
||||
private slots:
|
||||
void savePersonal(QString profileName, const ToxEncrypt* passkey);
|
||||
|
||||
private:
|
||||
bool loaded;
|
||||
|
|
Loading…
Reference in New Issue
Block a user