1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

Build our Settings after our QApplication, fixes crash on startup

Thanks to @stqism for reporting the crash

This is why global static variables are evil
This commit is contained in:
Tux3 / Mlkj / !Lev.uXFMLA 2014-11-11 23:21:16 +01:00
parent 57bcda7cd9
commit 7bca831066
No known key found for this signature in database
GPG Key ID: 7E086DD661263264
3 changed files with 6 additions and 3 deletions

View File

@ -58,6 +58,8 @@ int main(int argc, char *argv[])
a.setApplicationName("qTox"); a.setApplicationName("qTox");
a.setOrganizationName("Tox"); a.setOrganizationName("Tox");
Settings::getInstance(); // Build our Settings singleton as soon as QApplication is ready, not before
sodium_init(); // For the auto-updater sodium_init(); // For the auto-updater
#ifdef LOG_TO_FILE #ifdef LOG_TO_FILE

View File

@ -39,8 +39,10 @@ Settings::Settings() :
Settings& Settings::getInstance() Settings& Settings::getInstance()
{ {
static Settings settings; static Settings* settings{nullptr};
return settings; if (!settings)
settings = new Settings();
return *settings;
} }
void Settings::load() void Settings::load()

View File

@ -296,7 +296,6 @@ Widget::~Widget()
Widget* Widget::getInstance() Widget* Widget::getInstance()
{ {
if (!instance) if (!instance)
{ {
instance = new Widget(); instance = new Widget();