From 9beea94fd8b195854f748f35f7bde464bdb96c39 Mon Sep 17 00:00:00 2001 From: Eberhard Graether Date: Thu, 4 May 2017 13:49:38 +0200 Subject: [PATCH] src: Removed ApplicationStateMonitor --- src/app/main.cpp | 41 ----------------- src/lib/ApplicationStateMonitor.cpp | 58 ------------------------- src/lib/ApplicationStateMonitor.h | 32 -------------- src/lib/CMakeLists.txt | 2 - src/lib/data/indexer/TaskBuildIndex.cpp | 5 --- 5 files changed, 138 deletions(-) delete mode 100644 src/lib/ApplicationStateMonitor.cpp delete mode 100644 src/lib/ApplicationStateMonitor.h diff --git a/src/app/main.cpp b/src/app/main.cpp index 5e97e77a..2cff9301 100644 --- a/src/app/main.cpp +++ b/src/app/main.cpp @@ -1,5 +1,4 @@ #include "Application.h" -#include "ApplicationStateMonitor.h" #include "data/indexer/IndexerFactory.h" #include "data/indexer/IndexerFactoryModuleJava.h" @@ -250,46 +249,6 @@ int main(int argc, char *argv[]) utility::loadFontsFromDirectory(ResourcePaths::getFontsPath(), ".otf"); utility::loadFontsFromDirectory(ResourcePaths::getFontsPath(), ".ttf"); - const std::vector storedIndexingFiles = ApplicationStateMonitor::getStoredIndexingFiles(); - if (storedIndexingFiles.size() > 0) - { - MessageStatus("The application crashed during last project indexing. Please follow the instructions to help us fix this problem.").dispatch(); - - ApplicationStateMonitor::clearStoredIndexingFiles(); - if (storedIndexingFiles.size() > 1) - { - std::string fileStrings = ""; - for (const FilePath& filePath: storedIndexingFiles) - { - fileStrings += "
  • " + filePath.str() + "
  • "; - } - Application::getInstance()->handleDialog( - "

    It seems that Sourcetrail shut down unexpectedly while indexing your project. We are sorry about that. " - "But let's go on and find out what exactly went wrong. The crash occurred while indexing one of these files:

    " - "" - "

    First of all we need to figure out which of these files caused the crash. Please go ahead and create copy of your project. " - "Remove everything except the files mentioned above from the Project Paths. " - "Set the indexer thread count in the preferences to 1, force-refresh the project and wait for the crash to reoccur.

    " - ); - } - else - { - Application::getInstance()->handleDialog( - "

    It seems that Sourcetrail shut down unexpectedly while indexing your project. We are really sorry about that. " - "At least we know which of your source files caused the crash:

    " - "" - "

    To find out which part of the file caused the crash, please make sure to remove everything except this source file from your Project Paths. " - "Enable the option \"Indexer Logging\" in your preferences (this really slows down indexing performance) and force-refresh the project.

    " - "

    After the expected crash reoccurred please open the respective log file which now contains the portion of the abstract syntax tree that Sourcetrail managed to index, " - "including the node where the crash occurred. We hope that this information helps you figure out what caused the crash and tell us what we can do to reproduce it.

    " - ); - } - } - return qtApp.exec(); } } diff --git a/src/lib/ApplicationStateMonitor.cpp b/src/lib/ApplicationStateMonitor.cpp deleted file mode 100644 index 4867d14c..00000000 --- a/src/lib/ApplicationStateMonitor.cpp +++ /dev/null @@ -1,58 +0,0 @@ -#include "ApplicationStateMonitor.h" - -#include "settings/ApplicationSettings.h" - -std::shared_ptr ApplicationStateMonitor::getInstance() -{ - if (!s_instance) - { - s_instance = std::shared_ptr(new ApplicationStateMonitor()); - } - return s_instance; -} - -std::vector ApplicationStateMonitor::getStoredIndexingFiles() -{ - return ApplicationSettings::getInstance()->getIndexingFilePaths(); -} - -void ApplicationStateMonitor::clearStoredIndexingFiles() -{ - ApplicationSettings::getInstance()->setIndexingFilePaths(std::vector()); - ApplicationSettings::getInstance()->save(); -} - -void ApplicationStateMonitor::clearIndexingFiles() -{ - std::lock_guard lock(m_indexingFilesMutex); - m_indexingFiles.clear(); - storeCurrentState(); -} - -void ApplicationStateMonitor::addIndexingFile(FilePath file) -{ - std::lock_guard lock(m_indexingFilesMutex); - m_indexingFiles.insert(file); - storeCurrentState(); -} - -void ApplicationStateMonitor::removeIndexingFile(FilePath file) -{ - std::lock_guard lock(m_indexingFilesMutex); - m_indexingFiles.erase(file); - storeCurrentState(); -} - -std::shared_ptr ApplicationStateMonitor::s_instance; - -ApplicationStateMonitor::ApplicationStateMonitor() -{ -} - -void ApplicationStateMonitor::storeCurrentState() -{ - std::vector indexingFiles; - indexingFiles.insert(indexingFiles.begin(), m_indexingFiles.begin(), m_indexingFiles.end()); - ApplicationSettings::getInstance()->setIndexingFilePaths(indexingFiles); - ApplicationSettings::getInstance()->save(); -} diff --git a/src/lib/ApplicationStateMonitor.h b/src/lib/ApplicationStateMonitor.h deleted file mode 100644 index 766b9668..00000000 --- a/src/lib/ApplicationStateMonitor.h +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef APPLICATION_STATE_MONITOR_H -#define APPLICATION_STATE_MONITOR_H - -#include -#include -#include -#include - -class FilePath; - -class ApplicationStateMonitor -{ -public: - static std::shared_ptr getInstance(); - static std::vector getStoredIndexingFiles(); - static void clearStoredIndexingFiles(); - - void clearIndexingFiles(); - void addIndexingFile(FilePath file); - void removeIndexingFile(FilePath file); - -private: - static std::shared_ptr s_instance; - ApplicationStateMonitor(); - void storeCurrentState(); - - - std::set m_indexingFiles; - std::mutex m_indexingFilesMutex; -}; - -#endif // APPLICATION_STATE_MONITOR_H diff --git a/src/lib/CMakeLists.txt b/src/lib/CMakeLists.txt index dd48db90..39f3fe4f 100644 --- a/src/lib/CMakeLists.txt +++ b/src/lib/CMakeLists.txt @@ -472,8 +472,6 @@ add_files( Application.cpp Application.h - ApplicationStateMonitor.cpp - ApplicationStateMonitor.h LicenseChecker.cpp LicenseChecker.h ) diff --git a/src/lib/data/indexer/TaskBuildIndex.cpp b/src/lib/data/indexer/TaskBuildIndex.cpp index c5480ee3..c0fc4297 100644 --- a/src/lib/data/indexer/TaskBuildIndex.cpp +++ b/src/lib/data/indexer/TaskBuildIndex.cpp @@ -8,7 +8,6 @@ #include "utility/file/FileRegister.h" #include "utility/file/FileRegisterStateData.h" #include "utility/scheduling/Blackboard.h" -#include "ApplicationStateMonitor.h" #include "Application.h" TaskBuildIndex::TaskBuildIndex( @@ -45,8 +44,6 @@ Task::TaskState TaskBuildIndex::doUpdate(std::shared_ptr blackboard) } else { - ApplicationStateMonitor::getInstance()->addIndexingFile(indexerCommand->getSourceFilePath()); - { std::lock_guard lock(blackboard->getMutex()); @@ -82,8 +79,6 @@ Task::TaskState TaskBuildIndex::doUpdate(std::shared_ptr blackboard) blackboard->get("indexed_source_file_count", indexedSourceFileCount); blackboard->set("indexed_source_file_count", indexedSourceFileCount + 1); } - - ApplicationStateMonitor::getInstance()->removeIndexingFile(indexerCommand->getSourceFilePath()); } return (m_indexer->interrupted() ? STATE_FAILURE : STATE_SUCCESS);