| 93 | } |
| 94 | |
| 95 | void ProjectActionsController::newProject() |
| 96 | { |
| 97 | //! NOTE This method is synchronous, |
| 98 | //! but inside `multiInstancesProvider` there can be an event loop |
| 99 | //! to wait for the responses from other instances, accordingly, |
| 100 | //! the events (like user click) can be executed and this method can be called several times, |
| 101 | //! before the end of the current call. |
| 102 | //! So we ignore all subsequent calls until the current one completes. |
| 103 | if (m_isProjectProcessing) { |
| 104 | return; |
| 105 | } |
| 106 | m_isProjectProcessing = true; |
| 107 | |
| 108 | DEFER { |
| 109 | m_isProjectProcessing = false; |
| 110 | }; |
| 111 | |
| 112 | if (globalContext()->currentProject()) { |
| 113 | #ifdef MU_BUILD_MULTIINSTANCE_MODULE |
| 114 | //! Check, if any project is already open in the current window |
| 115 | //! and there is already a created instance without a project, then activate it |
| 116 | if (multiInstancesProvider()->isHasAppInstanceWithoutProject()) { |
| 117 | multiInstancesProvider()->activateWindowWithoutProject(); |
| 118 | return; |
| 119 | } |
| 120 | |
| 121 | //! Otherwise, we will create a new instance |
| 122 | QStringList args; |
| 123 | args << "--session-type" << "start-with-new"; |
| 124 | multiInstancesProvider()->openNewAppInstance(args); |
| 125 | #else |
| 126 | LOGE() << "Has current project, but no multiinstance module, create new unable, need close current"; |
| 127 | #endif |
| 128 | return; |
| 129 | } |
| 130 | |
| 131 | muse::Ret ret = interactive()->open(NEW_PROJECT_URI).ret; |
| 132 | |
| 133 | if (ret) { |
| 134 | ret = openPageIfNeed(PROJECT_PAGE_URI); |
| 135 | } |
| 136 | |
| 137 | if (!ret) { |
| 138 | LOGE() << ret.toString(); |
| 139 | } |
| 140 | } |
| 141 | |
| 142 | void ProjectActionsController::openProject(const muse::actions::ActionData& args) |
| 143 | { |
nothing calls this directly
no test coverage detected