diff --git a/src/lib/data/TaskFinishParsing.cpp b/src/lib/data/TaskFinishParsing.cpp index 111fa440..009bb138 100644 --- a/src/lib/data/TaskFinishParsing.cpp +++ b/src/lib/data/TaskFinishParsing.cpp @@ -31,13 +31,22 @@ Task::TaskState TaskFinishParsing::doUpdate(std::shared_ptr blackboa { TimePoint start = utility::durationStart(); - m_dialogView->showStatusDialog("Finish Indexing", "Optimizing database"); + if (m_dialogView) + { + m_dialogView->showStatusDialog("Finish Indexing", "Optimizing database"); + } m_storage->optimizeMemory(); - m_dialogView->showStatusDialog("Finish Indexing", "Building caches"); + if (m_dialogView) + { + m_dialogView->showStatusDialog("Finish Indexing", "Building caches"); + } m_storage->buildCaches(); - m_dialogView->hideStatusDialog(); + if (m_dialogView) + { + m_dialogView->hideStatusDialog(); + } MessageFinishedParsing().dispatch(); float time = utility::duration(start); @@ -62,12 +71,15 @@ Task::TaskState TaskFinishParsing::doUpdate(std::shared_ptr blackboa int sourceFileCount = 0; blackboard->get("source_file_count", sourceFileCount); - m_dialogView->finishedIndexingDialog( - indexedSourceFileCount, - sourceFileCount, - time, - m_storageAccess->getErrorCount() - ); + if (m_dialogView) + { + m_dialogView->finishedIndexingDialog( + indexedSourceFileCount, + sourceFileCount, + time, + m_storageAccess->getErrorCount() + ); + } return STATE_SUCCESS; } diff --git a/src/lib/data/TaskShowStatusDialog.cpp b/src/lib/data/TaskShowStatusDialog.cpp index 959182ed..d29baf9d 100644 --- a/src/lib/data/TaskShowStatusDialog.cpp +++ b/src/lib/data/TaskShowStatusDialog.cpp @@ -23,7 +23,10 @@ void TaskShowStatusDialog::doEnter(std::shared_ptr blackboard) Task::TaskState TaskShowStatusDialog::doUpdate(std::shared_ptr blackboard) { - m_dialogView->showStatusDialog(m_title, m_message); + if (m_dialogView) + { + m_dialogView->showStatusDialog(m_title, m_message); + } return STATE_SUCCESS; } diff --git a/src/lib/data/indexer/TaskBuildIndex.cpp b/src/lib/data/indexer/TaskBuildIndex.cpp index e97e18f9..7db0b82c 100644 --- a/src/lib/data/indexer/TaskBuildIndex.cpp +++ b/src/lib/data/indexer/TaskBuildIndex.cpp @@ -57,9 +57,12 @@ Task::TaskState TaskBuildIndex::doUpdate(std::shared_ptr blackboard) int indexedSourceFileCount = 0; blackboard->get("indexed_source_file_count", indexedSourceFileCount); - m_dialogView->updateIndexingDialog( - indexedSourceFileCount, sourceFileCount, indexerCommand->getSourceFilePath().str() - ); + if (m_dialogView) + { + m_dialogView->updateIndexingDialog( + indexedSourceFileCount, sourceFileCount, indexerCommand->getSourceFilePath().str() + ); + } } // file register only copies the DileRegisterStateData diff --git a/src/lib/data/parser/TaskParseWrapper.cpp b/src/lib/data/parser/TaskParseWrapper.cpp index b6ff302f..4dc96fd7 100644 --- a/src/lib/data/parser/TaskParseWrapper.cpp +++ b/src/lib/data/parser/TaskParseWrapper.cpp @@ -30,7 +30,10 @@ void TaskParseWrapper::doEnter(std::shared_ptr blackboard) { int sourceFileCount = 0; blackboard->get("source_file_count", sourceFileCount); - m_dialogView->updateIndexingDialog(0, sourceFileCount, ""); + if (m_dialogView) + { + m_dialogView->updateIndexingDialog(0, sourceFileCount, ""); + } m_start = utility::durationStart(); diff --git a/src/lib_java/JavaProject.cpp b/src/lib_java/JavaProject.cpp index 3da96312..e897716a 100644 --- a/src/lib_java/JavaProject.cpp +++ b/src/lib_java/JavaProject.cpp @@ -92,28 +92,31 @@ bool JavaProject::prepareIndexing() const FilePath mavenPath = ApplicationSettings::getInstance()->getMavenPath(); const FilePath projectRootPath = m_projectSettings->getAbsoluteMavenProjectFilePath().parentDirectory(); - ScopedFunctor dialogHider([this](){ - getDialogView()->hideStatusDialog(); - }); - - getDialogView()->showStatusDialog("Preparing Project", "Maven\nGenerating Source Files"); - bool success = utility::mavenGenerateSources( - mavenPath, projectRootPath - ); - - if (!success) + if (Application::getInstance()->hasGUI()) { - const std::string dialogMessage = - "Coati was unable to locate Maven on this machine.\n" - "Please make sure to provide the correct Maven Path in the preferences."; + ScopedFunctor dialogHider([this](){ + getDialogView()->hideStatusDialog(); + }); - MessageStatus(dialogMessage, true, false).dispatch(); + getDialogView()->showStatusDialog("Preparing Project", "Maven\nGenerating Source Files"); + bool success = utility::mavenGenerateSources( + mavenPath, projectRootPath + ); - Application::getInstance()->handleDialog(dialogMessage); - return false; + if (!success) + { + const std::string dialogMessage = + "Coati was unable to locate Maven on this machine.\n" + "Please make sure to provide the correct Maven Path in the preferences."; + + MessageStatus(dialogMessage, true, false).dispatch(); + + Application::getInstance()->handleDialog(dialogMessage); + return false; + } + + getDialogView()->showStatusDialog("Preparing Project", "Maven\nExporting Dependencies"); } - - getDialogView()->showStatusDialog("Preparing Project", "Maven\nExporting Dependencies"); utility::mavenCopyDependencies( mavenPath, projectRootPath, m_projectSettings->getAbsoluteMavenDependenciesDirectory() ); @@ -148,9 +151,15 @@ std::vector> JavaProject::getIndexerCommands() if (!m_rootDirectories) { - getDialogView()->showStatusDialog("Preparing Project", "Gathering Root\nDirectories"); + if (Application::getInstance()->hasGUI()) + { + getDialogView()->showStatusDialog("Preparing Project", "Gathering Root\nDirectories"); + } fetchRootDirectories(); - getDialogView()->hideStatusDialog(); + if (Application::getInstance()->hasGUI()) + { + getDialogView()->hideStatusDialog(); + } } for (FilePath rootDirectory: *(m_rootDirectories.get())) @@ -193,13 +202,21 @@ void JavaProject::updateFileManager(FileManager& fileManager) std::vector sourcePaths; if (m_projectSettings->getAbsoluteMavenProjectFilePath().exists()) { - getDialogView()->showStatusDialog("Preparing Project", "Maven\nFetching Source Directories"); + + if (Application::getInstance()->hasGUI()) + { + getDialogView()->showStatusDialog("Preparing Project", "Maven\nFetching Source Directories"); + } const FilePath mavenPath(ApplicationSettings::getInstance()->getMavenPath()); const FilePath projectRootPath = m_projectSettings->getAbsoluteMavenProjectFilePath().parentDirectory(); sourcePaths = utility::mavenGetAllDirectoriesFromEffectivePom(mavenPath, projectRootPath, m_projectSettings->getShouldIndexMavenTests()); - getDialogView()->hideStatusDialog(); + + if (Application::getInstance()->hasGUI()) + { + getDialogView()->hideStatusDialog(); + } } else {