Don't run settings preroutine when not initialized

This commit is contained in:
Atlante45 2018-01-29 11:52:43 -08:00
parent c2b1c4250c
commit 061f9ea359
2 changed files with 25 additions and 21 deletions

View file

@ -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,6 +41,8 @@ namespace Setting {
} }
void setupPrivateInstance() { void setupPrivateInstance() {
// Ensure Setting::init has already ran and qApp exists
if (qApp && globalManager) {
// Let's set up the settings Private instance on its own thread // Let's set up the settings Private instance on its own thread
QThread* thread = new QThread(); QThread* thread = new QThread();
Q_CHECK_PTR(thread); Q_CHECK_PTR(thread);
@ -57,6 +58,7 @@ namespace Setting {
// 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)
// Sets up the settings private instance. Should only be run once at startup. preInit() must be run beforehand, // Sets up the settings private instance. Should only be run once at startup. preInit() must be run beforehand,
@ -79,6 +81,8 @@ namespace Setting {
} }
globalManager = DependencyManager::set<Manager>(); globalManager = DependencyManager::set<Manager>();
setupPrivateInstance();
} }
void Interface::init() { void Interface::init() {