logic: Fixed and improved indexing interruption (issue #634)
* Fixed indexing can be interrupted when dialog hidden * Clear intermediate storages when interrupting * Abort waiting for less queued storages when indexing interrupted * Don't index another file when indexing was already interrupted * Moved indexing interrupted progress dialog to TaskBuildIndex * Use MessageIndexingInterrupted instead of MessageInterruptTasks
This commit is contained in:
+3
-3
@@ -21,7 +21,7 @@
|
||||
#include "FileLogger.h"
|
||||
#include "logging.h"
|
||||
#include "LogManager.h"
|
||||
#include "MessageInterruptTasks.h"
|
||||
#include "MessageIndexingInterrupted.h"
|
||||
#include "MessageLoadProject.h"
|
||||
#include "MessageStatus.h"
|
||||
#include "ResourcePaths.h"
|
||||
@@ -37,8 +37,8 @@
|
||||
|
||||
void signalHandler(int signum)
|
||||
{
|
||||
std::cout << "interrupt running tasks" << std::endl;
|
||||
MessageInterruptTasks().dispatch();
|
||||
std::cout << "interrupt indexing" << std::endl;
|
||||
MessageIndexingInterrupted().dispatch();
|
||||
}
|
||||
|
||||
void setupLogging()
|
||||
|
||||
@@ -455,6 +455,7 @@ add_files(
|
||||
utility/messaging/type/history/MessageHistoryUndo.h
|
||||
|
||||
utility/messaging/type/indexing/MessageIndexingFinished.h
|
||||
utility/messaging/type/indexing/MessageIndexingInterrupted.h
|
||||
utility/messaging/type/indexing/MessageIndexingShowDialog.h
|
||||
utility/messaging/type/indexing/MessageIndexingStarted.h
|
||||
utility/messaging/type/indexing/MessageIndexingStatus.h
|
||||
@@ -494,7 +495,6 @@ add_files(
|
||||
utility/messaging/type/MessageGraphNodeHide.h
|
||||
utility/messaging/type/MessageGraphNodeMove.h
|
||||
utility/messaging/type/MessageIDECreateCDB.h
|
||||
utility/messaging/type/MessageInterruptTasks.h
|
||||
utility/messaging/type/MessageLoadProject.h
|
||||
utility/messaging/type/MessageLogFilterChanged.h
|
||||
utility/messaging/type/MessageMoveIDECursor.h
|
||||
|
||||
@@ -41,3 +41,8 @@ void TaskInjectStorage::doExit(std::shared_ptr<Blackboard> blackboard)
|
||||
void TaskInjectStorage::doReset(std::shared_ptr<Blackboard> blackboard)
|
||||
{
|
||||
}
|
||||
|
||||
void TaskInjectStorage::handleMessage(MessageIndexingInterrupted* message)
|
||||
{
|
||||
m_storageProvider->clear();
|
||||
}
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "MessageIndexingInterrupted.h"
|
||||
#include "MessageListener.h"
|
||||
#include "Task.h"
|
||||
|
||||
class Storage;
|
||||
@@ -10,6 +12,7 @@ class StorageProvider;
|
||||
|
||||
class TaskInjectStorage
|
||||
: public Task
|
||||
, public MessageListener<MessageIndexingInterrupted>
|
||||
{
|
||||
public:
|
||||
TaskInjectStorage(
|
||||
@@ -23,6 +26,8 @@ private:
|
||||
void doExit(std::shared_ptr<Blackboard> blackboard) override;
|
||||
void doReset(std::shared_ptr<Blackboard> blackboard) override;
|
||||
|
||||
void handleMessage(MessageIndexingInterrupted* message) override;
|
||||
|
||||
std::shared_ptr<StorageProvider> m_storageProvider;
|
||||
std::weak_ptr<Storage> m_target;
|
||||
};
|
||||
|
||||
@@ -125,7 +125,10 @@ void TaskBuildIndex::doExit(std::shared_ptr<Blackboard> blackboard)
|
||||
}
|
||||
m_processThreads.clear();
|
||||
|
||||
while (fetchIntermediateStorages(blackboard));
|
||||
if (!m_interrupted)
|
||||
{
|
||||
while (fetchIntermediateStorages(blackboard));
|
||||
}
|
||||
|
||||
std::vector<FilePath> crashedFiles = m_interprocessIndexingStatusManager.getCrashedSourceFilePaths();
|
||||
if (crashedFiles.size())
|
||||
@@ -156,14 +159,14 @@ void TaskBuildIndex::terminate()
|
||||
utility::killRunningProcesses();
|
||||
}
|
||||
|
||||
void TaskBuildIndex::handleMessage(MessageInterruptTasks* message)
|
||||
void TaskBuildIndex::handleMessage(MessageIndexingInterrupted* message)
|
||||
{
|
||||
if (!m_dialogView->dialogsHidden())
|
||||
{
|
||||
LOG_INFO("sending indexer interrupt command.");
|
||||
m_interprocessIndexingStatusManager.setIndexingInterrupted(true);
|
||||
m_interrupted = true;
|
||||
}
|
||||
LOG_INFO("sending indexer interrupt command.");
|
||||
|
||||
m_interprocessIndexingStatusManager.setIndexingInterrupted(true);
|
||||
m_interrupted = true;
|
||||
|
||||
m_dialogView->showUnknownProgressDialog(L"Interrupting Indexing", L"Waiting for indexer\nthreads to finish");
|
||||
}
|
||||
|
||||
void TaskBuildIndex::runIndexerProcess(int processId, const std::wstring& logFilePath)
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include <thread>
|
||||
|
||||
#include "MessageListener.h"
|
||||
#include "MessageInterruptTasks.h"
|
||||
#include "MessageIndexingInterrupted.h"
|
||||
#include "Task.h"
|
||||
|
||||
#include "InterprocessIndexerCommandManager.h"
|
||||
@@ -17,7 +17,7 @@ class IndexerCommandList;
|
||||
|
||||
class TaskBuildIndex
|
||||
: public Task
|
||||
, public MessageListener<MessageInterruptTasks>
|
||||
, public MessageListener<MessageIndexingInterrupted>
|
||||
{
|
||||
public:
|
||||
TaskBuildIndex(
|
||||
@@ -35,7 +35,7 @@ protected:
|
||||
void doReset(std::shared_ptr<Blackboard> blackboard) override;
|
||||
void terminate() override;
|
||||
|
||||
void handleMessage(MessageInterruptTasks* message) override;
|
||||
void handleMessage(MessageIndexingInterrupted* message) override;
|
||||
|
||||
void runIndexerProcess(int processId, const std::wstring& logFilePath);
|
||||
void runIndexerThread(int processId);
|
||||
|
||||
@@ -106,7 +106,7 @@ void TaskFillIndexerCommandsQueue::terminate()
|
||||
m_interrupted = true;
|
||||
}
|
||||
|
||||
void TaskFillIndexerCommandsQueue::handleMessage(MessageInterruptTasks* message)
|
||||
void TaskFillIndexerCommandsQueue::handleMessage(MessageIndexingInterrupted* message)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m_commandsMutex);
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include <queue>
|
||||
|
||||
#include "MessageListener.h"
|
||||
#include "MessageInterruptTasks.h"
|
||||
#include "MessageIndexingInterrupted.h"
|
||||
#include "Task.h"
|
||||
|
||||
#include "InterprocessIndexerCommandManager.h"
|
||||
@@ -13,7 +13,7 @@ class IndexerCommandProvider;
|
||||
|
||||
class TaskFillIndexerCommandsQueue
|
||||
: public Task
|
||||
, public MessageListener<MessageInterruptTasks>
|
||||
, public MessageListener<MessageIndexingInterrupted>
|
||||
{
|
||||
public:
|
||||
TaskFillIndexerCommandsQueue(
|
||||
@@ -29,7 +29,7 @@ protected:
|
||||
void doReset(std::shared_ptr<Blackboard> blackboard) override;
|
||||
void terminate() override;
|
||||
|
||||
void handleMessage(MessageInterruptTasks* message) override;
|
||||
void handleMessage(MessageIndexingInterrupted* message) override;
|
||||
|
||||
bool fillCommandQueue();
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ void InterprocessIndexer::work()
|
||||
LOG_INFO(std::to_wstring(m_processId) + L" fetched indexer command for \"" + indexerCommand->getSourceFilePath().wstr() + L"\"");
|
||||
LOG_INFO(std::to_wstring(m_processId) + L" indexer commands left: " + std::to_wstring(m_interprocessIndexerCommandManager.indexerCommandCount() + 1));
|
||||
|
||||
while (true)
|
||||
while (updaterThreadRunning)
|
||||
{
|
||||
const size_t storageCount = m_interprocessIntermediateStorageManager.getIntermediateStorageCount();
|
||||
if (storageCount < 2)
|
||||
@@ -73,6 +73,11 @@ void InterprocessIndexer::work()
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(200));
|
||||
}
|
||||
|
||||
if (!updaterThreadRunning)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
LOG_INFO_STREAM(<< m_processId << " updating indexer status with currently indexed filepath");
|
||||
m_interprocessIndexingStatusManager.startIndexingSourceFile(indexerCommand->getSourceFilePath());
|
||||
|
||||
|
||||
@@ -8,6 +8,12 @@ int StorageProvider::getStorageCount() const
|
||||
return m_storages.size();
|
||||
}
|
||||
|
||||
void StorageProvider::clear()
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m_storagesMutex);
|
||||
return m_storages.clear();
|
||||
}
|
||||
|
||||
void StorageProvider::insert(std::shared_ptr<IntermediateStorage> storage)
|
||||
{
|
||||
const std::size_t storageSize = storage->getSourceLocationCount();
|
||||
|
||||
@@ -11,6 +11,8 @@ class StorageProvider
|
||||
public:
|
||||
int getStorageCount() const;
|
||||
|
||||
void clear();
|
||||
|
||||
void insert(std::shared_ptr<IntermediateStorage> storage);
|
||||
|
||||
// returns empty shared_ptr if no storages available
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
#ifndef MESSAGE_INTERRUPT_TASKS_H
|
||||
#define MESSAGE_INTERRUPT_TASKS_H
|
||||
|
||||
#include "Message.h"
|
||||
|
||||
class MessageInterruptTasks:
|
||||
public Message<MessageInterruptTasks>
|
||||
{
|
||||
public:
|
||||
MessageInterruptTasks()
|
||||
{
|
||||
setSendAsTask(false);
|
||||
}
|
||||
|
||||
static const std::string getStaticType()
|
||||
{
|
||||
return "MessageInterruptTasks";
|
||||
}
|
||||
};
|
||||
|
||||
#endif // MESSAGE_INTERRUPT_TASKS_H
|
||||
@@ -0,0 +1,16 @@
|
||||
#ifndef MESSAGE_INDEXING_INTERRUPTED_H
|
||||
#define MESSAGE_INDEXING_INTERRUPTED_H
|
||||
|
||||
#include "Message.h"
|
||||
|
||||
class MessageIndexingInterrupted
|
||||
: public Message<MessageIndexingInterrupted>
|
||||
{
|
||||
public:
|
||||
static const std::string getStaticType()
|
||||
{
|
||||
return "MessageIndexingInterrupted";
|
||||
}
|
||||
};
|
||||
|
||||
#endif // MESSAGE_INDEXING_INTERRUPTED_H
|
||||
@@ -497,25 +497,6 @@ void QtDialogView::handleMessage(MessageIndexingShowDialog* message)
|
||||
);
|
||||
}
|
||||
|
||||
void QtDialogView::handleMessage(MessageInterruptTasks* message)
|
||||
{
|
||||
if (!m_dialogsVisible)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
m_onQtThread3(
|
||||
[=]()
|
||||
{
|
||||
QtIndexingDialog* window = dynamic_cast<QtIndexingDialog*>(m_windowStack.getTopWindow());
|
||||
if (window && window->getType() == QtIndexingDialog::DIALOG_INDEXING)
|
||||
{
|
||||
showUnknownProgressDialog(L"Interrupting Indexing", L"Waiting for indexer\nthreads to finish");
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
void QtDialogView::handleMessage(MessageErrorCountUpdate* message)
|
||||
{
|
||||
ErrorCountInfo errorInfo = message->errorCount;
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
#include "MessageListener.h"
|
||||
#include "MessageErrorCountUpdate.h"
|
||||
#include "MessageIndexingShowDialog.h"
|
||||
#include "MessageInterruptTasks.h"
|
||||
#include "MessageWindowClosed.h"
|
||||
|
||||
class QtIndexingDialog;
|
||||
@@ -21,7 +20,6 @@ class QtDialogView
|
||||
, public DialogView
|
||||
, public MessageListener<MessageErrorCountUpdate>
|
||||
, public MessageListener<MessageIndexingShowDialog>
|
||||
, public MessageListener<MessageInterruptTasks>
|
||||
, public MessageListener<MessageWindowClosed>
|
||||
{
|
||||
Q_OBJECT
|
||||
@@ -63,7 +61,6 @@ private slots:
|
||||
private:
|
||||
void handleMessage(MessageErrorCountUpdate* message) override;
|
||||
void handleMessage(MessageIndexingShowDialog* message) override;
|
||||
void handleMessage(MessageInterruptTasks* message) override;
|
||||
void handleMessage(MessageWindowClosed* message) override;
|
||||
|
||||
void updateErrorCount(size_t errorCount, size_t fatalCount);
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include "QtHelpButton.h"
|
||||
#include "QtProgressBar.h"
|
||||
#include "MessageErrorsHelpMessage.h"
|
||||
#include "MessageInterruptTasks.h"
|
||||
#include "MessageIndexingInterrupted.h"
|
||||
#include "ResourcePaths.h"
|
||||
#include "utility.h"
|
||||
|
||||
@@ -404,7 +404,10 @@ void QtIndexingDialog::handleClose()
|
||||
{
|
||||
if (m_type == DIALOG_INDEXING)
|
||||
{
|
||||
MessageInterruptTasks().dispatch();
|
||||
if (isVisible())
|
||||
{
|
||||
MessageIndexingInterrupted().dispatch();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -41,7 +41,6 @@
|
||||
#include "MessageEnteredLicense.h"
|
||||
#include "MessageFind.h"
|
||||
#include "MessageIndexingShowDialog.h"
|
||||
#include "MessageInterruptTasks.h"
|
||||
#include "MessageLoadProject.h"
|
||||
#include "MessageRefresh.h"
|
||||
#include "MessageRefreshUI.h"
|
||||
@@ -493,7 +492,6 @@ void QtMainWindow::keyPressEvent(QKeyEvent* event)
|
||||
break;
|
||||
|
||||
case Qt::Key_Escape:
|
||||
MessageInterruptTasks().dispatch();
|
||||
emit hideScreenSearch();
|
||||
break;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user