From f7d7661d58d9b0d158fd959978b29c9c1a3a8de7 Mon Sep 17 00:00:00 2001 From: Seth Riley <17361645+Qudix@users.noreply.github.com> Date: Mon, 2 Nov 2020 13:20:05 -0600 Subject: Changing the location of several directories --- src/CMakeLists.txt | 14 ++++---- src/dlls.manifest | 29 ++++++++++++++++ src/dlls.manifest.qt5 | 29 ---------------- src/env.cpp | 7 ++++ src/env.h | 1 + src/main.cpp | 91 ++++++++++++++------------------------------------- src/qt.conf | 8 +++-- 7 files changed, 76 insertions(+), 103 deletions(-) create mode 100644 src/dlls.manifest delete mode 100644 src/dlls.manifest.qt5 (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e95179b8..79389e42 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -223,17 +223,19 @@ target_include_directories(${CMAKE_PROJECT_NAME} PRIVATE ) -install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/dlls.manifest.qt5 +install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/dlls.manifest DESTINATION bin/dlls RENAME dlls.manifest) -install(FILES ${qm_files} DESTINATION bin/translations) +install(FILES ${qm_files} DESTINATION bin/dlls/translations) install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/stylesheets - ${CMAKE_CURRENT_SOURCE_DIR}/tutorials - DESTINATION bin) + DESTINATION bin) + +install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/tutorials + DESTINATION bin/dlls) deploy_qt(BINARIES ModOrganizer.exe uibase.dll plugins/bsa_packer.dll) -install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/../qdds.dll DESTINATION bin/dlls/imageformats) -install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/resources/markdown.html DESTINATION bin/resources) +install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/../qdds.dll DESTINATION bin/dlls/QtPlugins/imageformats) +install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/resources/markdown.html DESTINATION bin/dlls/resources) diff --git a/src/dlls.manifest b/src/dlls.manifest new file mode 100644 index 00000000..846a02ae --- /dev/null +++ b/src/dlls.manifest @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/dlls.manifest.qt5 b/src/dlls.manifest.qt5 deleted file mode 100644 index cae74df1..00000000 --- a/src/dlls.manifest.qt5 +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/env.cpp b/src/env.cpp index 2862aa95..4e5ad196 100644 --- a/src/env.cpp +++ b/src/env.cpp @@ -394,6 +394,13 @@ QString path() return get("PATH"); } +QString prependToPath(const QString& s) +{ + auto old = path(); + set("PATH", s + ";" + old); + return old; +} + QString addPath(const QString& s) { auto old = path(); diff --git a/src/env.h b/src/env.h index 5c7492c6..954c7bb0 100644 --- a/src/env.h +++ b/src/env.h @@ -236,6 +236,7 @@ QString get(const QString& name); QString set(const QString& name, const QString& value); QString path(); +QString prependToPath(const QString& s); QString addPath(const QString& s); QString setPath(const QString& s); diff --git a/src/main.cpp b/src/main.cpp index a81ae962..60b06817 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -464,69 +464,6 @@ MOBase::IPluginGame *determineCurrentGame( return nullptr; } - -// extend path to include dll directory so plugins don't need a manifest -// (using AddDllDirectory would be an alternative to this but it seems fairly -// complicated esp. -// since it isn't easily accessible on Windows < 8 -// SetDllDirectory replaces other search directories and this seems to -// propagate to child processes) -void setupPath() -{ - static const int BUFSIZE = 4096; - - QCoreApplication::setLibraryPaths(QStringList(QCoreApplication::applicationDirPath() + "/dlls") + QCoreApplication::libraryPaths()); - - boost::scoped_array oldPath(new TCHAR[BUFSIZE]); - DWORD offset = ::GetEnvironmentVariable(TEXT("PATH"), oldPath.get(), BUFSIZE); - if (offset > BUFSIZE) { - oldPath.reset(new TCHAR[offset]); - ::GetEnvironmentVariable(TEXT("PATH"), oldPath.get(), offset); - } - - std::wstring newPath(ToWString(QDir::toNativeSeparators( - QCoreApplication::applicationDirPath())) + L"\\dlls"); - newPath += L";"; - newPath += oldPath.get(); - - ::SetEnvironmentVariableW(L"PATH", newPath.c_str()); -} - -void preloadDll(const QString& filename) -{ - if (GetModuleHandleW(filename.toStdWString().c_str())) { - // already loaded, this can happen when "restarting" MO by switching - // instances, for example - return; - } - - const auto appPath = QDir::toNativeSeparators( - QCoreApplication::applicationDirPath()); - - const auto dllPath = appPath + "\\" + filename; - - if (!QFile::exists(dllPath)) { - log::warn("{} not found", dllPath); - return; - } - - if (!LoadLibraryW(dllPath.toStdWString().c_str())) { - const auto e = GetLastError(); - log::warn("failed to load {}: {}", dllPath, formatSystemMessage(e)); - } -} - -void preloadSsl() -{ -#if Q_PROCESSOR_WORDSIZE == 8 - preloadDll("libcrypto-1_1-x64.dll"); - preloadDll("libssl-1_1-x64.dll"); -#elif Q_PROCESSOR_WORDSIZE == 4 - preloadDll("libcrypto-1_1.dll"); - preloadDll("libssl-1_1.dll"); -#endif -} - static QString getVersionDisplayString() { return createVersionInfo().displayString(3); @@ -543,7 +480,6 @@ int runApplication(MOApplication &application, SingleInstance &instance, getVersionDisplayString(), GITID, QCoreApplication::applicationDirPath(), MOShared::getUsvfsVersionString()); - preloadSsl(); if (!QSslSocket::supportsSsl()) { log::warn("no ssl support"); } @@ -889,6 +825,25 @@ void initLogging() qInstallMessageHandler(qtLogCallback); } +void preloadDll(const QString& filename) +{ + if (GetModuleHandleW(filename.toStdWString().c_str())) + return; + + const auto appPath = QDir::toNativeSeparators(QDir::currentPath()); + const auto dllPath = appPath + "\\dlls\\" + filename; + + if (!QFile::exists(dllPath)) { + log::warn("{} not found", dllPath); + return; + } + + if (!LoadLibraryW(dllPath.toStdWString().c_str())) { + const auto e = GetLastError(); + log::warn("failed to load {}: {}", dllPath, formatSystemMessage(e)); + } +} + int main(int argc, char *argv[]) { @@ -905,6 +860,9 @@ int main(int argc, char *argv[]) } } + preloadDll("libcrypto-1_1-x64.dll"); + preloadDll("libssl-1_1-x64.dll"); + initLogging(); //Make sure the configured temp folder exists @@ -925,9 +883,10 @@ int main(int argc, char *argv[]) MOApplication application(argc, argv); QStringList arguments = application.arguments(); - SetThisThreadName("main"); + env::prependToPath(QDir::toNativeSeparators( + QCoreApplication::applicationDirPath() + "/dlls")); - setupPath(); + SetThisThreadName("main"); bool forcePrimary = false; if (arguments.contains("update")) { diff --git a/src/qt.conf b/src/qt.conf index f834a22a..d5a3f6ac 100644 --- a/src/qt.conf +++ b/src/qt.conf @@ -1,3 +1,7 @@ [Paths] -Prefix=. -Plugins=dlls +Prefix=dlls +Libraries=. +LibraryExecutables=. +Plugins=QtPlugins +Imports=QtImports +Qml2Imports=QtImports \ No newline at end of file -- cgit v1.3.1 From 5bad8f903205fb0e21c60fafd0d6913d3143a477 Mon Sep 17 00:00:00 2001 From: Seth Riley <17361645+Qudix@users.noreply.github.com> Date: Mon, 2 Nov 2020 19:13:04 -0600 Subject: Fixed tutorials --- src/main.cpp | 6 ++---- src/mainwindow.cpp | 4 ++-- src/qt.conf | 3 ++- 3 files changed, 6 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/main.cpp b/src/main.cpp index 60b06817..a3e30fa0 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -693,10 +693,8 @@ int runApplication(MOApplication &application, SingleInstance &instance, } log::debug("initializing tutorials"); - TutorialManager::init( - qApp->applicationDirPath() + "/" - + QString::fromStdWString(AppConfig::tutorialsPath()) + "/", - &organizer); + QString tutorialsPath = QCoreApplication::applicationDirPath() + "/dlls/tutorials/"; + TutorialManager::init(tutorialsPath, &organizer); if (!application.setStyleFile(settings.interface().styleName().value_or(""))) { // disable invalid stylesheet diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 65c1d65c..650f5db3 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -1203,7 +1203,7 @@ void MainWindow::createHelpMenu() ActionList tutorials; - QDirIterator dirIter(QApplication::applicationDirPath() + "/tutorials", QStringList("*.js"), QDir::Files); + QDirIterator dirIter(QApplication::applicationDirPath() + "/dlls/tutorials", QStringList("*.js"), QDir::Files); while (dirIter.hasNext()) { dirIter.next(); QString fileName = dirIter.fileName(); @@ -1315,7 +1315,7 @@ bool MainWindow::addProfile() void MainWindow::hookUpWindowTutorials() { - QDirIterator dirIter(QApplication::applicationDirPath() + "/tutorials", QStringList("*.js"), QDir::Files); + QDirIterator dirIter(QApplication::applicationDirPath() + "/dlls/tutorials", QStringList("*.js"), QDir::Files); while (dirIter.hasNext()) { dirIter.next(); QString fileName = dirIter.fileName(); diff --git a/src/qt.conf b/src/qt.conf index d5a3f6ac..6a9d56ae 100644 --- a/src/qt.conf +++ b/src/qt.conf @@ -4,4 +4,5 @@ Libraries=. LibraryExecutables=. Plugins=QtPlugins Imports=QtImports -Qml2Imports=QtImports \ No newline at end of file +Qml2Imports=QtImports +Translations=translations \ No newline at end of file -- cgit v1.3.1 From 7cc76f7cea3445f4081477e91721a922d69fdb9b Mon Sep 17 00:00:00 2001 From: Seth Riley <17361645+Qudix@users.noreply.github.com> Date: Mon, 2 Nov 2020 19:40:13 -0600 Subject: Fix for deprecated implicit function definition --- src/tutorials/TutorialOverlay.qml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/tutorials/TutorialOverlay.qml b/src/tutorials/TutorialOverlay.qml index 47e5065d..0a31ef0e 100644 --- a/src/tutorials/TutorialOverlay.qml +++ b/src/tutorials/TutorialOverlay.qml @@ -55,7 +55,9 @@ Rectangle { Connections { target: manager - onTabChanged: tabChanged(index) + function onTabChanged() { + tabChanged(index) + } } Tooltip { -- cgit v1.3.1 From 68750575d2f28c873b0d68391a7940e61c2ad2d4 Mon Sep 17 00:00:00 2001 From: Seth Riley <17361645+Qudix@users.noreply.github.com> Date: Tue, 3 Nov 2020 18:12:23 -0600 Subject: Implement suggestions --- src/CMakeLists.txt | 8 ++++---- src/main.cpp | 2 +- src/mainwindow.cpp | 6 +++--- src/qt.conf | 14 +++++++------- src/settingsdialoggeneral.cpp | 2 +- 5 files changed, 16 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 79389e42..782d6589 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -227,15 +227,15 @@ install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/dlls.manifest DESTINATION bin/dlls RENAME dlls.manifest) -install(FILES ${qm_files} DESTINATION bin/dlls/translations) +install(FILES ${qm_files} DESTINATION bin/resources/translations) install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/stylesheets DESTINATION bin) install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/tutorials - DESTINATION bin/dlls) + DESTINATION bin/resources) deploy_qt(BINARIES ModOrganizer.exe uibase.dll plugins/bsa_packer.dll) -install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/../qdds.dll DESTINATION bin/dlls/QtPlugins/imageformats) -install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/resources/markdown.html DESTINATION bin/dlls/resources) +install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/../qdds.dll DESTINATION bin/dlls/imageformats) +install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/resources/markdown.html DESTINATION bin/resources) diff --git a/src/main.cpp b/src/main.cpp index a3e30fa0..6b1ec482 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -693,7 +693,7 @@ int runApplication(MOApplication &application, SingleInstance &instance, } log::debug("initializing tutorials"); - QString tutorialsPath = QCoreApplication::applicationDirPath() + "/dlls/tutorials/"; + QString tutorialsPath = QCoreApplication::applicationDirPath() + "/resources/tutorials/"; TutorialManager::init(tutorialsPath, &organizer); if (!application.setStyleFile(settings.interface().styleName().value_or(""))) { diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 650f5db3..522657fb 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -1203,7 +1203,7 @@ void MainWindow::createHelpMenu() ActionList tutorials; - QDirIterator dirIter(QApplication::applicationDirPath() + "/dlls/tutorials", QStringList("*.js"), QDir::Files); + QDirIterator dirIter(QApplication::applicationDirPath() + "/resources/tutorials", QStringList("*.js"), QDir::Files); while (dirIter.hasNext()) { dirIter.next(); QString fileName = dirIter.fileName(); @@ -1315,7 +1315,7 @@ bool MainWindow::addProfile() void MainWindow::hookUpWindowTutorials() { - QDirIterator dirIter(QApplication::applicationDirPath() + "/dlls/tutorials", QStringList("*.js"), QDir::Files); + QDirIterator dirIter(QApplication::applicationDirPath() + "/resources/tutorials", QStringList("*.js"), QDir::Files); while (dirIter.hasNext()) { dirIter.next(); QString fileName = dirIter.fileName(); @@ -5185,7 +5185,7 @@ void MainWindow::installTranslator(const QString &name) { QTranslator *translator = new QTranslator(this); QString fileName = name + "_" + m_CurrentLanguage; - if (!translator->load(fileName, qApp->applicationDirPath() + "/translations")) { + if (!translator->load(fileName, qApp->applicationDirPath() + "/resources/translations")) { if (m_CurrentLanguage.contains(QRegularExpression("^.*_(EN|en)(-.*)?$"))) { log::debug("localization file %s not found", fileName); } // we don't actually expect localization files for English (en, en-us, en-uk, and any variation thereof) diff --git a/src/qt.conf b/src/qt.conf index 6a9d56ae..2b659e87 100644 --- a/src/qt.conf +++ b/src/qt.conf @@ -1,8 +1,8 @@ [Paths] -Prefix=dlls -Libraries=. -LibraryExecutables=. -Plugins=QtPlugins -Imports=QtImports -Qml2Imports=QtImports -Translations=translations \ No newline at end of file +Prefix=. +Libraries=dlls +LibraryExecutables=dlls +Plugins=dlls +Imports=dlls +Qml2Imports=dlls +Translations=resources/translations \ No newline at end of file diff --git a/src/settingsdialoggeneral.cpp b/src/settingsdialoggeneral.cpp index 3d14d521..072764c9 100644 --- a/src/settingsdialoggeneral.cpp +++ b/src/settingsdialoggeneral.cpp @@ -82,7 +82,7 @@ void GeneralSettingsTab::addLanguages() const QRegExp exp(pattern); QDirIterator iter( - QCoreApplication::applicationDirPath() + "/translations", + QCoreApplication::applicationDirPath() + "/resources/translations", QDir::Files); std::vector> languages; -- cgit v1.3.1 From 92f3694acdf3b576d61e454a00c7a40ab877bed9 Mon Sep 17 00:00:00 2001 From: Seth Riley <17361645+Qudix@users.noreply.github.com> Date: Fri, 6 Nov 2020 12:16:37 -0600 Subject: Fixed bad merge --- src/main.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src') diff --git a/src/main.cpp b/src/main.cpp index bfd23103..a905df5d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -708,8 +708,7 @@ int main(int argc, char *argv[]) TimeThis tt("main() to doOneRun()"); - env::prependToPath(QDir::toNativeSeparators( - QCoreApplication::applicationDirPath() + "/dlls")); + SetThisThreadName("main"); initLogging(); auto application = MOApplication::create(argc, argv); -- cgit v1.3.1 From b9bc1a2d56be5efc4478f1487c3e7dfb3529102d Mon Sep 17 00:00:00 2001 From: Qudix <17361645+Qudix@users.noreply.github.com> Date: Mon, 9 Nov 2020 14:10:50 -0600 Subject: Using AppConfig --- src/mainwindow.cpp | 11 ++++++++--- src/settingsdialoggeneral.cpp | 6 +++--- src/shared/appconfig.inc | 3 ++- 3 files changed, 13 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 74885e28..52d97270 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -1204,7 +1204,9 @@ void MainWindow::createHelpMenu() ActionList tutorials; - QDirIterator dirIter(QApplication::applicationDirPath() + "/resources/tutorials", QStringList("*.js"), QDir::Files); + QString tutorialPath = QApplication::applicationDirPath() + + "/" + QString::fromStdWString(AppConfig::tutorialsPath()) + "/"; + QDirIterator dirIter(tutorialPath, QStringList("*.js"), QDir::Files); while (dirIter.hasNext()) { dirIter.next(); QString fileName = dirIter.fileName(); @@ -1316,7 +1318,8 @@ bool MainWindow::addProfile() void MainWindow::hookUpWindowTutorials() { - QDirIterator dirIter(QApplication::applicationDirPath() + "/resources/tutorials", QStringList("*.js"), QDir::Files); + QString tutorialPath = QApplication::applicationDirPath() + "/" + QString::fromStdWString(AppConfig::tutorialsPath()) + "/"; + QDirIterator dirIter(tutorialPath, QStringList("*.js"), QDir::Files); while (dirIter.hasNext()) { dirIter.next(); QString fileName = dirIter.fileName(); @@ -5209,7 +5212,9 @@ void MainWindow::installTranslator(const QString &name) { QTranslator *translator = new QTranslator(this); QString fileName = name + "_" + m_CurrentLanguage; - if (!translator->load(fileName, qApp->applicationDirPath() + "/resources/translations")) { + QString translationsPath = qApp->applicationDirPath() + + "/" + QString::fromStdWString(AppConfig::translationsPath()); + if (!translator->load(fileName, translationsPath)) { if (m_CurrentLanguage.contains(QRegularExpression("^.*_(EN|en)(-.*)?$"))) { log::debug("localization file %s not found", fileName); } // we don't actually expect localization files for English (en, en-us, en-uk, and any variation thereof) diff --git a/src/settingsdialoggeneral.cpp b/src/settingsdialoggeneral.cpp index 87489ab4..9eae2ba1 100644 --- a/src/settingsdialoggeneral.cpp +++ b/src/settingsdialoggeneral.cpp @@ -81,9 +81,9 @@ void GeneralSettingsTab::addLanguages() const QRegExp exp(pattern); - QDirIterator iter( - QCoreApplication::applicationDirPath() + "/resources/translations", - QDir::Files); + QString translationsPath = qApp->applicationDirPath() + + "/" + QString::fromStdWString(AppConfig::translationsPath()); + QDirIterator iter(translationsPath, QDir::Files); std::vector> languages; diff --git a/src/shared/appconfig.inc b/src/shared/appconfig.inc index 5839c2f4..8d4125cf 100644 --- a/src/shared/appconfig.inc +++ b/src/shared/appconfig.inc @@ -6,7 +6,8 @@ APPPARAM(std::wstring, downloadPath, L"downloads") APPPARAM(std::wstring, overwritePath, L"overwrite") APPPARAM(std::wstring, stylesheetsPath, L"stylesheets") APPPARAM(std::wstring, cachePath, L"webcache") -APPPARAM(std::wstring, tutorialsPath, L"tutorials") +APPPARAM(std::wstring, tutorialsPath, L"resources/tutorials") +APPPARAM(std::wstring, translationsPath, L"resources/translations") APPPARAM(std::wstring, logPath, L"logs") APPPARAM(std::wstring, dumpsDir, L"crashDumps") APPPARAM(std::wstring, defaultProfileName, L"Default") -- cgit v1.3.1 From f43b2284dd873761f9d0cd781df7db6f197cbfc9 Mon Sep 17 00:00:00 2001 From: Qudix <17361645+Qudix@users.noreply.github.com> Date: Wed, 11 Nov 2020 20:58:38 -0600 Subject: QtWebEngine does not respect built-in qt.conf --- src/qt.conf | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src') diff --git a/src/qt.conf b/src/qt.conf index 2b659e87..5e070fa3 100644 --- a/src/qt.conf +++ b/src/qt.conf @@ -1,7 +1,6 @@ [Paths] -Prefix=. Libraries=dlls -LibraryExecutables=dlls +LibraryExecutables=resources Plugins=dlls Imports=dlls Qml2Imports=dlls -- cgit v1.3.1 From a0c26517028a25ccd39dc92f9da8539f25db85fc Mon Sep 17 00:00:00 2001 From: isanae <14251494+isanae@users.noreply.github.com> Date: Thu, 12 Nov 2020 00:17:36 -0500 Subject: highlighting plugins from the data directory would crash the mod name is "data" and getByName() crashes with a mod name that doesn't exist --- src/modlist.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/modlist.cpp b/src/modlist.cpp index 04abfb01..d7324e7f 100644 --- a/src/modlist.cpp +++ b/src/modlist.cpp @@ -860,9 +860,11 @@ void ModList::highlightMods(const QItemSelectionModel *selection, const MOShared if (fileEntry.get() != nullptr) { QString originName = QString::fromStdWString(directoryEntry.getOriginByID(fileEntry->getOrigin()).getName()); - - auto modInfo = ModInfo::getByName(originName); - modInfo->setPluginSelected(true); + const auto index = ModInfo::getIndex(originName); + if (index != UINT_MAX) { + auto modInfo = ModInfo::getByIndex(index); + modInfo->setPluginSelected(true); + } } } notifyChange(0, rowCount() - 1); -- cgit v1.3.1 From 6ae27224b0dcc860b882bebff3149828d874c832 Mon Sep 17 00:00:00 2001 From: isanae <14251494+isanae@users.noreply.github.com> Date: Thu, 12 Nov 2020 03:15:14 -0500 Subject: fixed a bunch of instance and command line stuff - clear instance manager overrides when restarting, or switching instances after starting MO with moshortcut://instance: won't do anything - clear overrides when the last selected instance can't be opened; MO would keep trying to open shortcuts even after selecting a different instance - command line was cleared too early, before the first run, so shortcuts were broken - the instance manager dialog can be opened without an instance loaded if the last selected instance doesn't exist, createNew() would throw because it tried to access the global Settings - fixed some problems with parts of MO wanting to restart and others expecting flow to continue - fixed create instance dialog using settings pointer to decide whether to restart; it restarts when it's the first created instance, which is not always the case even if the settings are null, so just check whether there are instances --- src/createinstancedialog.cpp | 10 ++++++---- src/instancemanager.cpp | 6 ++++++ src/instancemanager.h | 5 +++++ src/instancemanagerdialog.cpp | 6 +++++- src/moapplication.cpp | 18 +++++++++++++++--- 5 files changed, 37 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/createinstancedialog.cpp b/src/createinstancedialog.cpp index 47cb9d5c..a4e3c336 100644 --- a/src/createinstancedialog.cpp +++ b/src/createinstancedialog.cpp @@ -131,7 +131,7 @@ CreateInstanceDialog::CreateInstanceDialog( ui->pages->setCurrentIndex(0); ui->launch->setChecked(true); - if (!m_settings) + if (!InstanceManager::singleton().hasAnyInstances()) { // first run of MO, there are no instances yet, force launch ui->launch->setEnabled(false); @@ -314,6 +314,10 @@ void CreateInstanceDialog::finish() }; + // don't restart if this is the first instance, it'll be selected and opened + const bool mustRestart = InstanceManager::singleton().hasAnyInstances(); + + try { std::vector> dirs; @@ -396,9 +400,7 @@ void CreateInstanceDialog::finish() if (ui->launch->isChecked()) { InstanceManager::singleton().setCurrentInstance(ci.instanceName); - if (m_settings) { - // don't restart without settings, it happens on startup when there are - // no instances + if (mustRestart) { ExitModOrganizer(Exit::Restart); m_switching = true; } diff --git a/src/instancemanager.cpp b/src/instancemanager.cpp index 4191f850..2753fc4c 100644 --- a/src/instancemanager.cpp +++ b/src/instancemanager.cpp @@ -538,6 +538,12 @@ void InstanceManager::overrideProfile(const QString& profileName) m_overrideProfileName = profileName; } +void InstanceManager::clearOverrides() +{ + m_overrideInstanceName = {}; + m_overrideProfileName = {}; +} + std::optional InstanceManager::currentInstance() const { const QString profile = m_overrideProfileName ? diff --git a/src/instancemanager.h b/src/instancemanager.h index 4f8b01c7..981aed43 100644 --- a/src/instancemanager.h +++ b/src/instancemanager.h @@ -232,6 +232,11 @@ public: // void overrideProfile(const QString& profileName); + // clears instance and profile overrides, used when restarting MO to select + // another instance + // + void clearOverrides(); + // returns a game plugin that considers the given directory valid // // this will check for an INI file in the directory and use its game name diff --git a/src/instancemanagerdialog.cpp b/src/instancemanagerdialog.cpp index ff76e121..2497d8d8 100644 --- a/src/instancemanagerdialog.cpp +++ b/src/instancemanagerdialog.cpp @@ -580,13 +580,17 @@ void InstanceManagerDialog::onSelection() void InstanceManagerDialog::createNew() { - CreateInstanceDialog dlg(m_pc, &Settings::instance(), this); + // there might not be settings available; the dialog can be shown when the + // last selected instance doesn't exist anymore + CreateInstanceDialog dlg(m_pc, Settings::maybeInstance(), this); + if (dlg.exec() != QDialog::Accepted) { return; } if (dlg.switching()) { // restarting MO + accept(); return; } diff --git a/src/moapplication.cpp b/src/moapplication.cpp index 9139acbb..e7ac3926 100644 --- a/src/moapplication.cpp +++ b/src/moapplication.cpp @@ -170,12 +170,13 @@ int MOApplication::run(MOMultiProcess& multiProcess) { try { - // resets things when MO is "restarted" - resetForRestart(); - tt.stop(); + const auto r = doOneRun(multiProcess); + if (r == RestartExitCode) { + // resets things when MO is "restarted" + resetForRestart(); continue; } @@ -396,6 +397,10 @@ std::optional MOApplication::getCurrentInstance() if (!currentInstance) { + // clear any overrides that might have been given on the command line + m.clearOverrides(); + m_cl.clear(); + currentInstance = selectInstance(); } else @@ -403,6 +408,10 @@ std::optional MOApplication::getCurrentInstance() if (!QDir(currentInstance->directory()).exists()) { // the previously used instance doesn't exist anymore + // clear any overrides that might have been given on the command line + m.clearOverrides(); + m_cl.clear(); + if (m.hasAnyInstances()) { MOShared::criticalOnTop(QObject::tr( "Instance at '%1' not found. Select another instance.") @@ -466,6 +475,9 @@ void MOApplication::resetForRestart() // don't reprocess command line m_cl.clear(); + + // clear instance and profile overrides + InstanceManager::singleton().clearOverrides(); } bool MOApplication::setStyleFile(const QString& styleName) -- cgit v1.3.1 From e99b05f20db989e1d682841c25748227808dfa21 Mon Sep 17 00:00:00 2001 From: Mikaƫl Capelle Date: Fri, 13 Nov 2020 18:27:33 +0100 Subject: Fix order of saves. --- src/mainwindow.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 94bc5800..f7714392 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -1963,7 +1963,7 @@ void MainWindow::refreshSaveList() files.append(it.fileInfo()); } std::sort(files.begin(), files.end(), [](auto const& lhs, auto const& rhs) { - return lhs.fileTime(QFileDevice::FileModificationTime) < rhs.fileTime(QFileDevice::FileModificationTime); + return lhs.fileTime(QFileDevice::FileModificationTime) > rhs.fileTime(QFileDevice::FileModificationTime); }); for (const QFileInfo &file : files) { -- cgit v1.3.1 From 6a6cf8b0e7a468f084d0745d1d0c76a1524039a4 Mon Sep 17 00:00:00 2001 From: isanae <14251494+isanae@users.noreply.github.com> Date: Fri, 13 Nov 2020 23:54:08 -0500 Subject: added Qudix to contributors --- src/aboutdialog.ui | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src') diff --git a/src/aboutdialog.ui b/src/aboutdialog.ui index 88cc96e3..f4cb29d5 100644 --- a/src/aboutdialog.ui +++ b/src/aboutdialog.ui @@ -494,6 +494,11 @@ PurpleFez + + + Qudix + + reedts -- cgit v1.3.1