From 637857fb560a97eee3abfb5e4f604c9027f5b030 Mon Sep 17 00:00:00 2001 From: mlangkabel Date: Mon, 23 Jul 2018 14:20:16 +0200 Subject: [PATCH] src: fixed crash when indexing in headless mode --- src/lib/Application.cpp | 2 +- src/lib/component/view/DialogView.cpp | 3 ++- src/lib/component/view/DialogView.h | 4 +++- src/lib/project/Project.cpp | 6 +++--- src/lib/project/Project.h | 4 ++-- src/lib_gui/qt/view/QtDialogView.cpp | 5 +++-- src/lib_gui/qt/view/QtDialogView.h | 3 ++- 7 files changed, 16 insertions(+), 11 deletions(-) diff --git a/src/lib/Application.cpp b/src/lib/Application.cpp index 1b147fa6..68f3408f 100644 --- a/src/lib/Application.cpp +++ b/src/lib/Application.cpp @@ -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)); } } diff --git a/src/lib/component/view/DialogView.cpp b/src/lib/component/view/DialogView.cpp index fbbf0dad..d26d68c2 100644 --- a/src/lib/component/view/DialogView.cpp +++ b/src/lib/component/view/DialogView.cpp @@ -47,7 +47,8 @@ void DialogView::hideProgressDialog() } void DialogView::startIndexingDialog( - Project* project, const std::vector& enabledModes, const RefreshInfo& info) + Project* project, const std::vector& enabledModes, const RefreshInfo& info, + std::function onStartIndexing) { } diff --git a/src/lib/component/view/DialogView.h b/src/lib/component/view/DialogView.h index a8276318..f34b0f6e 100644 --- a/src/lib/component/view/DialogView.h +++ b/src/lib/component/view/DialogView.h @@ -1,6 +1,7 @@ #ifndef DIALOG_VIEW_H #define DIALOG_VIEW_H +#include #include #include @@ -45,7 +46,8 @@ public: virtual void hideProgressDialog(); virtual void startIndexingDialog( - Project* project, const std::vector& enabledModes, const RefreshInfo& info); + Project* project, const std::vector& enabledModes, const RefreshInfo& info, + std::function onStartIndexing); virtual void updateIndexingDialog( size_t startedFileCount, size_t finishedFileCount, size_t totalFileCount, const std::vector& sourcePaths); virtual DatabasePolicy finishedIndexingDialog( diff --git a/src/lib/project/Project.cpp b/src/lib/project/Project.cpp index 9110033c..ad3cd27c 100644 --- a/src/lib/project/Project.cpp +++ b/src/lib/project/Project.cpp @@ -225,7 +225,7 @@ void Project::load() } } -void Project::refresh(RefreshMode refreshMode, DialogView* dialogView) +void Project::refresh(RefreshMode refreshMode, std::shared_ptr 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) { if (m_isIndexing) { diff --git a/src/lib/project/Project.h b/src/lib/project/Project.h index a54b5d07..24514236 100644 --- a/src/lib/project/Project.h +++ b/src/lib/project/Project.h @@ -37,11 +37,11 @@ public: void load(); - void refresh(RefreshMode refreshMode, DialogView* dialogView); + void refresh(RefreshMode refreshMode, std::shared_ptr dialogView); RefreshInfo getRefreshInfo(RefreshMode mode) const; - void buildIndex(const RefreshInfo& info, DialogView* dialogView); + void buildIndex(const RefreshInfo& info, std::shared_ptr dialogView); private: enum ProjectStateType diff --git a/src/lib_gui/qt/view/QtDialogView.cpp b/src/lib_gui/qt/view/QtDialogView.cpp index ed8edf49..097f1964 100644 --- a/src/lib_gui/qt/view/QtDialogView.cpp +++ b/src/lib_gui/qt/view/QtDialogView.cpp @@ -145,7 +145,8 @@ void QtDialogView::hideProgressDialog() } void QtDialogView::startIndexingDialog( - Project* project, const std::vector& enabledModes, const RefreshInfo& info) + Project* project, const std::vector& enabledModes, const RefreshInfo& info, + std::function onStartIndexing) { m_refreshInfos.clear(); @@ -206,7 +207,7 @@ void QtDialogView::startIndexingDialog( Task::dispatch(std::make_shared( [=]() { - project->buildIndex(info, this); + onStartIndexing(info); } )); diff --git a/src/lib_gui/qt/view/QtDialogView.h b/src/lib_gui/qt/view/QtDialogView.h index ab8c18c1..a7b64989 100644 --- a/src/lib_gui/qt/view/QtDialogView.h +++ b/src/lib_gui/qt/view/QtDialogView.h @@ -40,7 +40,8 @@ public: void hideProgressDialog() override; void startIndexingDialog( - Project* project, const std::vector& enabledModes, const RefreshInfo& info) override; + Project* project, const std::vector& enabledModes, const RefreshInfo& info, + std::function onStartIndexing) override; void updateIndexingDialog( size_t startedFileCount, size_t finishedFileCount, size_t totalFileCount, const std::vector& sourcePaths) override; DatabasePolicy finishedIndexingDialog(