From 07c9a0e2bb303f1ffafdd9415b0fd36b687de6e3 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Mon, 24 Aug 2015 10:48:58 -0700 Subject: [PATCH 1/9] Add Developer > Crash Interface menu item --- interface/src/Application.cpp | 6 ++++++ interface/src/Application.h | 2 ++ interface/src/Menu.cpp | 2 ++ interface/src/Menu.h | 1 + 4 files changed, 11 insertions(+) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 0f3282582f..6bb12d4d06 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -5137,3 +5137,9 @@ void Application::emulateMouse(Hand* hand, float click, float shift, int index) _oldHandLeftClick[index] = false; } } + +void Application::crashApplication() { + QObject* object = nullptr; + bool value = object->isWindowType(); + qCDebug(interfaceapp) << "Intentionally crashed Interface"; +} diff --git a/interface/src/Application.h b/interface/src/Application.h index 6394aa12d0..2297ff157e 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -438,6 +438,8 @@ public slots: void reloadResourceCaches(); + void crashApplication(); + private slots: void clearDomainOctreeDetails(); void checkFPS(); diff --git a/interface/src/Menu.cpp b/interface/src/Menu.cpp index f99b3ba579..d08970a693 100644 --- a/interface/src/Menu.cpp +++ b/interface/src/Menu.cpp @@ -575,6 +575,8 @@ Menu::Menu() { addCheckableActionToQMenuAndActionHash(physicsOptionsMenu, MenuOption::PhysicsShowOwned); addCheckableActionToQMenuAndActionHash(physicsOptionsMenu, MenuOption::PhysicsShowHulls); + addActionToQMenuAndActionHash(developerMenu, MenuOption::CrashInterface, 0, qApp, SLOT(crashApplication())); + MenuWrapper* helpMenu = addMenu("Help"); addActionToQMenuAndActionHash(helpMenu, MenuOption::EditEntitiesHelp, 0, qApp, SLOT(showEditEntitiesHelp())); diff --git a/interface/src/Menu.h b/interface/src/Menu.h index 278da363d1..e9ce8bcaba 100644 --- a/interface/src/Menu.h +++ b/interface/src/Menu.h @@ -164,6 +164,7 @@ namespace MenuOption { const QString CopyAddress = "Copy Address to Clipboard"; const QString CopyPath = "Copy Path to Clipboard"; const QString CoupleEyelids = "Couple Eyelids"; + const QString CrashInterface = "Crash Interface"; const QString DebugAmbientOcclusion = "Debug Ambient Occlusion"; const QString DecreaseAvatarSize = "Decrease Avatar Size"; const QString DeleteBookmark = "Delete Bookmark..."; From 63ad972576d4dbf4569cb20d2f6f7d86ad4c2b78 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Mon, 24 Aug 2015 11:09:41 -0700 Subject: [PATCH 2/9] Write and delete "application is running" marker file --- interface/src/Application.cpp | 4 ++++ interface/src/CrashHandler.cpp | 42 ++++++++++++++++++++++++++++++++++ interface/src/CrashHandler.h | 27 ++++++++++++++++++++++ 3 files changed, 73 insertions(+) create mode 100644 interface/src/CrashHandler.cpp create mode 100644 interface/src/CrashHandler.h diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 6bb12d4d06..8b59fd16d4 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -104,6 +104,7 @@ #include #include "AudioClient.h" +#include "CrashHandler.h" #include "DiscoverabilityManager.h" #include "GLCanvas.h" #include "LODManager.h" @@ -256,6 +257,9 @@ bool setupEssentials(int& argc, char** argv) { // Set build version QCoreApplication::setApplicationVersion(BUILD_VERSION); + CrashHandler::writeRunningMarkerFiler(); + qAddPostRoutine(CrashHandler::deleteRunningMarkerFile); + DependencyManager::registerInheritance(); DependencyManager::registerInheritance(); DependencyManager::registerInheritance(); diff --git a/interface/src/CrashHandler.cpp b/interface/src/CrashHandler.cpp new file mode 100644 index 0000000000..c95e513898 --- /dev/null +++ b/interface/src/CrashHandler.cpp @@ -0,0 +1,42 @@ +// +// CrashHandler.cpp +// interface/src +// +// Created by David Rowe on 24 Aug 2015. +// Copyright 2015 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +#include "CrashHandler.h" + +#include +#include +#include +#include +#include + +static const QString RUNNING_MARKER_FILENAME = "Interface.running"; + +void CrashHandler::writeRunningMarkerFiler() { + QFile runningMarkerFile(runningMarkerFilePath()); + if (!runningMarkerFile.exists()) { + runningMarkerFile.open(QIODevice::WriteOnly); + runningMarkerFile.close(); + } +} +void CrashHandler::deleteRunningMarkerFile() { + QFile runningMarkerFile(runningMarkerFilePath()); + if (runningMarkerFile.exists()) { + runningMarkerFile.remove(); + } +} + +const QString CrashHandler::runningMarkerFilePath() { + QSettings::setDefaultFormat(QSettings::IniFormat); + QSettings applicationInfo(PathUtils::resourcesPath() + "info/ApplicationInfo.ini", QSettings::IniFormat); + applicationInfo.beginGroup("INFO"); + QCoreApplication::setOrganizationName(applicationInfo.value("organizationName").toString()); + return QStandardPaths::writableLocation(QStandardPaths::DataLocation) + "/" + RUNNING_MARKER_FILENAME; +} diff --git a/interface/src/CrashHandler.h b/interface/src/CrashHandler.h new file mode 100644 index 0000000000..d354c49d07 --- /dev/null +++ b/interface/src/CrashHandler.h @@ -0,0 +1,27 @@ +// +// CrashHandler.h +// interface/src +// +// Created by David Rowe on 24 Aug 2015. +// Copyright 2015 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +#ifndef hifi_CrashHandler_h +#define hifi_CrashHandler_h + +#include + +class CrashHandler { + +public: + static void writeRunningMarkerFiler(); + static void deleteRunningMarkerFile(); + +private: + static const QString runningMarkerFilePath(); +}; + +#endif // hifi_CrashHandler_h From 9c782f6a6d59f6c3ed1f2207daa7283de68cc967 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Mon, 24 Aug 2015 12:45:35 -0700 Subject: [PATCH 3/9] Display dialog of crash handling options at startup if Interface crashed Default option and Esc continue without taking any action. --- interface/src/Application.cpp | 1 + interface/src/CrashHandler.cpp | 59 ++++++++++++++++++++++++++++++++++ interface/src/CrashHandler.h | 11 +++++++ 3 files changed, 71 insertions(+) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 8b59fd16d4..ca09960abd 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -257,6 +257,7 @@ bool setupEssentials(int& argc, char** argv) { // Set build version QCoreApplication::setApplicationVersion(BUILD_VERSION); + CrashHandler::checkForAndHandleCrash(); CrashHandler::writeRunningMarkerFiler(); qAddPostRoutine(CrashHandler::deleteRunningMarkerFile); diff --git a/interface/src/CrashHandler.cpp b/interface/src/CrashHandler.cpp index c95e513898..b58e739176 100644 --- a/interface/src/CrashHandler.cpp +++ b/interface/src/CrashHandler.cpp @@ -12,13 +12,72 @@ #include "CrashHandler.h" #include +#include +#include #include +#include #include +#include #include #include +#include static const QString RUNNING_MARKER_FILENAME = "Interface.running"; +void CrashHandler::checkForAndHandleCrash() { + QFile runningMarkerFile(runningMarkerFilePath()); + if (runningMarkerFile.exists()) { + Action action = promptUserForAction(); + if (action != DO_NOTHING) { + handleCrash(action); + } + } +} + +CrashHandler::Action CrashHandler::promptUserForAction() { + QDialog crashDialog; + crashDialog.setWindowTitle("Interface Crashed Last Run"); + + QVBoxLayout* layout = new QVBoxLayout; + + QLabel* label = new QLabel("What would you like to do?"); + layout->addWidget(label); + + QRadioButton* option1 = new QRadioButton("Delete Interface.ini"); + QRadioButton* option2 = new QRadioButton("Delete Interface.ini but retain login and avatar info."); + QRadioButton* option3 = new QRadioButton("Continue with my current Interface.ini"); + option3->setChecked(true); + layout->addWidget(option1); + layout->addWidget(option2); + layout->addWidget(option3); + layout->addSpacing(12); + layout->addStretch(); + + QDialogButtonBox* buttons = new QDialogButtonBox(QDialogButtonBox::Ok); + layout->addWidget(buttons); + crashDialog.connect(buttons, SIGNAL(accepted()), SLOT(accept())); + + crashDialog.setLayout(layout); + + int result = crashDialog.exec(); + + if (result == QDialog::Accepted) { + if (option1->isChecked()) { + return CrashHandler::DELETE_INTERFACE; + } + if (option2->isChecked()) { + return CrashHandler::RETAIN_LOGIN_AND_AVATAR_INFO; + } + } + + // Dialog cancelled or "do nothing" option chosen + return CrashHandler::DO_NOTHING; +} + +void CrashHandler::handleCrash(CrashHandler::Action action) { + // TODO +} + void CrashHandler::writeRunningMarkerFiler() { QFile runningMarkerFile(runningMarkerFilePath()); if (!runningMarkerFile.exists()) { diff --git a/interface/src/CrashHandler.h b/interface/src/CrashHandler.h index d354c49d07..2b3b78c1f2 100644 --- a/interface/src/CrashHandler.h +++ b/interface/src/CrashHandler.h @@ -17,10 +17,21 @@ class CrashHandler { public: + static void checkForAndHandleCrash(); + static void writeRunningMarkerFiler(); static void deleteRunningMarkerFile(); private: + enum Action { + DELETE_INTERFACE, + RETAIN_LOGIN_AND_AVATAR_INFO, + DO_NOTHING + }; + + static Action promptUserForAction(); + static void handleCrash(Action action); + static const QString runningMarkerFilePath(); }; From f6cf77ae689434964ea7b60a5f04494ccead53a4 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Mon, 24 Aug 2015 13:24:31 -0700 Subject: [PATCH 4/9] Add Developer > Display Crash Options menu item Is enabled by default. Disabling it stops the display of the crash handling options dialog at start-up. --- interface/src/Application.cpp | 2 ++ interface/src/CrashHandler.cpp | 16 +++++++++------- interface/src/Menu.cpp | 1 + interface/src/Menu.h | 1 + libraries/shared/src/SettingInterface.cpp | 11 +++++++---- libraries/shared/src/SettingInterface.h | 1 + 6 files changed, 21 insertions(+), 11 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index ca09960abd..6e8c1065c9 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -257,6 +257,8 @@ bool setupEssentials(int& argc, char** argv) { // Set build version QCoreApplication::setApplicationVersion(BUILD_VERSION); + Setting::preInit(); + CrashHandler::checkForAndHandleCrash(); CrashHandler::writeRunningMarkerFiler(); qAddPostRoutine(CrashHandler::deleteRunningMarkerFile); diff --git a/interface/src/CrashHandler.cpp b/interface/src/CrashHandler.cpp index b58e739176..c64aa3d201 100644 --- a/interface/src/CrashHandler.cpp +++ b/interface/src/CrashHandler.cpp @@ -22,14 +22,20 @@ #include #include +#include "Menu.h" + static const QString RUNNING_MARKER_FILENAME = "Interface.running"; void CrashHandler::checkForAndHandleCrash() { QFile runningMarkerFile(runningMarkerFilePath()); if (runningMarkerFile.exists()) { - Action action = promptUserForAction(); - if (action != DO_NOTHING) { - handleCrash(action); + QSettings settings; + settings.beginGroup("Developer"); + if (settings.value(MenuOption::DisplayCrashOptions).toBool()) { + Action action = promptUserForAction(); + if (action != DO_NOTHING) { + handleCrash(action); + } } } } @@ -93,9 +99,5 @@ void CrashHandler::deleteRunningMarkerFile() { } const QString CrashHandler::runningMarkerFilePath() { - QSettings::setDefaultFormat(QSettings::IniFormat); - QSettings applicationInfo(PathUtils::resourcesPath() + "info/ApplicationInfo.ini", QSettings::IniFormat); - applicationInfo.beginGroup("INFO"); - QCoreApplication::setOrganizationName(applicationInfo.value("organizationName").toString()); return QStandardPaths::writableLocation(QStandardPaths::DataLocation) + "/" + RUNNING_MARKER_FILENAME; } diff --git a/interface/src/Menu.cpp b/interface/src/Menu.cpp index d08970a693..8c86d47710 100644 --- a/interface/src/Menu.cpp +++ b/interface/src/Menu.cpp @@ -575,6 +575,7 @@ Menu::Menu() { addCheckableActionToQMenuAndActionHash(physicsOptionsMenu, MenuOption::PhysicsShowOwned); addCheckableActionToQMenuAndActionHash(physicsOptionsMenu, MenuOption::PhysicsShowHulls); + addCheckableActionToQMenuAndActionHash(developerMenu, MenuOption::DisplayCrashOptions, 0, true); addActionToQMenuAndActionHash(developerMenu, MenuOption::CrashInterface, 0, qApp, SLOT(crashApplication())); MenuWrapper* helpMenu = addMenu("Help"); diff --git a/interface/src/Menu.h b/interface/src/Menu.h index e9ce8bcaba..f81a38872e 100644 --- a/interface/src/Menu.h +++ b/interface/src/Menu.h @@ -173,6 +173,7 @@ namespace MenuOption { const QString DisableLightEntities = "Disable Light Entities"; const QString DisableNackPackets = "Disable Entity NACK Packets"; const QString DiskCacheEditor = "Disk Cache Editor"; + const QString DisplayCrashOptions = "Display Crash Options"; const QString DisplayHands = "Show Hand Info"; const QString DisplayHandTargets = "Show Hand Targets"; const QString DisplayModelBounds = "Display Model Bounds"; diff --git a/libraries/shared/src/SettingInterface.cpp b/libraries/shared/src/SettingInterface.cpp index b60ffc0891..b3b9ce32f9 100644 --- a/libraries/shared/src/SettingInterface.cpp +++ b/libraries/shared/src/SettingInterface.cpp @@ -35,9 +35,9 @@ namespace Setting { settingsManagerThread->quit(); settingsManagerThread->wait(); } - - // Sets up the settings private instance. Should only be run once at startup - void init() { + + // Set up application settings. Should only be run once at startup. + void preInit() { // read the ApplicationInfo.ini file for Name/Version/Domain information QSettings::setDefaultFormat(QSettings::IniFormat); QSettings applicationInfo(PathUtils::resourcesPath() + "info/ApplicationInfo.ini", QSettings::IniFormat); @@ -46,7 +46,10 @@ namespace Setting { QCoreApplication::setApplicationName(applicationInfo.value("name").toString()); QCoreApplication::setOrganizationName(applicationInfo.value("organizationName").toString()); QCoreApplication::setOrganizationDomain(applicationInfo.value("organizationDomain").toString()); - + } + + // Sets up the settings private instance. Should only be run once at startup. preInit() must be run beforehand, + void init() { // Let's set up the settings Private instance on its own thread QThread* thread = new QThread(); Q_CHECK_PTR(thread); diff --git a/libraries/shared/src/SettingInterface.h b/libraries/shared/src/SettingInterface.h index 5092fd09c8..c8b1595a75 100644 --- a/libraries/shared/src/SettingInterface.h +++ b/libraries/shared/src/SettingInterface.h @@ -16,6 +16,7 @@ #include namespace Setting { + void preInit(); void init(); void cleanupSettings(); From 110e7a773b196ffe2589c2a5d57d485a372cc84e Mon Sep 17 00:00:00 2001 From: David Rowe Date: Mon, 24 Aug 2015 13:36:03 -0700 Subject: [PATCH 5/9] Implement crash option that deletes Interface.ini --- interface/src/CrashHandler.cpp | 14 +++++++++++++- interface/src/CrashHandler.h | 2 +- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/interface/src/CrashHandler.cpp b/interface/src/CrashHandler.cpp index c64aa3d201..6e9897fb82 100644 --- a/interface/src/CrashHandler.cpp +++ b/interface/src/CrashHandler.cpp @@ -69,7 +69,7 @@ CrashHandler::Action CrashHandler::promptUserForAction() { if (result == QDialog::Accepted) { if (option1->isChecked()) { - return CrashHandler::DELETE_INTERFACE; + return CrashHandler::DELETE_INTERFACE_INI; } if (option2->isChecked()) { return CrashHandler::RETAIN_LOGIN_AND_AVATAR_INFO; @@ -81,7 +81,19 @@ CrashHandler::Action CrashHandler::promptUserForAction() { } void CrashHandler::handleCrash(CrashHandler::Action action) { + if (action == CrashHandler::DELETE_INTERFACE_INI) { + QSettings settings; + QFile settingsFile(settings.fileName()); + if (settingsFile.exists()) { + settingsFile.remove(); + } + return; + } + // TODO + + // CrashHandler::DO_NOTHING or unexpected value + return; } void CrashHandler::writeRunningMarkerFiler() { diff --git a/interface/src/CrashHandler.h b/interface/src/CrashHandler.h index 2b3b78c1f2..fc754cf1ac 100644 --- a/interface/src/CrashHandler.h +++ b/interface/src/CrashHandler.h @@ -24,7 +24,7 @@ public: private: enum Action { - DELETE_INTERFACE, + DELETE_INTERFACE_INI, RETAIN_LOGIN_AND_AVATAR_INFO, DO_NOTHING }; From b27d25b46edc0f0dd1b047f1d7eda8f5604718c8 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Mon, 24 Aug 2015 16:41:25 -0700 Subject: [PATCH 6/9] Implement crash option that retains only login and avatar information --- interface/src/CrashHandler.cpp | 87 ++++++++++++++++++++++++++++++---- 1 file changed, 77 insertions(+), 10 deletions(-) diff --git a/interface/src/CrashHandler.cpp b/interface/src/CrashHandler.cpp index 6e9897fb82..b6d28ef161 100644 --- a/interface/src/CrashHandler.cpp +++ b/interface/src/CrashHandler.cpp @@ -22,16 +22,22 @@ #include #include +#include "DataServerAccountInfo.h" #include "Menu.h" +Q_DECLARE_METATYPE(DataServerAccountInfo) + static const QString RUNNING_MARKER_FILENAME = "Interface.running"; void CrashHandler::checkForAndHandleCrash() { QFile runningMarkerFile(runningMarkerFilePath()); if (runningMarkerFile.exists()) { + QSettings::setDefaultFormat(QSettings::IniFormat); QSettings settings; settings.beginGroup("Developer"); - if (settings.value(MenuOption::DisplayCrashOptions).toBool()) { + bool displayCrashOptions = settings.value(MenuOption::DisplayCrashOptions).toBool(); + settings.endGroup(); + if (displayCrashOptions) { Action action = promptUserForAction(); if (action != DO_NOTHING) { handleCrash(action); @@ -81,19 +87,80 @@ CrashHandler::Action CrashHandler::promptUserForAction() { } void CrashHandler::handleCrash(CrashHandler::Action action) { - if (action == CrashHandler::DELETE_INTERFACE_INI) { - QSettings settings; - QFile settingsFile(settings.fileName()); - if (settingsFile.exists()) { - settingsFile.remove(); - } + if (action != CrashHandler::DELETE_INTERFACE_INI && action != CrashHandler::RETAIN_LOGIN_AND_AVATAR_INFO) { + // CrashHandler::DO_NOTHING or unexpected value return; } - // TODO + QSettings::setDefaultFormat(QSettings::IniFormat); + QSettings settings; + const QString ADDRESS_MANAGER_GROUP = "AddressManager"; + const QString ADDRESS_KEY = "address"; + const QString AVATAR_GROUP = "Avatar"; + const QString DISPLAY_NAME_KEY = "displayName"; + const QString FULL_AVATAR_URL_KEY = "fullAvatarURL"; + const QString FULL_AVATAR_MODEL_NAME_KEY = "fullAvatarModelName"; + const QString ACCOUNTS_GROUP = "accounts"; + QString displayName; + QUrl fullAvatarURL; + QString fullAvatarModelName; + QUrl address; + QMap accounts; - // CrashHandler::DO_NOTHING or unexpected value - return; + if (action == CrashHandler::RETAIN_LOGIN_AND_AVATAR_INFO) { + // Read login and avatar info + + qRegisterMetaType("DataServerAccountInfo"); + qRegisterMetaTypeStreamOperators("DataServerAccountInfo"); + + // Location and orientation + settings.beginGroup(ADDRESS_MANAGER_GROUP); + address = settings.value(ADDRESS_KEY).toUrl(); + settings.endGroup(); + + // Display name and avatar + settings.beginGroup(AVATAR_GROUP); + displayName = settings.value(DISPLAY_NAME_KEY).toString(); + fullAvatarURL = settings.value(FULL_AVATAR_URL_KEY).toUrl(); + fullAvatarModelName = settings.value(FULL_AVATAR_MODEL_NAME_KEY).toString(); + settings.endGroup(); + + // Accounts + settings.beginGroup(ACCOUNTS_GROUP); + foreach(const QString& key, settings.allKeys()) { + accounts.insert(key, settings.value(key).value()); + } + settings.endGroup(); + } + + // Delete Interface.ini + QFile settingsFile(settings.fileName()); + if (settingsFile.exists()) { + settingsFile.remove(); + } + + if (action == CrashHandler::RETAIN_LOGIN_AND_AVATAR_INFO) { + // Write login and avatar info + + // Location and orientation + settings.beginGroup(ADDRESS_MANAGER_GROUP); + settings.setValue(ADDRESS_KEY, address); + settings.endGroup(); + + // Display name and avatar + settings.beginGroup(AVATAR_GROUP); + settings.setValue(DISPLAY_NAME_KEY, displayName); + settings.setValue(FULL_AVATAR_URL_KEY, fullAvatarURL); + settings.setValue(FULL_AVATAR_MODEL_NAME_KEY, fullAvatarModelName); + settings.endGroup(); + + // Accounts + settings.beginGroup(ACCOUNTS_GROUP); + foreach(const QString& key, accounts.keys()) { + settings.setValue(key, QVariant::fromValue(accounts.value(key))); + } + settings.endGroup(); + } } void CrashHandler::writeRunningMarkerFiler() { From a98a867b06bb10b097bf057ff784b0aa8288358c Mon Sep 17 00:00:00 2001 From: David Rowe Date: Tue, 25 Aug 2015 11:07:20 -0700 Subject: [PATCH 7/9] Delete Interface.ini.lock before accessing to check crash option --- libraries/shared/src/SettingInterface.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/libraries/shared/src/SettingInterface.cpp b/libraries/shared/src/SettingInterface.cpp index b3b9ce32f9..11ed64cac4 100644 --- a/libraries/shared/src/SettingInterface.cpp +++ b/libraries/shared/src/SettingInterface.cpp @@ -46,6 +46,15 @@ namespace Setting { QCoreApplication::setApplicationName(applicationInfo.value("name").toString()); QCoreApplication::setOrganizationName(applicationInfo.value("organizationName").toString()); QCoreApplication::setOrganizationDomain(applicationInfo.value("organizationDomain").toString()); + + // Delete Interface.ini.lock file if it exists, otherwise Interface freezes. + QSettings settings; + QString settingsLockFilename = settings.fileName() + ".lock"; + QFile settingsLockFile(settingsLockFilename); + if (settingsLockFile.exists()) { + bool deleted = settingsLockFile.remove(); + qCDebug(shared) << (deleted ? "Deleted" : "Failed to delete") << "settings lock file" << settingsLockFilename; + } } // Sets up the settings private instance. Should only be run once at startup. preInit() must be run beforehand, @@ -58,14 +67,6 @@ namespace Setting { privateInstance = new Manager(); Q_CHECK_PTR(privateInstance); - // Delete Interface.ini.lock file if it exists, otherwise Interface freezes. - QString settingsLockFilename = privateInstance->fileName() + ".lock"; - QFile settingsLockFile(settingsLockFilename); - if (settingsLockFile.exists()) { - bool deleted = settingsLockFile.remove(); - qCDebug(shared) << (deleted ? "Deleted" : "Failed to delete") << "settings lock file" << settingsLockFilename; - } - QObject::connect(privateInstance, SIGNAL(destroyed()), thread, SLOT(quit())); QObject::connect(thread, SIGNAL(started()), privateInstance, SLOT(startTimer())); QObject::connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater())); From 7c8ff4dcbdce6cb676f2ed341f32d2b64b63533c Mon Sep 17 00:00:00 2001 From: David Rowe Date: Tue, 25 Aug 2015 11:07:55 -0700 Subject: [PATCH 8/9] If Interface.ini doesn't contain crash option value assume default --- interface/src/CrashHandler.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/interface/src/CrashHandler.cpp b/interface/src/CrashHandler.cpp index b6d28ef161..349b48da37 100644 --- a/interface/src/CrashHandler.cpp +++ b/interface/src/CrashHandler.cpp @@ -35,9 +35,10 @@ void CrashHandler::checkForAndHandleCrash() { QSettings::setDefaultFormat(QSettings::IniFormat); QSettings settings; settings.beginGroup("Developer"); - bool displayCrashOptions = settings.value(MenuOption::DisplayCrashOptions).toBool(); + QVariant displayCrashOptions = settings.value(MenuOption::DisplayCrashOptions); settings.endGroup(); - if (displayCrashOptions) { + if (!displayCrashOptions.isValid() // Option does not exist in Interface.ini so assume default behavior. + || displayCrashOptions.toBool()) { Action action = promptUserForAction(); if (action != DO_NOTHING) { handleCrash(action); From 1f541832b69f26bdd223e2fe19b098a52e0d5d2a Mon Sep 17 00:00:00 2001 From: David Rowe Date: Tue, 25 Aug 2015 14:24:15 -0700 Subject: [PATCH 9/9] Reword dialog --- interface/src/CrashHandler.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/interface/src/CrashHandler.cpp b/interface/src/CrashHandler.cpp index 349b48da37..ce5facb580 100644 --- a/interface/src/CrashHandler.cpp +++ b/interface/src/CrashHandler.cpp @@ -53,12 +53,12 @@ CrashHandler::Action CrashHandler::promptUserForAction() { QVBoxLayout* layout = new QVBoxLayout; - QLabel* label = new QLabel("What would you like to do?"); + QLabel* label = new QLabel("If you are having trouble starting would you like to reset your settings?"); layout->addWidget(label); - QRadioButton* option1 = new QRadioButton("Delete Interface.ini"); - QRadioButton* option2 = new QRadioButton("Delete Interface.ini but retain login and avatar info."); - QRadioButton* option3 = new QRadioButton("Continue with my current Interface.ini"); + QRadioButton* option1 = new QRadioButton("Reset all my settings"); + QRadioButton* option2 = new QRadioButton("Reset my settings but retain login and avatar info."); + QRadioButton* option3 = new QRadioButton("Continue with my current settings"); option3->setChecked(true); layout->addWidget(option1); layout->addWidget(option2);