diff --git a/src/app/main.cpp b/src/app/main.cpp index 161f4ace..78f9e993 100644 --- a/src/app/main.cpp +++ b/src/app/main.cpp @@ -1,5 +1,7 @@ #include "includes.h" // defines 'void setup(int argc, char *argv[])' +#include + #include "Application.h" #include "data/indexer/IndexerFactory.h" #include "data/indexer/IndexerFactoryModuleJava.h" @@ -34,6 +36,12 @@ #include "utility/Version.h" #include "version.h" +void signalHandler(int signum) +{ + std::cout << "interrupt running tasks" << std::endl; + MessageInterruptTasks().dispatch(); +} + void setupLogging() { LogManager* logManager = LogManager::getInstance().get(); @@ -261,6 +269,24 @@ int main(int argc, char *argv[]) { MessageEnteredLicense(checker->getCurrentLicenseType()).dispatch(); } +#ifdef _WIN32 + signal(SIGINT, signalHandler); + signal(SIGTERM, signalHandler); + signal(SIGABRT, signalHandler); +#else + struct sigaction sa; + sa.sa_handler = signalHandler; + sigemptyset(&sa.sa_mask); + sa.sa_flags = SA_RESTART; + if (sigaction(SIGINT, &sa, NULL)) + { + std::cout << "Cant install SIGINT handler" << std::endl; + } + if (sigaction(SIGHUP, &sa, NULL)) + { + std::cout << "Cant install SIGHUP handler" << std::endl; + } +#endif } if (commandLineParser.hasError() ) diff --git a/src/lib/Application.cpp b/src/lib/Application.cpp index 119fbe00..1b0ff2c0 100644 --- a/src/lib/Application.cpp +++ b/src/lib/Application.cpp @@ -277,7 +277,7 @@ void Application::handleMessage(MessageLoadProject* message) if (m_project && projectSettingsFilePath == m_project->getProjectSettingsFilePath()) { - if (message->forceRefresh) + if (message->forceRefresh && m_hasGUI) { m_project->setStateSettingsUpdated(); refreshProject(false); @@ -285,6 +285,15 @@ void Application::handleMessage(MessageLoadProject* message) return; } createAndLoadProject(projectSettingsFilePath); + + if (message->forceRefresh) + { + refreshProject(true); + } + else if (!m_hasGUI) + { + refreshProject(false); + } } void Application::handleMessage(MessageRefresh* message) diff --git a/src/lib/data/TaskFinishParsing.cpp b/src/lib/data/TaskFinishParsing.cpp index 46f3c96a..e48452f2 100644 --- a/src/lib/data/TaskFinishParsing.cpp +++ b/src/lib/data/TaskFinishParsing.cpp @@ -3,7 +3,6 @@ #include "component/view/DialogView.h" #include "data/storage/PersistentStorage.h" #include "utility/messaging/type/MessageFinishedParsing.h" -#include "utility/messaging/type/MessageStatus.h" #include "utility/messaging/type/MessageQuitApplication.h" #include "utility/messaging/type/MessageStatus.h" #include "utility/scheduling/Blackboard.h"