diff --git a/src/plugins/coreplugin/actionmanager/actioncontainer.cpp b/src/plugins/coreplugin/actionmanager/actioncontainer.cpp index f902b1b1cbc..c9946dddd98 100644 --- a/src/plugins/coreplugin/actionmanager/actioncontainer.cpp +++ b/src/plugins/coreplugin/actionmanager/actioncontainer.cpp @@ -408,7 +408,7 @@ void ActionContainerPrivate::scheduleUpdate() if (m_updateRequested) return; m_updateRequested = true; - QTimer::singleShot(0, this, &ActionContainerPrivate::update); + QMetaObject::invokeMethod(this, &ActionContainerPrivate::update, Qt::QueuedConnection); } void ActionContainerPrivate::update() diff --git a/src/plugins/coreplugin/dialogs/newdialog.cpp b/src/plugins/coreplugin/dialogs/newdialog.cpp index 73a4e41ebe0..b09ddf67de5 100644 --- a/src/plugins/coreplugin/dialogs/newdialog.cpp +++ b/src/plugins/coreplugin/dialogs/newdialog.cpp @@ -41,7 +41,6 @@ #include #include #include -#include Q_DECLARE_METATYPE(Core::IWizardFactory*) @@ -502,8 +501,8 @@ void NewDialog::accept() if (m_ui->templatesView->currentIndex().isValid()) { IWizardFactory *wizard = currentWizardFactory(); if (QTC_GUARD(wizard)) { - QTimer::singleShot(0, std::bind(&runWizard, wizard, m_defaultLocation, - selectedPlatform(), m_extraVariables)); + QMetaObject::invokeMethod(wizard, std::bind(&runWizard, wizard, m_defaultLocation, + selectedPlatform(), m_extraVariables), Qt::QueuedConnection); } } QDialog::accept(); diff --git a/src/plugins/coreplugin/dialogs/restartdialog.cpp b/src/plugins/coreplugin/dialogs/restartdialog.cpp index 38b9738b90b..e002ca9b03c 100644 --- a/src/plugins/coreplugin/dialogs/restartdialog.cpp +++ b/src/plugins/coreplugin/dialogs/restartdialog.cpp @@ -28,7 +28,6 @@ #include #include -#include namespace Core { @@ -41,9 +40,7 @@ RestartDialog::RestartDialog(QWidget *parent, const QString &text) addButton(tr("Later"), QMessageBox::NoRole); addButton(tr("Restart Now"), QMessageBox::YesRole); - connect(this, &QDialog::accepted, this, [] { - QTimer::singleShot(0, ICore::instance(), [] { ICore::restart(); }); - }); + connect(this, &QDialog::accepted, ICore::instance(), &ICore::restart, Qt::QueuedConnection); } } // namespace Core diff --git a/src/plugins/coreplugin/documentmanager.cpp b/src/plugins/coreplugin/documentmanager.cpp index d4e083ec0ab..904f82f8508 100644 --- a/src/plugins/coreplugin/documentmanager.cpp +++ b/src/plugins/coreplugin/documentmanager.cpp @@ -1320,7 +1320,7 @@ void DocumentManager::checkForReload() d->m_blockActivated = false; // re-check in case files where modified while the dialog was open - QTimer::singleShot(0, this, &DocumentManager::checkForReload); + QMetaObject::invokeMethod(this, &DocumentManager::checkForReload, Qt::QueuedConnection); // dump(); } diff --git a/src/plugins/coreplugin/editormanager/editormanager.cpp b/src/plugins/coreplugin/editormanager/editormanager.cpp index c463e7db2e8..f3fa8429832 100644 --- a/src/plugins/coreplugin/editormanager/editormanager.cpp +++ b/src/plugins/coreplugin/editormanager/editormanager.cpp @@ -1466,7 +1466,7 @@ void EditorManagerPrivate::addEditor(IEditor *editor) emit m_instance->documentOpened(document); } emit m_instance->editorOpened(editor); - QTimer::singleShot(0, d, &EditorManagerPrivate::autoSuspendDocuments); + QMetaObject::invokeMethod(d, &EditorManagerPrivate::autoSuspendDocuments, Qt::QueuedConnection); } void EditorManagerPrivate::removeEditor(IEditor *editor, bool removeSuspendedEntry) @@ -2366,7 +2366,8 @@ void EditorManagerPrivate::handleContextChange(const QList &context) // the locator line edit) first activates the window and sets focus to its focus widget. // Only afterwards the focus is shifted to the widget that received the click. d->m_scheduledCurrentEditor = editor; - QTimer::singleShot(0, d, &EditorManagerPrivate::setCurrentEditorFromContextChange); + QMetaObject::invokeMethod(d, &EditorManagerPrivate::setCurrentEditorFromContextChange, + Qt::QueuedConnection); } else { updateActions(); } diff --git a/src/plugins/coreplugin/fancytabwidget.cpp b/src/plugins/coreplugin/fancytabwidget.cpp index 35b397d4cfe..c72b89762df 100644 --- a/src/plugins/coreplugin/fancytabwidget.cpp +++ b/src/plugins/coreplugin/fancytabwidget.cpp @@ -221,7 +221,9 @@ void FancyTabBar::mousePressEvent(QMouseEvent *event) m_currentIndex = index; update(); // update tab bar before showing widget - QTimer::singleShot(0, this, [this]() { emit currentChanged(m_currentIndex); }); + QMetaObject::invokeMethod(this, [this]() { + emit currentChanged(m_currentIndex); + }, Qt::QueuedConnection); } } } diff --git a/src/plugins/coreplugin/fancytabwidget.h b/src/plugins/coreplugin/fancytabwidget.h index 11f3f3bcd39..8c5544665df 100644 --- a/src/plugins/coreplugin/fancytabwidget.h +++ b/src/plugins/coreplugin/fancytabwidget.h @@ -32,7 +32,6 @@ #include #include -#include QT_BEGIN_NAMESPACE class QPainter; diff --git a/src/plugins/coreplugin/find/findtoolbar.cpp b/src/plugins/coreplugin/find/findtoolbar.cpp index f78aaa78958..498b290b264 100644 --- a/src/plugins/coreplugin/find/findtoolbar.cpp +++ b/src/plugins/coreplugin/find/findtoolbar.cpp @@ -889,7 +889,7 @@ bool FindToolBar::focusNextPrevChild(bool next) void FindToolBar::resizeEvent(QResizeEvent *event) { Q_UNUSED(event) - QTimer::singleShot(0, this, &FindToolBar::updateToolBar); + QMetaObject::invokeMethod(this, &FindToolBar::updateToolBar, Qt::QueuedConnection); } void FindToolBar::writeSettings() diff --git a/src/plugins/coreplugin/find/highlightscrollbarcontroller.cpp b/src/plugins/coreplugin/find/highlightscrollbarcontroller.cpp index 65666b5bccb..32a9525def8 100644 --- a/src/plugins/coreplugin/find/highlightscrollbarcontroller.cpp +++ b/src/plugins/coreplugin/find/highlightscrollbarcontroller.cpp @@ -31,7 +31,6 @@ #include #include #include -#include using namespace Utils; @@ -105,7 +104,7 @@ void HighlightScrollBarOverlay::scheduleUpdate() return; m_isCacheUpdateScheduled = true; - QTimer::singleShot(0, this, QOverload<>::of(&QWidget::update)); + QMetaObject::invokeMethod(this, QOverload<>::of(&QWidget::update), Qt::QueuedConnection); } void HighlightScrollBarOverlay::paintEvent(QPaintEvent *paintEvent) diff --git a/src/plugins/coreplugin/icore.cpp b/src/plugins/coreplugin/icore.cpp index 01c66f2ec0f..2adf220b91c 100644 --- a/src/plugins/coreplugin/icore.cpp +++ b/src/plugins/coreplugin/icore.cpp @@ -154,7 +154,6 @@ #include #include #include -#include using namespace Core::Internal; using namespace ExtensionSystem; @@ -834,7 +833,7 @@ public: { QTC_ASSERT(watched == m_widget, return false); if (event->type() == QEvent::Show) - QTimer::singleShot(0, this, &ScreenShooter::helper); + QMetaObject::invokeMethod(this, &ScreenShooter::helper, Qt::QueuedConnection); return false; } diff --git a/src/plugins/coreplugin/locator/spotlightlocatorfilter.cpp b/src/plugins/coreplugin/locator/spotlightlocatorfilter.cpp index 89b82b0c812..4306e9cd336 100644 --- a/src/plugins/coreplugin/locator/spotlightlocatorfilter.cpp +++ b/src/plugins/coreplugin/locator/spotlightlocatorfilter.cpp @@ -46,7 +46,6 @@ #include #include #include -#include #include using namespace Utils; @@ -147,7 +146,7 @@ Utils::FilePath SpotlightIterator::filePath() const void SpotlightIterator::scheduleKillProcess() { - QTimer::singleShot(0, m_process.get(), [this] { killProcess(); }); + QMetaObject::invokeMethod(m_process.get(), [this] { killProcess(); }, Qt::QueuedConnection); } void SpotlightIterator::killProcess() diff --git a/src/plugins/coreplugin/mainwindow.cpp b/src/plugins/coreplugin/mainwindow.cpp index 1ac481ee4df..9c5e28ceb4a 100644 --- a/src/plugins/coreplugin/mainwindow.cpp +++ b/src/plugins/coreplugin/mainwindow.cpp @@ -90,7 +90,6 @@ #include #include #include -#include #include #include @@ -320,8 +319,8 @@ void MainWindow::extensionsInitialized() emit m_coreImpl->coreAboutToOpen(); // Delay restoreWindowState, since it is overridden by LayoutRequest event - QTimer::singleShot(0, this, &MainWindow::restoreWindowState); - QTimer::singleShot(0, m_coreImpl, &ICore::coreOpened); + QMetaObject::invokeMethod(this, &MainWindow::restoreWindowState, Qt::QueuedConnection); + QMetaObject::invokeMethod(m_coreImpl, &ICore::coreOpened, Qt::QueuedConnection); } static void setRestart(bool restart) @@ -930,7 +929,7 @@ void MainWindow::exit() // since on close we are going to delete everything // so to prevent the deleting of that object we // just append it - QTimer::singleShot(0, this, &QWidget::close); + QMetaObject::invokeMethod(this, &QWidget::close, Qt::QueuedConnection); } void MainWindow::openFileWith() diff --git a/src/plugins/coreplugin/menubarfilter.cpp b/src/plugins/coreplugin/menubarfilter.cpp index db8969fadb7..51de8809eec 100644 --- a/src/plugins/coreplugin/menubarfilter.cpp +++ b/src/plugins/coreplugin/menubarfilter.cpp @@ -39,7 +39,6 @@ #include #include #include -#include QT_BEGIN_NAMESPACE Utils::QHashValueType qHash(const QPointer &p, Utils::QHashValueType seed) @@ -84,10 +83,10 @@ void MenuBarFilter::accept(LocatorFilterEntry selection, QString *newText, Q_UNUSED(selectionStart) Q_UNUSED(selectionLength) if (auto action = selection.internalData.value>()) { - QTimer::singleShot(0, action, [action] { + QMetaObject::invokeMethod(action, [action] { if (action->isEnabled()) action->trigger(); - }); + }, Qt::QueuedConnection); } } diff --git a/src/plugins/coreplugin/messagemanager.cpp b/src/plugins/coreplugin/messagemanager.cpp index 019c9d69b0c..b879461e350 100644 --- a/src/plugins/coreplugin/messagemanager.cpp +++ b/src/plugins/coreplugin/messagemanager.cpp @@ -33,7 +33,6 @@ #include #include #include -#include /*! \class Core::MessageManager @@ -90,7 +89,9 @@ static void write(const QString &text, Flag flags) if (QThread::currentThread() == m_instance->thread()) doWrite(text, flags); else - QTimer::singleShot(0, m_instance, [text, flags] { doWrite(text, flags); }); + QMetaObject::invokeMethod(m_instance, [text, flags] { + doWrite(text, flags); + }, Qt::QueuedConnection); } /*! diff --git a/src/plugins/coreplugin/progressmanager/progressmanager.cpp b/src/plugins/coreplugin/progressmanager/progressmanager.cpp index 8840a85112a..7ac8b174fa6 100644 --- a/src/plugins/coreplugin/progressmanager/progressmanager.cpp +++ b/src/plugins/coreplugin/progressmanager/progressmanager.cpp @@ -343,7 +343,7 @@ bool ProgressManagerPrivate::eventFilter(QObject *obj, QEvent *event) progress = m_taskList.last(); // don't send signal directly from an event filter, event filters should // do as little a possible - QTimer::singleShot(0, progress, &FutureProgress::clicked); + QMetaObject::invokeMethod(progress, &FutureProgress::clicked, Qt::QueuedConnection); event->accept(); return true; } diff --git a/src/plugins/coreplugin/reaper.cpp b/src/plugins/coreplugin/reaper.cpp index 1039814485a..ff7bcd67130 100644 --- a/src/plugins/coreplugin/reaper.cpp +++ b/src/plugins/coreplugin/reaper.cpp @@ -80,7 +80,7 @@ ProcessReaper::ProcessReaper(QProcess *p, int timeoutMs) : m_process(p) m_iterationTimer.setSingleShot(true); connect(&m_iterationTimer, &QTimer::timeout, this, &ProcessReaper::nextIteration); - QTimer::singleShot(0, this, &ProcessReaper::nextIteration); + QMetaObject::invokeMethod(this, &ProcessReaper::nextIteration, Qt::QueuedConnection); } ProcessReaper::~ProcessReaper() diff --git a/src/plugins/cpaster/frontend/main.cpp b/src/plugins/cpaster/frontend/main.cpp index afdfdd91662..b2aba50ac3d 100644 --- a/src/plugins/cpaster/frontend/main.cpp +++ b/src/plugins/cpaster/frontend/main.cpp @@ -29,7 +29,6 @@ #include #include -#include #include #include @@ -109,7 +108,7 @@ int main(int argc, char *argv[]) return EXIT_SUCCESS; case ArgumentsCollector::RequestTypePaste: { PasteReceiver pr(argsCollector.protocol(), argsCollector.inputFilePath()); - QTimer::singleShot(0, &pr, &PasteReceiver::paste); + QMetaObject::invokeMethod(&pr, &PasteReceiver::paste, Qt::QueuedConnection); return app.exec(); } } diff --git a/src/plugins/cppeditor/cppminimizableinfobars.cpp b/src/plugins/cppeditor/cppminimizableinfobars.cpp index d0a7b38aafb..aec2e1b4627 100644 --- a/src/plugins/cppeditor/cppminimizableinfobars.cpp +++ b/src/plugins/cppeditor/cppminimizableinfobars.cpp @@ -27,7 +27,6 @@ #include "cppeditorconstants.h" -#include #include #include @@ -142,10 +141,8 @@ static InfoBarEntry createMinimizableInfo(const Id &id, // The minimizer() might delete the "Minimize" button immediately and as // result invalid reads will happen in QToolButton::mouseReleaseEvent(). // Avoid this by running the minimizer in the next event loop iteration. - info.setCustomButtonInfo(MinimizableInfoBars::tr("Minimize"), [=](){ - QTimer::singleShot(0, [=] { - minimizer(); - }); + info.setCustomButtonInfo(MinimizableInfoBars::tr("Minimize"), [minimizer] { + QMetaObject::invokeMethod(settings(), [minimizer] { minimizer(); }, Qt::QueuedConnection); }); return info;