MCPcopy Create free account
hub / github.com/ModOrganizer2/modorganizer / getCurrentInstance

Method getCurrentInstance

src/moapplication.cpp:435–465  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

433}
434
435std::unique_ptr<Instance> MOApplication::getCurrentInstance(bool forceSelect)
436{
437 auto& m = InstanceManager::singleton();
438 auto currentInstance = m.currentInstance();
439
440 if (forceSelect || !currentInstance) {
441 // clear any overrides that might have been given on the command line
442 m.clearOverrides();
443 currentInstance = selectInstance();
444 } else {
445 if (!QDir(currentInstance->directory()).exists()) {
446 // the previously used instance doesn't exist anymore
447
448 // clear any overrides that might have been given on the command line
449 m.clearOverrides();
450
451 if (m.hasAnyInstances()) {
452 reportError(QObject::tr("Instance at '%1' not found. Select another instance.")
453 .arg(currentInstance->directory()));
454 } else {
455 reportError(
456 QObject::tr("Instance at '%1' not found. You must create a new instance")
457 .arg(currentInstance->directory()));
458 }
459
460 currentInstance = selectInstance();
461 }
462 }
463
464 return currentInstance;
465}
466
467std::optional<int> MOApplication::setupInstanceLoop(Instance& currentInstance,
468 PluginContainer& pc)

Callers

nothing calls this directly

Calls 7

selectInstanceFunction · 0.85
QDirClass · 0.85
clearOverridesMethod · 0.80
hasAnyInstancesMethod · 0.80
currentInstanceMethod · 0.45
existsMethod · 0.45
directoryMethod · 0.45

Tested by

no test coverage detected