From 240900de39aaf1562332ed88708b4b128703ad0e Mon Sep 17 00:00:00 2001 From: Eran Mizrahi Date: Tue, 12 Dec 2017 23:22:04 +0200 Subject: Move crash dumps to instance-dependant data folder --- src/main.cpp | 5 +++-- src/organizercore.cpp | 9 ++++----- src/settings.cpp | 12 ++++++++++++ src/settings.h | 2 ++ src/settingsdialog.ui | 9 +++++---- src/shared/appconfig.inc | 1 + 6 files changed, 27 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/main.cpp b/src/main.cpp index eed4dfd3..b4faf570 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -528,8 +528,6 @@ int runApplication(MOApplication &application, SingleInstance &instance, int main(int argc, char *argv[]) { - prevUnhandledExceptionFilter = SetUnhandledExceptionFilter(MyUnhandledExceptionFilter); - MOApplication application(argc, argv); QStringList arguments = application.arguments(); @@ -586,6 +584,9 @@ int main(int argc, char *argv[]) } application.setProperty("dataPath", dataPath); + // initialize dump collection only after "dataPath" since the crashes are stored under it + prevUnhandledExceptionFilter = SetUnhandledExceptionFilter(MyUnhandledExceptionFilter); + LogBuffer::init(100, QtDebugMsg, qApp->property("dataPath").toString() + "/logs/mo_interface.log"); QString splash = dataPath + "/splash.png"; diff --git a/src/organizercore.cpp b/src/organizercore.cpp index bc0578b3..deb0b718 100644 --- a/src/organizercore.cpp +++ b/src/organizercore.cpp @@ -670,11 +670,10 @@ void OrganizerCore::setGlobalCrashDumpsType(int crashDumpsType) { //static std::wstring OrganizerCore::crashDumpsPath() { - wchar_t appDataLocal[MAX_PATH]{ 0 }; - ::SHGetFolderPathW(NULL, CSIDL_LOCAL_APPDATA, NULL, 0, appDataLocal); - std::wstring dumpPath{ appDataLocal }; - dumpPath += L"\\modorganizer\\crashDumps"; - return dumpPath; + return ( + qApp->property("dataPath").toString() + "/" + + QString::fromStdWString(AppConfig::dumpsDir()) + ).toStdWString(); } void OrganizerCore::setCurrentProfile(const QString &profileName) diff --git a/src/settings.cpp b/src/settings.cpp index 05a62591..b2fc8939 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -24,6 +24,7 @@ along with Mod Organizer. If not, see . #include "settingsdialog.h" #include "versioninfo.h" #include "appconfig.h" +#include "organizercore.h" #include #include #include @@ -48,6 +49,7 @@ along with Mod Organizer. If not, see . #include #include #include +#include #include // for Qt::UserRole, etc #include // for qDebug, qWarning @@ -755,10 +757,20 @@ Settings::DiagnosticsTab::DiagnosticsTab(Settings *m_parent, SettingsDialog &m_d , m_logLevelBox(m_dialog.findChild("logLevelBox")) , m_dumpsTypeBox(m_dialog.findChild("dumpsTypeBox")) , m_dumpsMaxEdit(m_dialog.findChild("dumpsMaxEdit")) + , m_diagnosticsExplainedLabel(m_dialog.findChild("diagnosticsExplainedLabel")) { m_logLevelBox->setCurrentIndex(m_parent->logLevel()); m_dumpsTypeBox->setCurrentIndex(m_parent->crashDumpsType()); m_dumpsMaxEdit->setValue(m_parent->crashDumpsMax()); + QString logsPath = qApp->property("dataPath").toString() + + "/" + QString::fromStdWString(AppConfig::logPath()); + m_diagnosticsExplainedLabel->setText( + m_diagnosticsExplainedLabel->text() + .replace("LOGS_FULL_PATH", logsPath) + .replace("LOGS_DIR", QString::fromStdWString(AppConfig::logPath())) + .replace("DUMPS_FULL_PATH", QString::fromStdWString(OrganizerCore::crashDumpsPath())) + .replace("DUMPS_DIR", QString::fromStdWString(AppConfig::dumpsDir())) + ); } void Settings::DiagnosticsTab::update() diff --git a/src/settings.h b/src/settings.h index 9ee29ba3..ae38223f 100644 --- a/src/settings.h +++ b/src/settings.h @@ -41,6 +41,7 @@ class QLineEdit; class QSpinBox; class QListWidget; class QWidget; +class QLabel; struct ServerInfo; @@ -414,6 +415,7 @@ private: QComboBox *m_logLevelBox; QComboBox *m_dumpsTypeBox; QSpinBox *m_dumpsMaxEdit; + QLabel *m_diagnosticsExplainedLabel; }; /** Display/store the configuration in the 'nexus' tab of the settings dialogue */ diff --git a/src/settingsdialog.ui b/src/settingsdialog.ui index 6d462cfa..7a902748 100644 --- a/src/settingsdialog.ui +++ b/src/settingsdialog.ui @@ -483,12 +483,13 @@ If you use pre-releases, never contact me directly by e-mail or via private mess - + - Dumps are stored in <a href="%LOCALAPPDATA%\modorganizer\crashDumps">%LOCALAPPDATA%\modorganizer\crashDumps</a>. - Sending such dumps to the developers can help solve crashes caused by MO. - It is recommended to compress the dumps before sending, especially on the larger settings. + Logs and crash dumps are stored under your current instance in the <a href="LOGS_FULL_PATH">LOGS_DIR</a> + and <a href="DUMPS_FULL_PATH">DUMPS_DIR</a> folders. + Sending logs and/or crash dumps to the developers can help investigate issues. + It is recommended to compress large log and dmp files before sending. diff --git a/src/shared/appconfig.inc b/src/shared/appconfig.inc index e98757d3..e572a32b 100644 --- a/src/shared/appconfig.inc +++ b/src/shared/appconfig.inc @@ -8,6 +8,7 @@ APPPARAM(std::wstring, stylesheetsPath, L"stylesheets") APPPARAM(std::wstring, cachePath, L"webcache") APPPARAM(std::wstring, tutorialsPath, L"tutorials") APPPARAM(std::wstring, logPath, L"logs") +APPPARAM(std::wstring, dumpsDir, L"crashDumps") APPPARAM(std::wstring, profileTweakIni, L"profile_tweaks.ini") APPPARAM(std::wstring, logFileName, L"ModOrganizer.log") APPPARAM(std::wstring, iniFileName, L"ModOrganizer.ini") -- cgit v1.3.1