diff options
| author | isanae <14251494+isanae@users.noreply.github.com> | 2019-10-05 08:53:31 -0400 |
|---|---|---|
| committer | isanae <14251494+isanae@users.noreply.github.com> | 2019-10-05 08:53:31 -0400 |
| commit | 76df854483c40cb7610d79c5540a5e67f554d840 (patch) | |
| tree | 14670d7ce21598f7570de952ad104b2f3576010a /src | |
| parent | 605b669bed0344fa6539a471a040d3ceeb24771c (diff) | |
only log a warning for symlinks instead of exiting MO
added logs: when dmp files are present, for portable instances, and the ini path
clear the log widget when switching instances
Diffstat (limited to 'src')
| -rw-r--r-- | src/instancemanager.cpp | 7 | ||||
| -rw-r--r-- | src/instancemanager.h | 1 | ||||
| -rw-r--r-- | src/main.cpp | 8 | ||||
| -rw-r--r-- | src/organizercore.cpp | 37 |
4 files changed, 41 insertions, 12 deletions
diff --git a/src/instancemanager.cpp b/src/instancemanager.cpp index c0d343de..ec3c1add 100644 --- a/src/instancemanager.cpp +++ b/src/instancemanager.cpp @@ -263,6 +263,11 @@ QStringList InstanceManager::instances() const } +bool InstanceManager::isPortablePath(const QString& dataPath) +{ + return (dataPath == qApp->applicationDirPath()); +} + bool InstanceManager::portableInstall() const { return QFile::exists(qApp->applicationDirPath() + "/" + @@ -303,7 +308,7 @@ void InstanceManager::createDataPath(const QString &dataPath) const QString InstanceManager::determineDataPath() { QString instanceId = currentInstance(); - if (portableInstallIsLocked()) + if (portableInstallIsLocked()) { instanceId.clear(); } diff --git a/src/instancemanager.h b/src/instancemanager.h index 0e31fb08..649c2195 100644 --- a/src/instancemanager.h +++ b/src/instancemanager.h @@ -39,6 +39,7 @@ public: QString currentInstance() const; bool allowedToChangeInstance() const; + static bool isPortablePath(const QString& dataPath); private: diff --git a/src/main.cpp b/src/main.cpp index fe5fd87a..a6918d99 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -515,6 +515,10 @@ int runApplication(MOApplication &application, SingleInstance &instance, const QString dataPath = application.property("dataPath").toString(); log::info("data path: {}", dataPath); + if (InstanceManager::isPortablePath(dataPath)) { + log::debug("this is a portable instance"); + } + if (!bootstrap()) { reportError("failed to set up data paths"); return 1; @@ -531,6 +535,8 @@ int runApplication(MOApplication &application, SingleInstance &instance, Settings settings(dataPath + "/" + QString::fromStdWString(AppConfig::iniFileName())); log::getDefault().setLevel(settings.diagnostics().logLevel()); + log::debug("using ini at '{}'", settings.filename()); + // global crashDumpType sits in OrganizerCore to make a bit less ugly to // update it when the settings are changed during runtime OrganizerCore::setGlobalCrashDumpsType(settings.diagnostics().crashDumpsType()); @@ -860,6 +866,8 @@ int main(int argc, char *argv[]) } // we continue for the primary instance OR if MO was called with parameters do { + LogModel::instance().clear(); + // make sure the log file isn't locked in case MO was restarted and // the previous instance gets deleted log::getDefault().setFile({}); diff --git a/src/organizercore.cpp b/src/organizercore.cpp index a4a89c99..335910da 100644 --- a/src/organizercore.cpp +++ b/src/organizercore.cpp @@ -443,16 +443,20 @@ bool OrganizerCore::createDirectory(const QString &path) { } bool OrganizerCore::checkPathSymlinks() { - bool hasSymlink = (QFileInfo(m_Settings.paths().profiles()).isSymLink() || + const bool hasSymlink = ( + QFileInfo(m_Settings.paths().profiles()).isSymLink() || QFileInfo(m_Settings.paths().mods()).isSymLink() || QFileInfo(m_Settings.paths().overwrite()).isSymLink()); + if (hasSymlink) { - QMessageBox::critical(nullptr, QObject::tr("Error"), - QObject::tr("One of the configured MO2 directories (profiles, mods, or overwrite) " - "is on a path containing a symbolic (or other) link. This is incompatible " - "with MO2's VFS system.")); + log::warn("{}", QObject::tr( + "One of the configured MO2 directories (profiles, mods, or overwrite) " + "is on a path containing a symbolic (or other) link. This is likely to " + "be incompatible with MO2's virtual filesystem.")); + return false; } + return true; } @@ -498,18 +502,29 @@ void OrganizerCore::setLogLevel(log::Levels level) log::getDefault().setLevel(m_Settings.diagnostics().logLevel()); } -bool OrganizerCore::cycleDiagnostics() { - if (int maxDumps = settings().diagnostics().crashDumpsMax()) - removeOldFiles(QString::fromStdWString(crashDumpsPath()), "*.dmp", maxDumps, QDir::Time|QDir::Reversed); +bool OrganizerCore::cycleDiagnostics() +{ + const auto maxDumps = settings().diagnostics().crashDumpsMax(); + const auto path = QString::fromStdWString(crashDumpsPath()); + + if (maxDumps > 0) { + removeOldFiles(path, "*.dmp", maxDumps, QDir::Time|QDir::Reversed); + } + + // log if there are any files left + const auto files = QDir(path).entryList({"*.dmp"}, QDir::Files); + if (!files.isEmpty()) { + log::debug("there are crash dumps in '{}'", path); + } + return true; } -//static -void OrganizerCore::setGlobalCrashDumpsType(CrashDumpsType type) { +void OrganizerCore::setGlobalCrashDumpsType(CrashDumpsType type) +{ m_globalCrashDumpsType = type; } -//static std::wstring OrganizerCore::crashDumpsPath() { return ( qApp->property("dataPath").toString() + "/" |
