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