forked from qt-creator/qt-creator
Use invokeMethod instead of single shot timer with 0 timeout
Change-Id: I3ffc4bfdbc6fc58d4b90aa53427eb80653c22b65 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -32,7 +32,6 @@
|
||||
|
||||
#include <QDir>
|
||||
#include <QRegularExpression>
|
||||
#include <QTimer>
|
||||
|
||||
using namespace Utils;
|
||||
|
||||
@@ -202,7 +201,8 @@ QList<LocatorFilterEntry> BaseFileFilter::matchesFor(QFutureInterface<LocatorFil
|
||||
d->m_current.clear(); // free memory
|
||||
} else {
|
||||
d->m_current.iterator.clear();
|
||||
QTimer::singleShot(0, this, &BaseFileFilter::updatePreviousResultData);
|
||||
QMetaObject::invokeMethod(this, &BaseFileFilter::updatePreviousResultData,
|
||||
Qt::QueuedConnection);
|
||||
}
|
||||
|
||||
for (auto &entry : entries) {
|
||||
|
@@ -31,7 +31,6 @@
|
||||
#include <utils/stringutils.h>
|
||||
|
||||
#include <QAction>
|
||||
#include <QTimer>
|
||||
|
||||
using namespace Utils;
|
||||
|
||||
@@ -124,10 +123,10 @@ void CommandLocator::accept(LocatorFilterEntry entry,
|
||||
QTC_ASSERT(index >= 0 && index < d->commands.size(), return);
|
||||
QAction *action = d->commands.at(index)->action();
|
||||
// avoid nested stack trace and blocking locator by delayed triggering
|
||||
QTimer::singleShot(0, action, [action] {
|
||||
QMetaObject::invokeMethod(action, [action] {
|
||||
if (action->isEnabled())
|
||||
action->trigger();
|
||||
});
|
||||
}, Qt::QueuedConnection);
|
||||
}
|
||||
|
||||
void CommandLocator::refresh(QFutureInterface<void> &)
|
||||
|
@@ -33,7 +33,6 @@
|
||||
#include <utils/filesearch.h>
|
||||
|
||||
#include <QFileDialog>
|
||||
#include <QTimer>
|
||||
|
||||
using namespace Utils;
|
||||
|
||||
@@ -240,7 +239,8 @@ void DirectoryFilter::refresh(QFutureInterface<void> &future)
|
||||
QMutexLocker locker(&m_lock);
|
||||
if (m_directories.isEmpty()) {
|
||||
m_files.clear();
|
||||
QTimer::singleShot(0, this, &DirectoryFilter::updateFileIterator);
|
||||
QMetaObject::invokeMethod(this, &DirectoryFilter::updateFileIterator,
|
||||
Qt::QueuedConnection);
|
||||
future.setProgressRange(0, 1);
|
||||
future.setProgressValueAndText(1, tr("%1 filter update: 0 files").arg(displayName()));
|
||||
return;
|
||||
@@ -267,7 +267,7 @@ void DirectoryFilter::refresh(QFutureInterface<void> &future)
|
||||
if (!future.isCanceled()) {
|
||||
QMutexLocker locker(&m_lock);
|
||||
m_files = filesFound;
|
||||
QTimer::singleShot(0, this, &DirectoryFilter::updateFileIterator);
|
||||
QMetaObject::invokeMethod(this, &DirectoryFilter::updateFileIterator, Qt::QueuedConnection);
|
||||
future.setProgressValue(subDirIterator.maxProgress());
|
||||
} else {
|
||||
future.setProgressValueAndText(subDirIterator.currentProgress(), tr("%1 filter update: canceled").arg(displayName()));
|
||||
|
@@ -40,7 +40,6 @@
|
||||
#include <QDir>
|
||||
#include <QPushButton>
|
||||
#include <QRegularExpression>
|
||||
#include <QTimer>
|
||||
|
||||
using namespace Core;
|
||||
using namespace Core::Internal;
|
||||
@@ -175,7 +174,7 @@ void FileSystemFilter::accept(LocatorFilterEntry selection,
|
||||
*selectionStart = value.length();
|
||||
} else {
|
||||
// Don't block locator filter execution with dialog
|
||||
QTimer::singleShot(0, EditorManager::instance(), [info, selection] {
|
||||
QMetaObject::invokeMethod(EditorManager::instance(), [info, selection] {
|
||||
const QString targetFile = selection.internalData.toString();
|
||||
if (!info.exists()) {
|
||||
if (Utils::CheckableMessageBox::shouldAskAgain(ICore::settings(), kAlwaysCreate)) {
|
||||
@@ -208,7 +207,7 @@ void FileSystemFilter::accept(LocatorFilterEntry selection,
|
||||
EditorManager::openEditor(cleanedFilePath,
|
||||
Id(),
|
||||
EditorManager::CanContainLineAndColumnNumber);
|
||||
});
|
||||
}, Qt::QueuedConnection);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -361,7 +361,7 @@ bool LocatorPopup::event(QEvent *event)
|
||||
doUpdateGeometry();
|
||||
else if (event->type() == QEvent::LayoutRequest)
|
||||
// completion list resizes after first items are shown --> LayoutRequest
|
||||
QTimer::singleShot(0, this, &LocatorPopup::doUpdateGeometry);
|
||||
QMetaObject::invokeMethod(this, &LocatorPopup::doUpdateGeometry, Qt::QueuedConnection);
|
||||
return QWidget::event(event);
|
||||
}
|
||||
|
||||
@@ -751,12 +751,10 @@ bool LocatorWidget::eventFilter(QObject *obj, QEvent *event)
|
||||
case Qt::Key_Escape:
|
||||
if (!ke->modifiers()) {
|
||||
event->accept();
|
||||
QTimer::singleShot(0,
|
||||
this,
|
||||
[focus = m_previousFocusWidget,
|
||||
isInMainWindow = isInMainWindow()] {
|
||||
resetFocus(focus, isInMainWindow);
|
||||
});
|
||||
QMetaObject::invokeMethod(this, [focus = m_previousFocusWidget,
|
||||
isInMainWindow = isInMainWindow()] {
|
||||
resetFocus(focus, isInMainWindow);
|
||||
}, Qt::QueuedConnection);
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
|
@@ -34,8 +34,6 @@
|
||||
#include <projectexplorer/projectexplorer.h>
|
||||
#include <projectexplorer/session.h>
|
||||
|
||||
#include <QTimer>
|
||||
|
||||
using namespace Core;
|
||||
using namespace ProjectExplorer;
|
||||
using namespace Utils;
|
||||
@@ -168,7 +166,7 @@ void CppIncludesFilter::prepareSearch(const QString &entry)
|
||||
void CppIncludesFilter::refresh(QFutureInterface<void> &future)
|
||||
{
|
||||
Q_UNUSED(future)
|
||||
QTimer::singleShot(0, this, &CppIncludesFilter::markOutdated);
|
||||
QMetaObject::invokeMethod(this, &CppIncludesFilter::markOutdated, Qt::QueuedConnection);
|
||||
}
|
||||
|
||||
void CppIncludesFilter::markOutdated()
|
||||
|
@@ -31,7 +31,6 @@
|
||||
#include <utils/algorithm.h>
|
||||
|
||||
#include <QMutexLocker>
|
||||
#include <QTimer>
|
||||
|
||||
using namespace Core;
|
||||
using namespace ProjectExplorer;
|
||||
@@ -69,5 +68,5 @@ void AllProjectsFilter::prepareSearch(const QString &entry)
|
||||
void AllProjectsFilter::refresh(QFutureInterface<void> &future)
|
||||
{
|
||||
Q_UNUSED(future)
|
||||
QTimer::singleShot(0, this, &AllProjectsFilter::markFilesAsOutOfDate);
|
||||
QMetaObject::invokeMethod(this, &AllProjectsFilter::markFilesAsOutOfDate, Qt::QueuedConnection);
|
||||
}
|
||||
|
@@ -30,7 +30,6 @@
|
||||
#include <utils/algorithm.h>
|
||||
|
||||
#include <QMutexLocker>
|
||||
#include <QTimer>
|
||||
|
||||
using namespace Core;
|
||||
using namespace ProjectExplorer;
|
||||
@@ -84,5 +83,6 @@ void CurrentProjectFilter::currentProjectChanged()
|
||||
void CurrentProjectFilter::refresh(QFutureInterface<void> &future)
|
||||
{
|
||||
Q_UNUSED(future)
|
||||
QTimer::singleShot(0, this, &CurrentProjectFilter::markFilesAsOutOfDate);
|
||||
QMetaObject::invokeMethod(this, &CurrentProjectFilter::markFilesAsOutOfDate,
|
||||
Qt::QueuedConnection);
|
||||
}
|
||||
|
Reference in New Issue
Block a user