Commit 92401987 authored by loh.tar's avatar loh.tar
Browse files

Avoid QElapsedTimer

parent 5bd9888b
Pipeline #164663 passed with stage
in 5 minutes and 32 seconds
......@@ -128,7 +128,11 @@ KateProjectPluginView::KateProjectPluginView(KateProjectPlugin *plugin, KTextEdi
}
});
m_gitWidgetReloadGuard.start();
m_gitWidgetReloadTrigger.setSingleShot(true);
m_gitWidgetReloadTrigger.setInterval(500);
connect(&m_gitWidgetReloadTrigger, &QTimer::timeout, this, [this] {
slotUpdateStatus(true);
});
/**
* create views for all already existing projects
......@@ -465,19 +469,7 @@ void KateProjectPluginView::slotViewChanged()
void KateProjectPluginView::slotDocumentSaved()
{
if (!m_gitWidgetReloadGuard.hasExpired(500)) {
return;
}
m_gitWidgetReloadGuard.restart();
// We need to wait to be sure all files are saved,
// or the update may to early and we miss something
QTimer::singleShot(500, this, [=] {
if (QWidget *current = m_stackedGitViews->currentWidget()) {
static_cast<GitWidget *>(current)->updateStatus();
}
});
m_gitWidgetReloadTrigger.start();
}
void KateProjectPluginView::slotCurrentChanged(int index)
......
......@@ -9,10 +9,10 @@
#define _KATE_PROJECT_PLUGIN_VIEW_H_
#include <QComboBox>
#include <QElapsedTimer>
#include <QMenu>
#include <QPointer>
#include <QStackedWidget>
#include <QTimer>
#include <QToolButton>
#include <KTextEditor/View>
......@@ -335,7 +335,7 @@ private:
* Helper to avoid multiple reloads at a time
* @see slotDocumentSaved
*/
QElapsedTimer m_gitWidgetReloadGuard;
QTimer m_gitWidgetReloadTrigger;
/**
* our plugin
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment