src: fixed crash when indexing in headless mode

This commit is contained in:
mlangkabel
2018-07-23 14:20:16 +02:00
parent c523f1bd8b
commit 637857fb56
7 changed files with 16 additions and 11 deletions
+1 -1
View File
@@ -403,7 +403,7 @@ void Application::refreshProject(RefreshMode refreshMode)
{
if (m_project && checkSharedMemory())
{
m_project->refresh(refreshMode, getDialogView(DialogView::UseCase::INDEXING).get());
m_project->refresh(refreshMode, getDialogView(DialogView::UseCase::INDEXING));
}
}
+2 -1
View File
@@ -47,7 +47,8 @@ void DialogView::hideProgressDialog()
}
void DialogView::startIndexingDialog(
Project* project, const std::vector<RefreshMode>& enabledModes, const RefreshInfo& info)
Project* project, const std::vector<RefreshMode>& enabledModes, const RefreshInfo& info,
std::function<void(const RefreshInfo& info)> onStartIndexing)
{
}
+3 -1
View File
@@ -1,6 +1,7 @@
#ifndef DIALOG_VIEW_H
#define DIALOG_VIEW_H
#include <functional>
#include <string>
#include <vector>
@@ -45,7 +46,8 @@ public:
virtual void hideProgressDialog();
virtual void startIndexingDialog(
Project* project, const std::vector<RefreshMode>& enabledModes, const RefreshInfo& info);
Project* project, const std::vector<RefreshMode>& enabledModes, const RefreshInfo& info,
std::function<void(const RefreshInfo& info)> onStartIndexing);
virtual void updateIndexingDialog(
size_t startedFileCount, size_t finishedFileCount, size_t totalFileCount, const std::vector<FilePath>& sourcePaths);
virtual DatabasePolicy finishedIndexingDialog(
+3 -3
View File
@@ -225,7 +225,7 @@ void Project::load()
}
}
void Project::refresh(RefreshMode refreshMode, DialogView* dialogView)
void Project::refresh(RefreshMode refreshMode, std::shared_ptr<DialogView> dialogView)
{
if (m_isIndexing)
{
@@ -345,7 +345,7 @@ void Project::refresh(RefreshMode refreshMode, DialogView* dialogView)
enabledModes.insert(enabledModes.end(), { REFRESH_UPDATED_FILES, REFRESH_UPDATED_AND_INCOMPLETE_FILES });
}
dialogView->startIndexingDialog(this, enabledModes, info);
dialogView->startIndexingDialog(this, enabledModes, info, [this, dialogView](const RefreshInfo& info) { buildIndex(info, dialogView); });
}
else
{
@@ -371,7 +371,7 @@ RefreshInfo Project::getRefreshInfo(RefreshMode mode) const
}
}
void Project::buildIndex(const RefreshInfo& info, DialogView* dialogView)
void Project::buildIndex(const RefreshInfo& info, std::shared_ptr<DialogView> dialogView)
{
if (m_isIndexing)
{
+2 -2
View File
@@ -37,11 +37,11 @@ public:
void load();
void refresh(RefreshMode refreshMode, DialogView* dialogView);
void refresh(RefreshMode refreshMode, std::shared_ptr<DialogView> dialogView);
RefreshInfo getRefreshInfo(RefreshMode mode) const;
void buildIndex(const RefreshInfo& info, DialogView* dialogView);
void buildIndex(const RefreshInfo& info, std::shared_ptr<DialogView> dialogView);
private:
enum ProjectStateType
+3 -2
View File
@@ -145,7 +145,8 @@ void QtDialogView::hideProgressDialog()
}
void QtDialogView::startIndexingDialog(
Project* project, const std::vector<RefreshMode>& enabledModes, const RefreshInfo& info)
Project* project, const std::vector<RefreshMode>& enabledModes, const RefreshInfo& info,
std::function<void(const RefreshInfo& info)> onStartIndexing)
{
m_refreshInfos.clear();
@@ -206,7 +207,7 @@ void QtDialogView::startIndexingDialog(
Task::dispatch(std::make_shared<TaskLambda>(
[=]()
{
project->buildIndex(info, this);
onStartIndexing(info);
}
));
+2 -1
View File
@@ -40,7 +40,8 @@ public:
void hideProgressDialog() override;
void startIndexingDialog(
Project* project, const std::vector<RefreshMode>& enabledModes, const RefreshInfo& info) override;
Project* project, const std::vector<RefreshMode>& enabledModes, const RefreshInfo& info,
std::function<void(const RefreshInfo& info)> onStartIndexing) override;
void updateIndexingDialog(
size_t startedFileCount, size_t finishedFileCount, size_t totalFileCount, const std::vector<FilePath>& sourcePaths) override;
DatabasePolicy finishedIndexingDialog(