1
0
Fork 0

GUI: introduce MethodInvoker utility

This commit is contained in:
Duncan Ogilvie 2020-02-10 02:31:05 +01:00
parent 472a8160dd
commit 992e6d2374
No known key found for this signature in database
GPG Key ID: FC89E0AAA0C1AAD8
2 changed files with 26 additions and 1 deletions

View File

@ -0,0 +1,24 @@
#ifndef METHODINVOKER_H
#define METHODINVOKER_H
#include <functional>
#include "Bridge.h"
struct MethodInvoker
{
template<class Func>
static void invokeMethod(Func && fn)
{
using StdFunc = std::function<void()>;
auto fnPtr = new StdFunc(std::forward<Func>(fn));
GuiExecuteOnGuiThreadEx([](void* userdata)
{
auto stdFunc = (StdFunc*)userdata;
(*stdFunc)();
delete stdFunc;
}, fnPtr);
}
};
#endif // METHODINVOKER_H

View File

@ -304,7 +304,8 @@ HEADERS += \
Src/BasicView/AbstractSearchList.h \
Src/BasicView/StdSearchListView.h \
Src/Gui/FileLines.h \
Src/BasicView/StdTableSearchList.h
Src/BasicView/StdTableSearchList.h \
Src/Utils/MethodInvoker.h
FORMS += \