diff --git a/qrenderdoc/Code/QRDUtils.cpp b/qrenderdoc/Code/QRDUtils.cpp index fd598165d..adf0d910f 100644 --- a/qrenderdoc/Code/QRDUtils.cpp +++ b/qrenderdoc/Code/QRDUtils.cpp @@ -26,6 +26,7 @@ #include #include #include +#include bool SaveToJSON(QVariantMap &data, QIODevice &f, const char *magicIdentifier, uint32_t magicVersion) { @@ -88,6 +89,14 @@ bool LoadFromJSON(QVariantMap &data, QIODevice &f, const char *magicIdentifier, return true; } +int GUIInvoke::methodIndex = -1; + +void GUIInvoke::init() +{ + GUIInvoke *invoke = new GUIInvoke(); + methodIndex = invoke->metaObject()->indexOfMethod(QMetaObject::normalizedSignature("doInvoke()")); +} + void GUIInvoke::call(const std::function &f) { if(qApp->thread() == QThread::currentThread()) @@ -96,12 +105,9 @@ void GUIInvoke::call(const std::function &f) return; } - // TODO: could maybe do away with string compare here via caching - // invoke->metaObject()->indexOfMethod("doInvoke"); ? - GUIInvoke *invoke = new GUIInvoke(f); invoke->moveToThread(qApp->thread()); - QMetaObject::invokeMethod(invoke, "doInvoke", Qt::QueuedConnection); + invoke->metaObject()->method(methodIndex).invoke(invoke, Qt::QueuedConnection); } void GUIInvoke::blockcall(const std::function &f) @@ -112,12 +118,9 @@ void GUIInvoke::blockcall(const std::function &f) return; } - // TODO: could maybe do away with string compare here via caching - // invoke->metaObject()->indexOfMethod("doInvoke"); ? - GUIInvoke *invoke = new GUIInvoke(f); invoke->moveToThread(qApp->thread()); - QMetaObject::invokeMethod(invoke, "doInvoke", Qt::BlockingQueuedConnection); + invoke->metaObject()->method(methodIndex).invoke(invoke, Qt::BlockingQueuedConnection); } void RDDialog::show(QMenu *menu, QPoint pos) diff --git a/qrenderdoc/Code/QRDUtils.h b/qrenderdoc/Code/QRDUtils.h index cf1507c88..55ac0fc69 100644 --- a/qrenderdoc/Code/QRDUtils.h +++ b/qrenderdoc/Code/QRDUtils.h @@ -55,9 +55,13 @@ class GUIInvoke : public QObject private: Q_OBJECT GUIInvoke(const std::function &f) : func(f) {} + GUIInvoke() {} std::function func; + static int methodIndex; + public: + static void init(); static void call(const std::function &f); static void blockcall(const std::function &f); diff --git a/qrenderdoc/Code/qrenderdoc.cpp b/qrenderdoc/Code/qrenderdoc.cpp index f990742bb..8bee1c9f2 100644 --- a/qrenderdoc/Code/qrenderdoc.cpp +++ b/qrenderdoc/Code/qrenderdoc.cpp @@ -132,6 +132,8 @@ int main(int argc, char *argv[]) config.SetupFormatting(); + GUIInvoke::init(); + CaptureContext ctx(filename, remoteHost, remoteIdent, temp, config); while(ctx.isRunning())