| 1534 | } |
| 1535 | |
| 1536 | bool Application::launch(BaseInstance* instance, |
| 1537 | LaunchMode mode, |
| 1538 | MinecraftTarget::Ptr targetToJoin, |
| 1539 | MinecraftAccountPtr accountToUse, |
| 1540 | const QString& offlineName) |
| 1541 | { |
| 1542 | if (m_updateRunning) { |
| 1543 | qDebug() << "Cannot launch instances while an update is running. Please try again when updates are completed."; |
| 1544 | } else if (instance->canLaunch()) { |
| 1545 | QMutexLocker locker(&m_instanceExtrasMutex); |
| 1546 | auto& extras = m_instanceExtras[instance->id()]; |
| 1547 | auto window = extras.window; |
| 1548 | if (window) { |
| 1549 | if (!window->saveAll()) { |
| 1550 | return false; |
| 1551 | } |
| 1552 | } |
| 1553 | auto& controller = extras.controller; |
| 1554 | controller.reset(new LaunchController()); |
| 1555 | controller->setInstance(instance); |
| 1556 | controller->setLaunchMode(mode); |
| 1557 | controller->setProfiler(profilers().value(instance->settings()->get("Profiler").toString(), nullptr).get()); |
| 1558 | controller->setTargetToJoin(targetToJoin); |
| 1559 | controller->setAccountToUse(accountToUse); |
| 1560 | controller->setOfflineName(offlineName); |
| 1561 | if (window) { |
| 1562 | controller->setParentWidget(window); |
| 1563 | } else if (m_mainWindow) { |
| 1564 | controller->setParentWidget(m_mainWindow); |
| 1565 | } |
| 1566 | connect(controller.get(), &LaunchController::finished, this, &Application::controllerFinished); |
| 1567 | addRunningInstance(); |
| 1568 | QMetaObject::invokeMethod(controller.get(), &Task::start, Qt::QueuedConnection); |
| 1569 | return true; |
| 1570 | } else if (instance->isRunning()) { |
| 1571 | showInstanceWindow(instance, "console"); |
| 1572 | return true; |
| 1573 | } else if (instance->canEdit()) { |
| 1574 | showInstanceWindow(instance); |
| 1575 | return true; |
| 1576 | } |
| 1577 | return false; |
| 1578 | } |
| 1579 | |
| 1580 | bool Application::kill(BaseInstance* instance) |
| 1581 | { |
nothing calls this directly
no test coverage detected