From 4adb13c9435baade511d3ac78fb142dc73bd2e1f Mon Sep 17 00:00:00 2001 From: Eran Mizrahi Date: Fri, 8 Dec 2017 18:24:06 +0200 Subject: generate dumps using new diagnostics settings --- src/mainwindow.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/mainwindow.cpp') diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 48dfdfbd..cab4c41f 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -3296,7 +3296,7 @@ void MainWindow::on_actionSettings_triggered() updateDownloadListDelegate(); - m_OrganizerCore.setLogLevel(settings.logLevel()); + m_OrganizerCore.updateVFSParams(settings.logLevel(), settings.crashDumpsType()); } -- cgit v1.3.1 From 1b4b6dbeb46aa7e6b87b3de32cd8953fa0d32a7a Mon Sep 17 00:00:00 2001 From: Eran Mizrahi Date: Sat, 9 Dec 2017 01:56:16 +0200 Subject: cycle crash dumps --- src/mainwindow.cpp | 1 + src/organizercore.cpp | 10 +++++++++- src/organizercore.h | 2 ++ 3 files changed, 12 insertions(+), 1 deletion(-) (limited to 'src/mainwindow.cpp') diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index cab4c41f..b47e9c57 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -3297,6 +3297,7 @@ void MainWindow::on_actionSettings_triggered() updateDownloadListDelegate(); m_OrganizerCore.updateVFSParams(settings.logLevel(), settings.crashDumpsType()); + m_OrganizerCore.cycleDiagnostics(); } diff --git a/src/organizercore.cpp b/src/organizercore.cpp index adb895ec..7f86f2b4 100644 --- a/src/organizercore.cpp +++ b/src/organizercore.cpp @@ -630,7 +630,8 @@ bool OrganizerCore::bootstrap() { return createDirectory(m_Settings.getProfileDirectory()) && createDirectory(m_Settings.getModDirectory()) && createDirectory(m_Settings.getDownloadDirectory()) && - createDirectory(m_Settings.getOverwriteDirectory()); + createDirectory(m_Settings.getOverwriteDirectory()) && + createDirectory(QString::fromStdWString(crashDumpsPath())) && cycleDiagnostics(); } void OrganizerCore::createDefaultProfile() @@ -652,6 +653,12 @@ void OrganizerCore::updateVFSParams(int logLevel, int crashDumpsType) { m_USVFS.updateParams(logLevel, crashDumpsType); } +bool OrganizerCore::cycleDiagnostics() { + if (int maxDumps = settings().crashDumpsMax()) + removeOldFiles(QString::fromStdWString(crashDumpsPath()), "*.dmp", maxDumps, QDir::Time|QDir::Reversed); + return true; +} + //static void OrganizerCore::setGlobalCrashDumpsType(int crashDumpsType) { m_globalCrashDumpsType = ::crashDumpsType(crashDumpsType); @@ -1083,6 +1090,7 @@ void OrganizerCore::spawnBinary(const QFileInfo &binary, const QString &argument refreshESPList(); savePluginList(); + cycleDiagnostics(); //These callbacks should not fiddle with directoy structure and ESPs. m_FinishedRun(binary.absoluteFilePath(), processExitCode); diff --git a/src/organizercore.h b/src/organizercore.h index 7bb7faa7..40531195 100644 --- a/src/organizercore.h +++ b/src/organizercore.h @@ -160,6 +160,8 @@ public: void updateVFSParams(int logLevel, int crashDumpsType); + bool cycleDiagnostics(); + static CrashDumpsType getGlobalCrashDumpsType() { return m_globalCrashDumpsType; } static void setGlobalCrashDumpsType(int crashDumpsType); static std::wstring crashDumpsPath(); -- cgit v1.3.1 From 66b17eea8ac83ee6f7b729974240d995a1e8ed3a Mon Sep 17 00:00:00 2001 From: Eran Mizrahi Date: Sat, 9 Dec 2017 21:39:22 +0200 Subject: Wait for processes run using command line shortcuts --- src/CMakeLists.txt | 1 + src/ilockedwaitingforprocess.h | 13 ++++++++++++ src/iuserinterface.h | 7 ++----- src/lockeddialog.h | 7 ++++--- src/mainwindow.cpp | 21 +++---------------- src/mainwindow.h | 4 +--- src/organizercore.cpp | 46 +++++++++++++++++++++++++++++++++--------- src/organizercore.h | 2 +- 8 files changed, 62 insertions(+), 39 deletions(-) create mode 100644 src/ilockedwaitingforprocess.h (limited to 'src/mainwindow.cpp') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index d603336c..39aabb91 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -169,6 +169,7 @@ SET(organizer_HDRS viewmarkingscrollbar.h plugincontainer.h organizercore.h + ilockedwaitingforprocess.h iuserinterface.h instancemanager.h usvfsconnector.h diff --git a/src/ilockedwaitingforprocess.h b/src/ilockedwaitingforprocess.h new file mode 100644 index 00000000..6a4267d4 --- /dev/null +++ b/src/ilockedwaitingforprocess.h @@ -0,0 +1,13 @@ +#ifndef ILOCKEDWAITINGFORPROCESS_H +#define ILOCKEDWAITINGFORPROCESS_H + +class QString; + +class ILockedWaitingForProcess +{ +public: + virtual bool unlockClicked() = 0; + virtual void setProcessName(QString const &) = 0; +}; + +#endif // ILOCKEDWAITINGFORPROCESS_H diff --git a/src/iuserinterface.h b/src/iuserinterface.h index 0af1c2ac..255c7ac0 100644 --- a/src/iuserinterface.h +++ b/src/iuserinterface.h @@ -3,6 +3,7 @@ #include "modinfo.h" +#include "ilockedwaitingforprocess.h" #include #include #include @@ -27,12 +28,8 @@ public: virtual void displayModInformation(ModInfo::Ptr modInfo, unsigned int index, int tab) = 0; - virtual void lock() = 0; + virtual ILockedWaitingForProcess* lock() = 0; virtual void unlock() = 0; - virtual bool unlockClicked() = 0; - virtual void setProcessName(QString const &) = 0; - - }; #endif // IUSERINTERFACE_H diff --git a/src/lockeddialog.h b/src/lockeddialog.h index 29ac459b..8803efae 100644 --- a/src/lockeddialog.h +++ b/src/lockeddialog.h @@ -20,6 +20,7 @@ along with Mod Organizer. If not, see . #ifndef LOCKEDDIALOG_H #define LOCKEDDIALOG_H +#include "ilockedwaitingforprocess.h" #include // for QDialog #include // for Q_OBJECT, slots #include // for QString @@ -39,7 +40,7 @@ namespace Ui { * data on which Mod Organizer works. After the UI is unlocked (manually or after the * external application closed) MO will refresh all of its data sources **/ -class LockedDialog : public QDialog +class LockedDialog : public QDialog, public ILockedWaitingForProcess { Q_OBJECT @@ -52,13 +53,13 @@ public: * * @return true if the user clicked the unlock button **/ - bool unlockClicked() const { return m_UnlockClicked; } + bool unlockClicked() override { return m_UnlockClicked; } /** * @brief set the name of the process being run * @param name of process */ - void setProcessName(const QString &name); + void setProcessName(const QString &name) override; protected: diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index b47e9c57..1db895fc 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -1465,17 +1465,18 @@ void MainWindow::storeSettings(QSettings &settings) { } } -void MainWindow::lock() +ILockedWaitingForProcess* MainWindow::lock() { if (m_LockDialog != nullptr) { ++m_LockCount; - return; + return m_LockDialog; } m_LockDialog = new LockedDialog(qApp->activeWindow()); m_LockDialog->show(); setEnabled(false); m_LockDialog->setEnabled(true); //What's the point otherwise? ++m_LockCount; + return m_LockDialog; } void MainWindow::unlock() @@ -1494,22 +1495,6 @@ void MainWindow::unlock() } } -bool MainWindow::unlockClicked() -{ - if (m_LockDialog != nullptr) { - return m_LockDialog->unlockClicked(); - } else { - return false; - } -} - -void MainWindow::setProcessName(QString const &name) -{ - if (m_LockDialog != nullptr) { - m_LockDialog->setProcessName(name); - } -} - void MainWindow::on_btnRefreshData_clicked() { m_OrganizerCore.refreshDirectoryStructure(); diff --git a/src/mainwindow.h b/src/mainwindow.h index cec6c407..f6f11157 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -116,10 +116,8 @@ public: void storeSettings(QSettings &settings) override; void readSettings(); - virtual void lock() override; + virtual ILockedWaitingForProcess* lock() override; virtual void unlock() override; - virtual bool unlockClicked() override; - virtual void setProcessName(QString const &name) override; bool addProfile(); void refreshDataTree(); diff --git a/src/organizercore.cpp b/src/organizercore.cpp index 54cfed54..f0dfa8d4 100644 --- a/src/organizercore.cpp +++ b/src/organizercore.cpp @@ -31,6 +31,7 @@ #include "appconfig.h" #include #include +#include "lockeddialog.h" #include #include @@ -1067,8 +1068,9 @@ QStringList OrganizerCore::modsSortedByProfilePriority() const void OrganizerCore::spawnBinary(const QFileInfo &binary, const QString &arguments, const QDir ¤tDirectory, const QString &steamAppID, const QString &customOverwrite) { + ILockedWaitingForProcess* uilock = nullptr; if (m_UserInterface != nullptr) { - m_UserInterface->lock(); + uilock = m_UserInterface->lock(); } ON_BLOCK_EXIT([&] () { if (m_UserInterface != nullptr) { m_UserInterface->unlock(); } @@ -1077,7 +1079,7 @@ void OrganizerCore::spawnBinary(const QFileInfo &binary, const QString &argument HANDLE processHandle = spawnBinaryDirect(binary, arguments, m_CurrentProfile->name(), currentDirectory, steamAppID, customOverwrite); if (processHandle != INVALID_HANDLE_VALUE) { DWORD processExitCode; - (void)waitForProcessCompletion(processHandle, &processExitCode); + (void)waitForProcessCompletion(processHandle, &processExitCode, uilock); refreshDirectoryStructure(); // need to remove our stored load order because it may be outdated if a foreign tool changed the @@ -1258,24 +1260,50 @@ HANDLE OrganizerCore::startApplication(const QString &executable, } } - return spawnBinaryDirect(binary, arguments, profileName, currentDirectory, - steamAppID, customOverwrite); + HANDLE processHandle = spawnBinaryDirect(binary, arguments, profileName, currentDirectory, steamAppID, customOverwrite); + if (processHandle != INVALID_HANDLE_VALUE) { + std::unique_ptr dlg; + ILockedWaitingForProcess* uilock = nullptr; + + if (m_UserInterface != nullptr) { + uilock = m_UserInterface->lock(); + } + else { + // i.e. when running command line shortcuts there is no m_UserInterface + dlg.reset(new LockedDialog); + dlg->show(); + dlg->setEnabled(true); + uilock = dlg.get(); + } + + ON_BLOCK_EXIT([&]() { + if (m_UserInterface != nullptr) { + m_UserInterface->unlock(); + } }); + + DWORD processExitCode; + waitForProcessCompletion(processHandle, &processExitCode, uilock); + cycleDiagnostics(); + } + + return processHandle; } bool OrganizerCore::waitForApplication(HANDLE handle, LPDWORD exitCode) { + ILockedWaitingForProcess* uilock = nullptr; if (m_UserInterface != nullptr) { - m_UserInterface->lock(); + uilock = m_UserInterface->lock(); } ON_BLOCK_EXIT([&] () { if (m_UserInterface != nullptr) { m_UserInterface->unlock(); } }); - return waitForProcessCompletion(handle, exitCode); + return waitForProcessCompletion(handle, exitCode, uilock); } -bool OrganizerCore::waitForProcessCompletion(HANDLE handle, LPDWORD exitCode) +bool OrganizerCore::waitForProcessCompletion(HANDLE handle, LPDWORD exitCode, ILockedWaitingForProcess* uilock) { DWORD startPID = ::GetProcessId(handle); @@ -1292,7 +1320,7 @@ bool OrganizerCore::waitForProcessCompletion(HANDLE handle, LPDWORD exitCode) while ( res = ::MsgWaitForMultipleObjects(1, &handle, false, 500, QS_KEY | QS_MOUSEBUTTON), - ((m_UserInterface == nullptr) || !m_UserInterface->unlockClicked())) { + ((uilock == nullptr) || !uilock->unlockClicked())) { if (!::GetVFSProcessList(&numProcesses, processes)) { break; @@ -1335,7 +1363,7 @@ bool OrganizerCore::waitForProcessCompletion(HANDLE handle, LPDWORD exitCode) // Update the lock process name with the name of the lowest active PID - though this may not actually be the main process if (handles.size() > 0) - m_UserInterface->setProcessName(QString::fromStdWString(getProcessName(handles.begin()->second))); + uilock->setProcessName(QString::fromStdWString(getProcessName(handles.begin()->second))); // If the main wait process dies, we need a backup wait process until the subprocesses close if ((res == WAIT_FAILED) || (res == WAIT_OBJECT_0)) { diff --git a/src/organizercore.h b/src/organizercore.h index 40531195..0927c88e 100644 --- a/src/organizercore.h +++ b/src/organizercore.h @@ -267,7 +267,7 @@ private: const MOShared::DirectoryEntry *directoryEntry, int createDestination); - bool waitForProcessCompletion(HANDLE handle, LPDWORD exitCode); + bool waitForProcessCompletion(HANDLE handle, LPDWORD exitCode, ILockedWaitingForProcess* uilock); private slots: -- cgit v1.3.1