mirror of
https://github.com/overte-org/overte.git
synced 2025-07-23 07:23:51 +02:00
Don't run settings preroutine when not initialized
This commit is contained in:
parent
c2b1c4250c
commit
061f9ea359
2 changed files with 25 additions and 21 deletions
|
@ -33,7 +33,6 @@ namespace Setting {
|
||||||
// tell the private instance to clean itself up on its thread
|
// tell the private instance to clean itself up on its thread
|
||||||
DependencyManager::destroy<Manager>();
|
DependencyManager::destroy<Manager>();
|
||||||
|
|
||||||
//
|
|
||||||
globalManager.reset();
|
globalManager.reset();
|
||||||
|
|
||||||
// quit the settings manager thread and wait on it to make sure it's gone
|
// quit the settings manager thread and wait on it to make sure it's gone
|
||||||
|
@ -42,20 +41,23 @@ namespace Setting {
|
||||||
}
|
}
|
||||||
|
|
||||||
void setupPrivateInstance() {
|
void setupPrivateInstance() {
|
||||||
// Let's set up the settings Private instance on its own thread
|
// Ensure Setting::init has already ran and qApp exists
|
||||||
QThread* thread = new QThread();
|
if (qApp && globalManager) {
|
||||||
Q_CHECK_PTR(thread);
|
// Let's set up the settings Private instance on its own thread
|
||||||
thread->setObjectName("Settings Thread");
|
QThread* thread = new QThread();
|
||||||
|
Q_CHECK_PTR(thread);
|
||||||
|
thread->setObjectName("Settings Thread");
|
||||||
|
|
||||||
QObject::connect(thread, SIGNAL(started()), globalManager.data(), SLOT(startTimer()));
|
QObject::connect(thread, SIGNAL(started()), globalManager.data(), SLOT(startTimer()));
|
||||||
QObject::connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater()));
|
QObject::connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater()));
|
||||||
QObject::connect(thread, SIGNAL(finished()), globalManager.data(), SLOT(deleteLater()));
|
QObject::connect(thread, SIGNAL(finished()), globalManager.data(), SLOT(deleteLater()));
|
||||||
globalManager->moveToThread(thread);
|
globalManager->moveToThread(thread);
|
||||||
thread->start();
|
thread->start();
|
||||||
qCDebug(shared) << "Settings thread started.";
|
qCDebug(shared) << "Settings thread started.";
|
||||||
|
|
||||||
// Register cleanupPrivateInstance to run inside QCoreApplication's destructor.
|
// Register cleanupPrivateInstance to run inside QCoreApplication's destructor.
|
||||||
qAddPostRoutine(cleanupPrivateInstance);
|
qAddPostRoutine(cleanupPrivateInstance);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
FIXED_Q_COREAPP_STARTUP_FUNCTION(setupPrivateInstance)
|
FIXED_Q_COREAPP_STARTUP_FUNCTION(setupPrivateInstance)
|
||||||
|
|
||||||
|
@ -79,6 +81,8 @@ namespace Setting {
|
||||||
}
|
}
|
||||||
|
|
||||||
globalManager = DependencyManager::set<Manager>();
|
globalManager = DependencyManager::set<Manager>();
|
||||||
|
|
||||||
|
setupPrivateInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Interface::init() {
|
void Interface::init() {
|
||||||
|
|
|
@ -32,14 +32,14 @@
|
||||||
// We cannot used std::call_once with a static once_flag because
|
// We cannot used std::call_once with a static once_flag because
|
||||||
// this is used in shared libraries that are linked by several DLLs
|
// this is used in shared libraries that are linked by several DLLs
|
||||||
// (ie. plugins), meaning the static will be useless in that case
|
// (ie. plugins), meaning the static will be useless in that case
|
||||||
#define FIXED_Q_COREAPP_STARTUP_FUNCTION(AFUNC) \
|
#define FIXED_Q_COREAPP_STARTUP_FUNCTION(AFUNC) \
|
||||||
static void AFUNC ## _fixed() { \
|
static void AFUNC ## _fixed() { \
|
||||||
const auto propertyName = std::string(Q_FUNC_INFO) + __FILE__; \
|
const auto propertyName = std::string(Q_FUNC_INFO) + __FILE__; \
|
||||||
if (!qApp->property(propertyName.c_str()).toBool()) { \
|
if (!qApp->property(propertyName.c_str()).toBool()) { \
|
||||||
AFUNC(); \
|
AFUNC(); \
|
||||||
qApp->setProperty(propertyName.c_str(), QVariant(true)); \
|
qApp->setProperty(propertyName.c_str(), QVariant(true)); \
|
||||||
} \
|
} \
|
||||||
} \
|
} \
|
||||||
Q_COREAPP_STARTUP_FUNCTION(AFUNC ## _fixed)
|
Q_COREAPP_STARTUP_FUNCTION(AFUNC ## _fixed)
|
||||||
|
|
||||||
// When writing out avatarEntities to a QByteArray, if the parentID is the ID of MyAvatar, use this ID instead. This allows
|
// When writing out avatarEntities to a QByteArray, if the parentID is the ID of MyAvatar, use this ID instead. This allows
|
||||||
|
|
Loading…
Reference in a new issue