aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJarek Kobus <jaroslaw.kobus@qt.io>2020-11-11 16:34:39 +0100
committerJarek Kobus <jaroslaw.kobus@qt.io>2020-11-16 13:45:02 +0000
commit6d5e30215762255abb76faa2d81a1a8ff60b8960 (patch)
tree3d62b027bf5a94b55b79eaa796b233b50f8a3e17
parent3167d23a36ff5b9fd42105f763b9e19bf62596cb (diff)
Use typed syntax in calls to QMetaObject::invokeMethod
We do it wherever possible. Some places can't be fixed since they still rely on dynamic introspection (mainly QQuickItem cases). Change-Id: Ia00b4a04d8b995c9a43b7bf2dbe76a60364bb8ca Reviewed-by: Eike Ziller <eike.ziller@qt.io>
-rw-r--r--src/libs/advanceddockingsystem/dockareatitlebar.cpp8
-rw-r--r--src/libs/qmljs/qmljsmodelmanagerinterface.cpp5
-rw-r--r--src/libs/qmljs/qmljsplugindumper.cpp12
-rw-r--r--src/libs/ssh/sshconnectionmanager.cpp10
-rw-r--r--src/plugins/clearcase/clearcaseplugin.cpp2
-rw-r--r--src/plugins/coreplugin/find/basetextfind.cpp3
-rw-r--r--src/plugins/coreplugin/locator/opendocumentsfilter.cpp3
-rw-r--r--src/plugins/cpptools/stringtable.cpp3
-rw-r--r--src/plugins/debugger/gdb/gdbengine.cpp3
-rw-r--r--src/plugins/debugger/uvsc/uvscengine.cpp4
-rw-r--r--src/plugins/help/helpindexfilter.cpp4
-rw-r--r--src/plugins/help/searchwidget.cpp2
-rw-r--r--src/plugins/projectexplorer/foldernavigationwidget.cpp6
-rw-r--r--src/plugins/scxmleditor/plugin_interface/graphicsscene.cpp6
14 files changed, 36 insertions, 35 deletions
diff --git a/src/libs/advanceddockingsystem/dockareatitlebar.cpp b/src/libs/advanceddockingsystem/dockareatitlebar.cpp
index 4430f936723..f2a2ad4cc0c 100644
--- a/src/libs/advanceddockingsystem/dockareatitlebar.cpp
+++ b/src/libs/advanceddockingsystem/dockareatitlebar.cpp
@@ -293,7 +293,8 @@ namespace ADS
if (QEvent::EnabledChange == event->type() && m_hideWhenDisabled) {
// force setVisible() call
// Calling setVisible() directly here doesn't work well when button is expected to be shown first time
- QMetaObject::invokeMethod(this, "setVisible", Qt::QueuedConnection, Q_ARG(bool, isEnabled()));
+ const bool visible = isEnabled();
+ QMetaObject::invokeMethod(this, [this, visible] { setVisible(visible); }, Qt::QueuedConnection);
}
return Super::event(event);
@@ -352,8 +353,9 @@ namespace ADS
break;
}
}
- bool visible = (hasElidedTabTitle && (d->m_tabBar->count() > 1));
- QMetaObject::invokeMethod(d->m_tabsMenuButton, "setVisible", Qt::QueuedConnection, Q_ARG(bool, visible));
+ const bool visible = (hasElidedTabTitle && (d->m_tabBar->count() > 1));
+ QMetaObject::invokeMethod(this, [this, visible] {
+ d->m_tabsMenuButton->setVisible(visible); }, Qt::QueuedConnection);
}
d->m_menuOutdated = true;
}
diff --git a/src/libs/qmljs/qmljsmodelmanagerinterface.cpp b/src/libs/qmljs/qmljsmodelmanagerinterface.cpp
index 3cc8db7e630..210adf6096b 100644
--- a/src/libs/qmljs/qmljsmodelmanagerinterface.cpp
+++ b/src/libs/qmljs/qmljsmodelmanagerinterface.cpp
@@ -1250,8 +1250,7 @@ void ModelManagerInterface::maybeQueueCppQmlTypeUpdate(const CPlusPlus::Document
doc->releaseSourceAndAST();
// delegate actual queuing to the gui thread
- QMetaObject::invokeMethod(this, "queueCppQmlTypeUpdate",
- Q_ARG(CPlusPlus::Document::Ptr, doc), Q_ARG(bool, scan));
+ QMetaObject::invokeMethod(this, [=] { queueCppQmlTypeUpdate(doc, scan); });
}
void ModelManagerInterface::queueCppQmlTypeUpdate(const CPlusPlus::Document::Ptr &doc, bool scan)
@@ -1392,7 +1391,7 @@ void ModelManagerInterface::updateCppQmlTypes(
qmlModelManager->m_cppDeclarationFiles = newDeclarations;
if (hasNewInfo)
// one could get away with re-linking the cpp types...
- QMetaObject::invokeMethod(qmlModelManager, "asyncReset");
+ QMetaObject::invokeMethod(qmlModelManager, &ModelManagerInterface::asyncReset);
}
ModelManagerInterface::CppDataHash ModelManagerInterface::cppData() const
diff --git a/src/libs/qmljs/qmljsplugindumper.cpp b/src/libs/qmljs/qmljsplugindumper.cpp
index 8b7604809b6..a1c084a59a9 100644
--- a/src/libs/qmljs/qmljsplugindumper.cpp
+++ b/src/libs/qmljs/qmljsplugindumper.cpp
@@ -65,24 +65,20 @@ Utils::FileSystemWatcher *PluginDumper::pluginWatcher()
void PluginDumper::loadBuiltinTypes(const QmlJS::ModelManagerInterface::ProjectInfo &info)
{
// move to the owning thread
- metaObject()->invokeMethod(this, "onLoadBuiltinTypes",
- Q_ARG(QmlJS::ModelManagerInterface::ProjectInfo, info));
+ metaObject()->invokeMethod(this, [=] { onLoadBuiltinTypes(info); });
}
void PluginDumper::loadPluginTypes(const QString &libraryPath, const QString &importPath, const QString &importUri, const QString &importVersion)
{
// move to the owning thread
- metaObject()->invokeMethod(this, "onLoadPluginTypes",
- Q_ARG(QString, libraryPath),
- Q_ARG(QString, importPath),
- Q_ARG(QString, importUri),
- Q_ARG(QString, importVersion));
+ metaObject()->invokeMethod(this, [=] { onLoadPluginTypes(libraryPath, importPath,
+ importUri, importVersion); });
}
void PluginDumper::scheduleRedumpPlugins()
{
// move to the owning thread
- metaObject()->invokeMethod(this, "dumpAllPlugins", Qt::QueuedConnection);
+ metaObject()->invokeMethod(this, &PluginDumper::dumpAllPlugins, Qt::QueuedConnection);
}
void PluginDumper::onLoadBuiltinTypes(const QmlJS::ModelManagerInterface::ProjectInfo &info, bool force)
diff --git a/src/libs/ssh/sshconnectionmanager.cpp b/src/libs/ssh/sshconnectionmanager.cpp
index 68533728f23..ac73878b8cc 100644
--- a/src/libs/ssh/sshconnectionmanager.cpp
+++ b/src/libs/ssh/sshconnectionmanager.cpp
@@ -107,11 +107,11 @@ public:
|| connection->connectionParameters() != sshParams)
continue;
- if (connection->thread() != QThread::currentThread()) {
- QMetaObject::invokeMethod(this, "switchToCallerThread",
- Qt::BlockingQueuedConnection,
- Q_ARG(SshConnection *, connection),
- Q_ARG(QObject *, QThread::currentThread()));
+ auto currentThread = QThread::currentThread();
+ if (connection->thread() != currentThread) {
+ QMetaObject::invokeMethod(this, [this, connection, currentThread] {
+ switchToCallerThread(connection, currentThread);
+ }, Qt::BlockingQueuedConnection);
}
m_unacquiredConnections.removeOne(c);
diff --git a/src/plugins/clearcase/clearcaseplugin.cpp b/src/plugins/clearcase/clearcaseplugin.cpp
index 770cbf2defa..d8765f8bca8 100644
--- a/src/plugins/clearcase/clearcaseplugin.cpp
+++ b/src/plugins/clearcase/clearcaseplugin.cpp
@@ -1059,7 +1059,7 @@ void ClearCasePluginPrivate::setStatus(const QString &file, FileStatus::Status s
m_statusMap->insert(file, FileStatus(status, QFileInfo(file).permissions()));
if (update && currentState().currentFile() == file)
- QMetaObject::invokeMethod(this, "updateStatusActions");
+ QMetaObject::invokeMethod(this, &ClearCasePluginPrivate::updateStatusActions);
}
void ClearCasePluginPrivate::undoCheckOutCurrent()
diff --git a/src/plugins/coreplugin/find/basetextfind.cpp b/src/plugins/coreplugin/find/basetextfind.cpp
index c58447e8b70..dec5d4186e2 100644
--- a/src/plugins/coreplugin/find/basetextfind.cpp
+++ b/src/plugins/coreplugin/find/basetextfind.cpp
@@ -451,6 +451,9 @@ QTextCursor BaseTextFind::findOne(const QRegularExpression &expr,
if (!inScope(candidate.selectionStart(), candidate.selectionEnd()))
return candidate;
bool inVerticalFindScope = false;
+ // This code relies on the fact, that we have to keep TextEditorWidget subclass
+ // inside d->m_plaineditor which is of QPlainTextEdit class. So we can't
+ // transform it into a typed version now, as it relies on a dynamic match.
QMetaObject::invokeMethod(d->m_plaineditor, "inFindScope", Qt::DirectConnection,
Q_RETURN_ARG(bool, inVerticalFindScope),
Q_ARG(QTextCursor, candidate));
diff --git a/src/plugins/coreplugin/locator/opendocumentsfilter.cpp b/src/plugins/coreplugin/locator/opendocumentsfilter.cpp
index fe67e5d884b..b58293fae8f 100644
--- a/src/plugins/coreplugin/locator/opendocumentsfilter.cpp
+++ b/src/plugins/coreplugin/locator/opendocumentsfilter.cpp
@@ -113,7 +113,8 @@ QList<OpenDocumentsFilter::Entry> OpenDocumentsFilter::editors() const
void OpenDocumentsFilter::refresh(QFutureInterface<void> &future)
{
Q_UNUSED(future)
- QMetaObject::invokeMethod(this, "refreshInternally", Qt::BlockingQueuedConnection);
+ QMetaObject::invokeMethod(this, &OpenDocumentsFilter::refreshInternally,
+ Qt::BlockingQueuedConnection);
}
void OpenDocumentsFilter::accept(LocatorFilterEntry selection,
diff --git a/src/plugins/cpptools/stringtable.cpp b/src/plugins/cpptools/stringtable.cpp
index e27fc5ceaef..efd186fada9 100644
--- a/src/plugins/cpptools/stringtable.cpp
+++ b/src/plugins/cpptools/stringtable.cpp
@@ -108,7 +108,8 @@ QString StringTablePrivate::insert(const QString &string)
void StringTable::scheduleGC()
{
- QMetaObject::invokeMethod(&m_instance->m_gcCountDown, "start", Qt::QueuedConnection);
+ QMetaObject::invokeMethod(&m_instance->m_gcCountDown, QOverload<>::of(&QTimer::start),
+ Qt::QueuedConnection);
}
StringTable::StringTable()
diff --git a/src/plugins/debugger/gdb/gdbengine.cpp b/src/plugins/debugger/gdb/gdbengine.cpp
index 3e76d5a782c..af373a1de15 100644
--- a/src/plugins/debugger/gdb/gdbengine.cpp
+++ b/src/plugins/debugger/gdb/gdbengine.cpp
@@ -765,8 +765,7 @@ void GdbEngine::runCommand(const DebuggerCommand &command)
m_scheduledTestResponses.remove(token);
showMessage(QString("FAKING TEST RESPONSE (TOKEN: %2, RESPONSE: %3)")
.arg(token).arg(buffer));
- QMetaObject::invokeMethod(this, "handleResponse",
- Q_ARG(QString, buffer));
+ QMetaObject::invokeMethod(this, [this, buffer] { handleResponse(buffer); });
} else {
m_gdbProc.write(cmd.function.toUtf8() + "\r\n");
if (command.flags & NeedsFlush)
diff --git a/src/plugins/debugger/uvsc/uvscengine.cpp b/src/plugins/debugger/uvsc/uvscengine.cpp
index 75e8bddb8d5..ca2619f4f0f 100644
--- a/src/plugins/debugger/uvsc/uvscengine.cpp
+++ b/src/plugins/debugger/uvsc/uvscengine.cpp
@@ -531,8 +531,8 @@ void UvscEngine::doUpdateLocals(const UpdateParameters &params)
const bool partial = !params.partialVariable.isEmpty();
// This is a workaround to avoid a strange QVector index assertion
// inside of the watch model.
- QMetaObject::invokeMethod(this, "handleUpdateLocals", Qt::QueuedConnection,
- Q_ARG(bool, partial));
+ QMetaObject::invokeMethod(this, [this, partial] { handleUpdateLocals(partial); },
+ Qt::QueuedConnection);
}
void UvscEngine::updateAll()
diff --git a/src/plugins/help/helpindexfilter.cpp b/src/plugins/help/helpindexfilter.cpp
index 45d2ba63882..693d56dbb32 100644
--- a/src/plugins/help/helpindexfilter.cpp
+++ b/src/plugins/help/helpindexfilter.cpp
@@ -180,8 +180,8 @@ QList<LocatorFilterEntry> HelpIndexFilter::matchesFor(QFutureInterface<LocatorFi
if (forceUpdate) {
QStringList indices;
- QMetaObject::invokeMethod(this, "allIndices", Qt::BlockingQueuedConnection,
- Q_RETURN_ARG(QStringList, indices));
+ QMetaObject::invokeMethod(this, [this] { return allIndices(); },
+ Qt::BlockingQueuedConnection, &indices);
m_mutex.lock(); // guard m_needsUpdate
m_needsUpdate = false;
m_mutex.unlock();
diff --git a/src/plugins/help/searchwidget.cpp b/src/plugins/help/searchwidget.cpp
index 48d48347374..cb2db9f76da 100644
--- a/src/plugins/help/searchwidget.cpp
+++ b/src/plugins/help/searchwidget.cpp
@@ -155,7 +155,7 @@ void SearchWidget::showEvent(QShowEvent *event)
connect(searchEngine, &QHelpSearchEngine::indexingFinished, this,
&SearchWidget::indexingFinished);
- QMetaObject::invokeMethod(&LocalHelpManager::helpEngine(), "setupFinished",
+ QMetaObject::invokeMethod(&LocalHelpManager::helpEngine(), &QHelpEngine::setupFinished,
Qt::QueuedConnection);
}
}
diff --git a/src/plugins/projectexplorer/foldernavigationwidget.cpp b/src/plugins/projectexplorer/foldernavigationwidget.cpp
index 9ebf310681e..f54ea3f7d92 100644
--- a/src/plugins/projectexplorer/foldernavigationwidget.cpp
+++ b/src/plugins/projectexplorer/foldernavigationwidget.cpp
@@ -388,10 +388,8 @@ FolderNavigationWidget::FolderNavigationWidget(QWidget *parent) : QWidget(parent
// QTimer::singleShot only posts directly onto the event loop if you use the SLOT("...")
// notation, so using a singleShot with a lambda would flicker
// QTimer::singleShot(0, this, [this, filePath]() { setCrumblePath(filePath); });
- QMetaObject::invokeMethod(this,
- "setCrumblePath",
- Qt::QueuedConnection,
- Q_ARG(Utils::FilePath, filePath));
+ QMetaObject::invokeMethod(this, [this, filePath] { setCrumblePath(filePath); },
+ Qt::QueuedConnection);
});
connect(m_crumbLabel, &Utils::FileCrumbLabel::pathClicked, [this](const Utils::FilePath &path) {
const QModelIndex rootIndex = m_sortProxyModel->mapToSource(m_listView->rootIndex());
diff --git a/src/plugins/scxmleditor/plugin_interface/graphicsscene.cpp b/src/plugins/scxmleditor/plugin_interface/graphicsscene.cpp
index 604824d464e..6e941fd8077 100644
--- a/src/plugins/scxmleditor/plugin_interface/graphicsscene.cpp
+++ b/src/plugins/scxmleditor/plugin_interface/graphicsscene.cpp
@@ -832,7 +832,8 @@ void GraphicsScene::addWarningItem(WarningItem *item)
if (!m_allWarnings.contains(item)) {
m_allWarnings << item;
if (!m_autoLayoutRunning && !m_initializing)
- QMetaObject::invokeMethod(this, "warningVisibilityChanged", Qt::QueuedConnection, Q_ARG(int, 0));
+ QMetaObject::invokeMethod(this, [this] { warningVisibilityChanged(0); },
+ Qt::QueuedConnection);
}
}
@@ -841,7 +842,8 @@ void GraphicsScene::removeWarningItem(WarningItem *item)
m_allWarnings.removeAll(item);
if (!m_autoLayoutRunning && !m_initializing)
- QMetaObject::invokeMethod(this, "warningVisibilityChanged", Qt::QueuedConnection, Q_ARG(int, 0));
+ QMetaObject::invokeMethod(this, [this] { warningVisibilityChanged(0); },
+ Qt::QueuedConnection);
}
void GraphicsScene::warningVisibilityChanged(int type, WarningItem *item)