diff options
| author | isanae <14251494+isanae@users.noreply.github.com> | 2020-11-07 17:32:30 -0500 |
|---|---|---|
| committer | isanae <14251494+isanae@users.noreply.github.com> | 2020-11-07 20:16:27 -0500 |
| commit | 079fd33cf18cc901d1a6a4463d8a8ccd1d730786 (patch) | |
| tree | 8e96f5af73389a1001a29ca761d1454d716c23d0 /src | |
| parent | ba7d24faef49858b9721c2ade0f3ea4a7ba4d96d (diff) | |
added sanitychecks.h, moved to namespace sanity
added a set SetThisThreadName() after creating the main window, Qt resets it
Diffstat (limited to 'src')
| -rw-r--r-- | src/main.cpp | 22 | ||||
| -rw-r--r-- | src/moapplication.cpp | 1 | ||||
| -rw-r--r-- | src/sanitychecks.cpp | 10 | ||||
| -rw-r--r-- | src/sanitychecks.h | 27 |
4 files changed, 47 insertions, 13 deletions
diff --git a/src/main.cpp b/src/main.cpp index 55fedc7a..40512006 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -32,6 +32,7 @@ along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>. #include "env.h" #include "envmodule.h" #include "commandline.h" +#include "sanitychecks.h" #include "shared/util.h" #include "shared/appconfig.h" #include "shared/error_report.h" @@ -41,14 +42,9 @@ along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>. #include <log.h> #include <utility.h> - using namespace MOBase; using namespace MOShared; -void sanityChecks(const env::Environment& env); -int checkIncompatibleModule(const env::Module& m); -int checkPathsForSanity(MOBase::IPluginGame& game, const Settings& s); - void purgeOldFiles() { // remove the temporary backup directory in case we're restarting after an @@ -159,11 +155,11 @@ int runApplication( env::Environment env; env.dump(settings); settings.dump(); - sanityChecks(env); + sanity::checkEnvironment(env); const auto moduleNotification = env.onModuleLoaded(qApp, [](auto&& m) { log::debug("loaded module {}", m.toString()); - checkIncompatibleModule(m); + sanity::checkIncompatibleModule(m); }); // this must outlive `organizer` @@ -204,7 +200,7 @@ int runApplication( log::debug("this is a portable instance"); } - checkPathsForSanity(*currentInstance.gamePlugin(), settings); + sanity::checkPaths(*currentInstance.gamePlugin(), settings); organizer.setManagedGame(currentInstance.gamePlugin()); organizer.createDefaultProfile(); @@ -249,10 +245,14 @@ int runApplication( int res = 1; - { // scope to control lifetime of mainwindow + { + // scope to control lifetime of mainwindow // set up main window and its data structures MainWindow mainWindow(settings, organizer, *pluginContainer); + // qt resets the thread name somewhere when creating the main window + MOShared::SetThisThreadName("main"); + ni.getAccessManager()->setTopLevelWidget(&mainWindow); QObject::connect(&mainWindow, SIGNAL(styleChanged(QString)), &application, @@ -373,6 +373,8 @@ int doOneRun( int main(int argc, char *argv[]) { + MOShared::SetThisThreadName("main"); + cl::CommandLine cl; if (auto r=cl.run(GetCommandLineW())) { @@ -381,8 +383,6 @@ int main(int argc, char *argv[]) TimeThis tt("main() to doOneRun()"); - SetThisThreadName("main"); - initLogging(); auto application = MOApplication::create(argc, argv); diff --git a/src/moapplication.cpp b/src/moapplication.cpp index f514050f..43d787f5 100644 --- a/src/moapplication.cpp +++ b/src/moapplication.cpp @@ -20,6 +20,7 @@ along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>. #include "moapplication.h"
#include "settings.h"
#include "env.h"
+#include "shared/util.h"
#include <iplugingame.h>
#include <report.h>
#include <utility.h>
diff --git a/src/sanitychecks.cpp b/src/sanitychecks.cpp index 7afce7bd..613e4b26 100644 --- a/src/sanitychecks.cpp +++ b/src/sanitychecks.cpp @@ -1,3 +1,4 @@ +#include "sanitychecks.h" #include "env.h" #include "envmodule.h" #include "settings.h" @@ -5,6 +6,9 @@ #include <log.h> #include <utility.h> +namespace sanity +{ + using namespace MOBase; enum class SecurityZone @@ -368,7 +372,7 @@ int checkProtected(const QDir& d, const QString& what) return 0; } -int checkPathsForSanity(IPluginGame& game, const Settings& s) +int checkPaths(IPluginGame& game, const Settings& s) { log::debug("checking paths"); @@ -390,7 +394,7 @@ int checkPathsForSanity(IPluginGame& game, const Settings& s) return n; } -void sanityChecks(const env::Environment& e) +void checkEnvironment(const env::Environment& e) { log::debug("running sanity checks..."); @@ -404,3 +408,5 @@ void sanityChecks(const env::Environment& e) "sanity checks done, {}", (n > 0 ? "problems were found" : "everything looks okay")); } + +} // namespace diff --git a/src/sanitychecks.h b/src/sanitychecks.h new file mode 100644 index 00000000..8786ee78 --- /dev/null +++ b/src/sanitychecks.h @@ -0,0 +1,27 @@ +#ifndef MODORGANIZER_SANITYCHECKS_INCLUDED +#define MODORGANIZER_SANITYCHECKS_INCLUDED + +namespace env +{ + class Environment; + class Module; +} + +namespace MOBase +{ + class IPluginGame; +} + +class Settings; + + +namespace sanity +{ + +void checkEnvironment(const env::Environment& env); +int checkIncompatibleModule(const env::Module& m); +int checkPaths(MOBase::IPluginGame& game, const Settings& s); + +} // namespace + +#endif // MODORGANIZER_SANITYCHECKS_INCLUDED |
