src: Removed ApplicationStateMonitor
This commit is contained in:
@@ -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<FilePath> 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 += "<li>" + filePath.str() + "</li>";
|
||||
}
|
||||
Application::getInstance()->handleDialog(
|
||||
"<p>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:</p>"
|
||||
"<ul>" +
|
||||
fileStrings +
|
||||
"</ul>"
|
||||
"<p>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.</p>"
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
Application::getInstance()->handleDialog(
|
||||
"<p>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:</p>"
|
||||
"<ul>"
|
||||
"<li>" + storedIndexingFiles.front().str() + "</li>" +
|
||||
"</ul>"
|
||||
"<p>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.</p>"
|
||||
"<p>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.</p>"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return qtApp.exec();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,58 +0,0 @@
|
||||
#include "ApplicationStateMonitor.h"
|
||||
|
||||
#include "settings/ApplicationSettings.h"
|
||||
|
||||
std::shared_ptr<ApplicationStateMonitor> ApplicationStateMonitor::getInstance()
|
||||
{
|
||||
if (!s_instance)
|
||||
{
|
||||
s_instance = std::shared_ptr<ApplicationStateMonitor>(new ApplicationStateMonitor());
|
||||
}
|
||||
return s_instance;
|
||||
}
|
||||
|
||||
std::vector<FilePath> ApplicationStateMonitor::getStoredIndexingFiles()
|
||||
{
|
||||
return ApplicationSettings::getInstance()->getIndexingFilePaths();
|
||||
}
|
||||
|
||||
void ApplicationStateMonitor::clearStoredIndexingFiles()
|
||||
{
|
||||
ApplicationSettings::getInstance()->setIndexingFilePaths(std::vector<FilePath>());
|
||||
ApplicationSettings::getInstance()->save();
|
||||
}
|
||||
|
||||
void ApplicationStateMonitor::clearIndexingFiles()
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m_indexingFilesMutex);
|
||||
m_indexingFiles.clear();
|
||||
storeCurrentState();
|
||||
}
|
||||
|
||||
void ApplicationStateMonitor::addIndexingFile(FilePath file)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m_indexingFilesMutex);
|
||||
m_indexingFiles.insert(file);
|
||||
storeCurrentState();
|
||||
}
|
||||
|
||||
void ApplicationStateMonitor::removeIndexingFile(FilePath file)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m_indexingFilesMutex);
|
||||
m_indexingFiles.erase(file);
|
||||
storeCurrentState();
|
||||
}
|
||||
|
||||
std::shared_ptr<ApplicationStateMonitor> ApplicationStateMonitor::s_instance;
|
||||
|
||||
ApplicationStateMonitor::ApplicationStateMonitor()
|
||||
{
|
||||
}
|
||||
|
||||
void ApplicationStateMonitor::storeCurrentState()
|
||||
{
|
||||
std::vector<FilePath> indexingFiles;
|
||||
indexingFiles.insert(indexingFiles.begin(), m_indexingFiles.begin(), m_indexingFiles.end());
|
||||
ApplicationSettings::getInstance()->setIndexingFilePaths(indexingFiles);
|
||||
ApplicationSettings::getInstance()->save();
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
#ifndef APPLICATION_STATE_MONITOR_H
|
||||
#define APPLICATION_STATE_MONITOR_H
|
||||
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <set>
|
||||
#include <vector>
|
||||
|
||||
class FilePath;
|
||||
|
||||
class ApplicationStateMonitor
|
||||
{
|
||||
public:
|
||||
static std::shared_ptr<ApplicationStateMonitor> getInstance();
|
||||
static std::vector<FilePath> getStoredIndexingFiles();
|
||||
static void clearStoredIndexingFiles();
|
||||
|
||||
void clearIndexingFiles();
|
||||
void addIndexingFile(FilePath file);
|
||||
void removeIndexingFile(FilePath file);
|
||||
|
||||
private:
|
||||
static std::shared_ptr<ApplicationStateMonitor> s_instance;
|
||||
ApplicationStateMonitor();
|
||||
void storeCurrentState();
|
||||
|
||||
|
||||
std::set<FilePath> m_indexingFiles;
|
||||
std::mutex m_indexingFilesMutex;
|
||||
};
|
||||
|
||||
#endif // APPLICATION_STATE_MONITOR_H
|
||||
@@ -472,8 +472,6 @@ add_files(
|
||||
|
||||
Application.cpp
|
||||
Application.h
|
||||
ApplicationStateMonitor.cpp
|
||||
ApplicationStateMonitor.h
|
||||
LicenseChecker.cpp
|
||||
LicenseChecker.h
|
||||
)
|
||||
|
||||
@@ -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> blackboard)
|
||||
}
|
||||
else
|
||||
{
|
||||
ApplicationStateMonitor::getInstance()->addIndexingFile(indexerCommand->getSourceFilePath());
|
||||
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(blackboard->getMutex());
|
||||
|
||||
@@ -82,8 +79,6 @@ Task::TaskState TaskBuildIndex::doUpdate(std::shared_ptr<Blackboard> 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);
|
||||
|
||||
Reference in New Issue
Block a user