GUI: introduce MethodInvoker utility
This commit is contained in:
parent
472a8160dd
commit
992e6d2374
|
|
@ -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
|
||||
|
|
@ -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 += \
|
||||
|
|
|
|||
Loading…
Reference in New Issue