src: avoid indexing slowdown on macOS by not using unknown progress for progressbar in status bar
This commit is contained in:
@@ -43,7 +43,7 @@ void StatusBarController::handleMessage(MessageIndexingStatus* message)
|
||||
{
|
||||
if (message->showProgress)
|
||||
{
|
||||
getView()->showIndexingProgress(message->unknownProgress, message->progressPercent);
|
||||
getView()->showIndexingProgress(message->progressPercent);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -16,11 +16,6 @@ void DialogView::setDialogsHideable(bool hideable)
|
||||
m_dialogsHideable = hideable;
|
||||
}
|
||||
|
||||
void DialogView::setUpdateIndexingStatus(bool updateStatus)
|
||||
{
|
||||
m_updateIndexingStatus = updateStatus;
|
||||
}
|
||||
|
||||
bool DialogView::dialogsHidden() const
|
||||
{
|
||||
return false;
|
||||
|
||||
@@ -34,7 +34,6 @@ public:
|
||||
UseCase getUseCase() const;
|
||||
|
||||
void setDialogsHideable(bool hideable);
|
||||
void setUpdateIndexingStatus(bool updateStatus);
|
||||
|
||||
virtual bool dialogsHidden() const;
|
||||
virtual void clearDialogs();
|
||||
@@ -64,7 +63,6 @@ protected:
|
||||
StorageAccess* m_storageAccess;
|
||||
|
||||
bool m_dialogsHideable = false;
|
||||
bool m_updateIndexingStatus = false;
|
||||
};
|
||||
|
||||
#endif // DIALOG_VIEW_H
|
||||
|
||||
@@ -19,7 +19,7 @@ public:
|
||||
|
||||
virtual void showIdeStatus(const std::wstring& message) = 0;
|
||||
|
||||
virtual void showIndexingProgress(bool unknownProgress, size_t progressPercent) = 0;
|
||||
virtual void showIndexingProgress(size_t progressPercent) = 0;
|
||||
virtual void hideIndexingProgress() = 0;
|
||||
|
||||
protected:
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include "component/view/DialogView.h"
|
||||
#include "data/storage/PersistentStorage.h"
|
||||
#include "utility/messaging/type/indexing/MessageIndexingFinished.h"
|
||||
#include "utility/messaging/type/indexing/MessageIndexingStatus.h"
|
||||
#include "utility/messaging/type/MessageQuitApplication.h"
|
||||
#include "utility/messaging/type/MessageStatus.h"
|
||||
#include "utility/scheduling/Blackboard.h"
|
||||
@@ -91,6 +92,8 @@ Task::TaskState TaskFinishParsing::doUpdate(std::shared_ptr<Blackboard> blackboa
|
||||
interruptedIndexing
|
||||
);
|
||||
|
||||
MessageIndexingStatus(false).dispatch();
|
||||
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(blackboard->getMutex());
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
#include "utility/AppPath.h"
|
||||
#include "utility/logging/FileLogger.h"
|
||||
#include "utility/messaging/type/indexing/MessageIndexingStatus.h"
|
||||
#include "utility/scheduling/Blackboard.h"
|
||||
#include "utility/UserPaths.h"
|
||||
#include "utility/utilityApp.h"
|
||||
@@ -298,4 +299,11 @@ void TaskBuildIndex::updateIndexingDialog(
|
||||
|
||||
Application::getInstance()->getDialogView(DialogView::UseCase::INDEXING)->updateIndexingDialog(
|
||||
m_indexingFileCount, indexedSourceFileCount, sourceFileCount, sourcePaths);
|
||||
|
||||
int progress = 0;
|
||||
if (sourceFileCount)
|
||||
{
|
||||
progress = indexedSourceFileCount * 100 / sourceFileCount;
|
||||
}
|
||||
MessageIndexingStatus(true, progress).dispatch();
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
#include "component/view/DialogView.h"
|
||||
#include "data/storage/PersistentStorage.h"
|
||||
#include "utility/messaging/type/indexing/MessageIndexingStatus.h"
|
||||
#include "utility/scheduling/Blackboard.h"
|
||||
#include "utility/utility.h"
|
||||
#include "Application.h"
|
||||
@@ -20,6 +21,8 @@ void TaskParseWrapper::doEnter(std::shared_ptr<Blackboard> blackboard)
|
||||
{
|
||||
dialogView->clearDialogs();
|
||||
dialogView->updateIndexingDialog(0, 0, sourceFileCount, { });
|
||||
|
||||
MessageIndexingStatus(true, 0).dispatch();
|
||||
}
|
||||
|
||||
m_start = utility::durationStart();
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include "utility/messaging/type/error/MessageErrorCountClear.h"
|
||||
#include "utility/messaging/type/indexing/MessageIndexingFinished.h"
|
||||
#include "utility/messaging/type/indexing/MessageIndexingStarted.h"
|
||||
#include "utility/messaging/type/indexing/MessageIndexingStatus.h"
|
||||
#include "utility/messaging/type/MessageRefresh.h"
|
||||
#include "utility/messaging/type/MessageStatus.h"
|
||||
#include "utility/scheduling/TaskDecoratorRepeat.h"
|
||||
@@ -398,6 +399,7 @@ void Project::buildIndex(const RefreshInfo& info, std::shared_ptr<DialogView> di
|
||||
MessageErrorCountClear().dispatch();
|
||||
|
||||
dialogView->showUnknownProgressDialog(L"Preparing Indexing", L"Setting up Indexers");
|
||||
MessageIndexingStatus(true, 0).dispatch();
|
||||
|
||||
m_storageCache->clear();
|
||||
m_storageCache->setSubject(m_storage.get());
|
||||
@@ -417,7 +419,6 @@ void Project::buildIndex(const RefreshInfo& info, std::shared_ptr<DialogView> di
|
||||
|
||||
bool hideable = m_state == PROJECT_STATE_LOADED || m_state == PROJECT_STATE_OUTDATED;
|
||||
dialogView->setDialogsHideable(hideable);
|
||||
dialogView->setUpdateIndexingStatus(true);
|
||||
|
||||
if (info.mode != REFRESH_ALL_FILES && (info.filesToClear.size() || info.nonIndexedFilesToClear.size()))
|
||||
{
|
||||
@@ -560,7 +561,6 @@ void Project::buildIndex(const RefreshInfo& info, std::shared_ptr<DialogView> di
|
||||
taskSequential->addTask(std::make_shared<TaskLambda>([dialogView, this]() {
|
||||
m_isIndexing = false;
|
||||
dialogView->setDialogsHideable(false);
|
||||
dialogView->setUpdateIndexingStatus(false);
|
||||
|
||||
MessageIndexingFinished().dispatch();
|
||||
}));
|
||||
|
||||
@@ -12,16 +12,14 @@ public:
|
||||
return "MessageIndexingStatus";
|
||||
}
|
||||
|
||||
MessageIndexingStatus(bool showProgress, bool unknownProgress, size_t progressPercent)
|
||||
MessageIndexingStatus(bool showProgress, size_t progressPercent = 0)
|
||||
: showProgress(showProgress)
|
||||
, unknownProgress(unknownProgress)
|
||||
, progressPercent(progressPercent)
|
||||
{
|
||||
setSendAsTask(false);
|
||||
}
|
||||
|
||||
const bool showProgress;
|
||||
const bool unknownProgress;
|
||||
const size_t progressPercent;
|
||||
};
|
||||
|
||||
|
||||
@@ -84,8 +84,8 @@ QtStatusBar::QtStatusBar()
|
||||
|
||||
m_indexingProgress = new QProgressBar();
|
||||
m_indexingProgress->setMinimum(0);
|
||||
m_indexingProgress->setMaximum(0);
|
||||
m_indexingProgress->setValue(0);
|
||||
m_indexingProgress->setMaximum(100);
|
||||
m_indexingProgress->setValue(100);
|
||||
layout->addWidget(m_indexingProgress);
|
||||
|
||||
m_indexingStatus->setLayout(layout);
|
||||
@@ -155,23 +155,14 @@ void QtStatusBar::setIdeStatus(const std::wstring& text)
|
||||
m_ideStatusText.setText(QString::fromStdWString(text));
|
||||
}
|
||||
|
||||
void QtStatusBar::showIndexingProgress(bool unknownProgress, size_t progressPercent)
|
||||
void QtStatusBar::showIndexingProgress(size_t progressPercent)
|
||||
{
|
||||
m_indexingStatus->show();
|
||||
m_vlineIndexing->show();
|
||||
|
||||
m_errorButton.setEnabled(false);
|
||||
|
||||
if (unknownProgress)
|
||||
{
|
||||
m_indexingProgress->setValue(0);
|
||||
m_indexingProgress->setMaximum(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_indexingProgress->setValue(progressPercent);
|
||||
m_indexingProgress->setMaximum(100);
|
||||
}
|
||||
m_indexingProgress->setValue(progressPercent);
|
||||
}
|
||||
|
||||
void QtStatusBar::hideIndexingProgress()
|
||||
|
||||
@@ -25,7 +25,7 @@ public:
|
||||
|
||||
void setIdeStatus(const std::wstring& text);
|
||||
|
||||
void showIndexingProgress(bool unknownProgress, size_t progressPercent);
|
||||
void showIndexingProgress(size_t progressPercent);
|
||||
void hideIndexingProgress();
|
||||
|
||||
protected:
|
||||
|
||||
@@ -33,13 +33,7 @@ QtDialogView::~QtDialogView()
|
||||
|
||||
bool QtDialogView::dialogsHidden() const
|
||||
{
|
||||
QtIndexingDialog* window = dynamic_cast<QtIndexingDialog*>(m_windowStack.getTopWindow());
|
||||
if (window)
|
||||
{
|
||||
return window->isHidden();
|
||||
}
|
||||
|
||||
return false;
|
||||
return !m_dialogsVisible;
|
||||
}
|
||||
|
||||
void QtDialogView::clearDialogs()
|
||||
@@ -114,11 +108,6 @@ void QtDialogView::showProgressDialog(const std::wstring& title, const std::wstr
|
||||
window->updateMessage(QString::fromStdWString(message));
|
||||
window->updateProgress(progress);
|
||||
|
||||
if (m_updateIndexingStatus)
|
||||
{
|
||||
MessageIndexingStatus(true, false, progress).dispatch();
|
||||
}
|
||||
|
||||
setUIBlocked(m_dialogsVisible);
|
||||
}
|
||||
);
|
||||
@@ -239,9 +228,11 @@ void QtDialogView::updateIndexingDialog(
|
||||
std::vector<std::wstring> stati;
|
||||
for (const FilePath& path : sourcePaths)
|
||||
{
|
||||
stati.push_back(L"[" + std::to_wstring(startedFileCount) + L"/" + std::to_wstring(totalFileCount) + L"] Indexing file: " + path.wstr());
|
||||
stati.push_back(
|
||||
L"[" + std::to_wstring(startedFileCount) + L"/" + std::to_wstring(totalFileCount) +
|
||||
L"] Indexing file: " + path.wstr());
|
||||
}
|
||||
MessageStatus(stati, false, true, m_dialogsVisible).dispatch();
|
||||
MessageStatus(stati, false, false, m_dialogsVisible).dispatch();
|
||||
}
|
||||
|
||||
QtIndexingDialog* window = dynamic_cast<QtIndexingDialog*>(m_windowStack.getTopWindow());
|
||||
@@ -255,21 +246,11 @@ void QtDialogView::updateIndexingDialog(
|
||||
|
||||
if (window && window->getType() == QtIndexingDialog::DIALOG_INDEXING)
|
||||
{
|
||||
window->updateIndexingProgress(finishedFileCount, totalFileCount, sourcePaths.empty() ? FilePath() : sourcePaths.back());
|
||||
window->updateIndexingProgress(
|
||||
finishedFileCount, totalFileCount, sourcePaths.empty() ? FilePath() : sourcePaths.back());
|
||||
}
|
||||
m_mainWindow->setWindowsTaskbarProgress(float(finishedFileCount) / totalFileCount);
|
||||
|
||||
if (m_updateIndexingStatus)
|
||||
{
|
||||
int progress = 0;
|
||||
if (totalFileCount)
|
||||
{
|
||||
progress = finishedFileCount * 100 / totalFileCount;
|
||||
}
|
||||
|
||||
MessageIndexingStatus(true, false, progress).dispatch();
|
||||
}
|
||||
|
||||
setUIBlocked(m_dialogsVisible);
|
||||
}
|
||||
);
|
||||
@@ -279,11 +260,6 @@ DatabasePolicy QtDialogView::finishedIndexingDialog(
|
||||
size_t indexedFileCount, size_t totalIndexedFileCount, size_t completedFileCount, size_t totalFileCount,
|
||||
float time, ErrorCountInfo errorInfo, bool interrupted)
|
||||
{
|
||||
if (m_updateIndexingStatus)
|
||||
{
|
||||
MessageIndexingStatus(false, false, 0).dispatch();
|
||||
}
|
||||
|
||||
DatabasePolicy policy = DATABASE_POLICY_UNKNOWN;
|
||||
m_resultReady = false;
|
||||
|
||||
@@ -441,11 +417,6 @@ void QtDialogView::showUnknownProgress(const std::wstring& title, const std::wst
|
||||
window->updateTitle(QString::fromStdWString(title));
|
||||
window->updateMessage(QString::fromStdWString(message));
|
||||
|
||||
if (m_updateIndexingStatus)
|
||||
{
|
||||
MessageIndexingStatus(true, true, 0).dispatch();
|
||||
}
|
||||
|
||||
setUIBlocked(m_dialogsVisible);
|
||||
}
|
||||
|
||||
|
||||
@@ -57,12 +57,12 @@ void QtStatusBarView::showIdeStatus(const std::wstring& message)
|
||||
);
|
||||
}
|
||||
|
||||
void QtStatusBarView::showIndexingProgress(bool unknownProgress, size_t progressPercent)
|
||||
void QtStatusBarView::showIndexingProgress(size_t progressPercent)
|
||||
{
|
||||
m_onQtThread(
|
||||
[=]()
|
||||
{
|
||||
m_widget->showIndexingProgress(unknownProgress, progressPercent);
|
||||
m_widget->showIndexingProgress(progressPercent);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ public:
|
||||
|
||||
virtual void showIdeStatus(const std::wstring& message);
|
||||
|
||||
virtual void showIndexingProgress(bool unknownProgress, size_t progressPercent);
|
||||
virtual void showIndexingProgress(size_t progressPercent);
|
||||
virtual void hideIndexingProgress();
|
||||
|
||||
private:
|
||||
|
||||
Reference in New Issue
Block a user