ui: added info screen for indexer crash investigation
* in case Coati crashes while indexing this screen will inform the user of further steps to take in order to find out what happened
This commit is contained in:
@@ -35,7 +35,7 @@ void Application::createInstance(
|
||||
|
||||
s_instance->m_storageCache = std::make_shared<StorageCache>();
|
||||
|
||||
if (viewFactory != nullptr)
|
||||
if (hasGui)
|
||||
{
|
||||
s_instance->m_componentManager = ComponentManager::create(viewFactory, s_instance->m_storageCache.get());
|
||||
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
#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();
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
#ifndef APPLICATION_STATE_MONITOR_H
|
||||
#define APPLICATION_STATE_MONITOR_H
|
||||
|
||||
#include <mutex>
|
||||
#include <set>
|
||||
|
||||
#include "utility/file/FilePath.h"
|
||||
|
||||
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
|
||||
@@ -383,6 +383,8 @@ add_files(
|
||||
|
||||
Application.cpp
|
||||
Application.h
|
||||
ApplicationStateMonitor.cpp
|
||||
ApplicationStateMonitor.h
|
||||
LicenseChecker.cpp
|
||||
LicenseChecker.h
|
||||
Project.cpp
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
#include "data/parser/TaskParse.h"
|
||||
|
||||
#include "component/view/DialogView.h"
|
||||
#include "utility/file/FileRegister.h"
|
||||
#include "utility/scheduling/Blackboard.h"
|
||||
#include "ApplicationStateMonitor.h"
|
||||
|
||||
TaskParse::TaskParse(
|
||||
std::shared_ptr<StorageProvider> storageProvider,
|
||||
@@ -28,6 +31,28 @@ void TaskParse::doEnter(std::shared_ptr<Blackboard> blackboard)
|
||||
}
|
||||
}
|
||||
|
||||
Task::TaskState TaskParse::doUpdate(std::shared_ptr<Blackboard> blackboard)
|
||||
{
|
||||
FilePath sourcePath = m_fileRegister->consumeSourceFile();
|
||||
|
||||
if (sourcePath.empty())
|
||||
{
|
||||
return STATE_FAILURE;
|
||||
}
|
||||
else
|
||||
{
|
||||
ApplicationStateMonitor::getInstance()->addIndexingFile(sourcePath);
|
||||
m_dialogView->updateIndexingDialog(
|
||||
m_fileRegister->getParsedSourceFilesCount(), m_fileRegister->getSourceFilesCount(), sourcePath.str()
|
||||
);
|
||||
|
||||
indexFile(sourcePath);
|
||||
ApplicationStateMonitor::getInstance()->removeIndexingFile(sourcePath);
|
||||
}
|
||||
|
||||
return (m_interrupted ? STATE_FAILURE : STATE_SUCCESS);
|
||||
}
|
||||
|
||||
void TaskParse::doExit(std::shared_ptr<Blackboard> blackboard)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(blackboard->getMutex());
|
||||
|
||||
@@ -25,10 +25,12 @@ public:
|
||||
|
||||
protected:
|
||||
virtual void doEnter(std::shared_ptr<Blackboard> blackboard);
|
||||
virtual TaskState doUpdate(std::shared_ptr<Blackboard> blackboard);
|
||||
virtual void doExit(std::shared_ptr<Blackboard> blackboard);
|
||||
virtual void doReset(std::shared_ptr<Blackboard> blackboard);
|
||||
|
||||
virtual void handleMessage(MessageInterruptTasks* message);
|
||||
virtual void indexFile(FilePath sourcePath) = 0;
|
||||
|
||||
std::shared_ptr<StorageProvider> m_storageProvider;
|
||||
std::shared_ptr<FileRegister> m_fileRegister;
|
||||
|
||||
@@ -175,6 +175,16 @@ void ApplicationSettings::setVerboseIndexerLoggingEnabled(bool value)
|
||||
setValue<bool>("application/verbose_indexer_logging_enabled", value);
|
||||
}
|
||||
|
||||
std::vector<FilePath> ApplicationSettings::getIndexingFilePaths() const
|
||||
{
|
||||
return getPathValues("application/state/indexing_paths/indexing_path");
|
||||
}
|
||||
|
||||
bool ApplicationSettings::setIndexingFilePaths(const std::vector<FilePath>& indexingFiles)
|
||||
{
|
||||
return setPathValues("application/state/indexing_paths/indexing_path", indexingFiles);
|
||||
}
|
||||
|
||||
int ApplicationSettings::getIndexerThreadCount() const
|
||||
{
|
||||
return getValue<int>("indexing/indexer_thread_count", 4);
|
||||
|
||||
@@ -53,6 +53,9 @@ public:
|
||||
bool getVerboseIndexerLoggingEnabled() const;
|
||||
void setVerboseIndexerLoggingEnabled(bool loggingEnabled);
|
||||
|
||||
std::vector<FilePath> getIndexingFilePaths() const;
|
||||
bool setIndexingFilePaths(const std::vector<FilePath>& indexingFiles);
|
||||
|
||||
// indexing
|
||||
int getIndexerThreadCount() const;
|
||||
void setIndexerThreadCount(const int count);
|
||||
|
||||
Reference in New Issue
Block a user