summaryrefslogtreecommitdiff
path: root/src/mir_core
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2016-09-17 17:42:48 +0000
committerGeorge Hazan <george.hazan@gmail.com>2016-09-17 17:42:48 +0000
commitd0735d50571bca069ee2fe372095b3750a32f51d (patch)
tree19d87e89cf4c4cf583b3d6873e0273c96795b8e6 /src/mir_core
parente5d58fc3bbbce2773b7c6c3f8b7da6faa66b672e (diff)
- fix for tray icon blinking in chats;
- code cleaning git-svn-id: http://svn.miranda-ng.org/main/trunk@17310 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'src/mir_core')
-rw-r--r--src/mir_core/src/mir_core.def1
-rw-r--r--src/mir_core/src/mir_core64.def1
-rw-r--r--src/mir_core/src/modules.cpp31
3 files changed, 33 insertions, 0 deletions
diff --git a/src/mir_core/src/mir_core.def b/src/mir_core/src/mir_core.def
index a9bdba9103..435036b9b4 100644
--- a/src/mir_core/src/mir_core.def
+++ b/src/mir_core/src/mir_core.def
@@ -1010,3 +1010,4 @@ db_delete_module @1161
?SetMaxLength@CCtrlEdit@@QAEXI@Z @1167 NONAME
?SetRange@CCtrlSpin@@QAEXFF@Z @1168 NONAME
db_get_current @1169
+CallFunctionSync @1170
diff --git a/src/mir_core/src/mir_core64.def b/src/mir_core/src/mir_core64.def
index c7279247af..f08ff49cdf 100644
--- a/src/mir_core/src/mir_core64.def
+++ b/src/mir_core/src/mir_core64.def
@@ -1010,3 +1010,4 @@ db_delete_module @1161
?SetMaxLength@CCtrlEdit@@QEAAXI@Z @1167 NONAME
?SetRange@CCtrlSpin@@QEAAXFF@Z @1168 NONAME
db_get_current @1169
+CallFunctionSync @1170
diff --git a/src/mir_core/src/modules.cpp b/src/mir_core/src/modules.cpp
index 7fd0cfc45a..a462d456f4 100644
--- a/src/mir_core/src/modules.cpp
+++ b/src/mir_core/src/modules.cpp
@@ -571,6 +571,8 @@ MIR_CORE_DLL(INT_PTR) CallServiceSync(const char *name, WPARAM wParam, LPARAM lP
return item.result;
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
MIR_CORE_DLL(int) CallFunctionAsync(void(__stdcall *func)(void *), void *arg)
{
if (GetCurrentThreadId() == mainThreadId)
@@ -580,6 +582,35 @@ MIR_CORE_DLL(int) CallFunctionAsync(void(__stdcall *func)(void *), void *arg)
return 0;
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
+struct TSyncCallParam
+{
+ INT_PTR (__stdcall *func)(void *);
+ void *arg;
+ HANDLE hDoneEvent;
+ INT_PTR result;
+};
+
+static void CALLBACK CallFuncToMainAPCFunc(ULONG_PTR dwParam)
+{
+ TSyncCallParam *item = (TSyncCallParam*)dwParam;
+ item->result = (*item->func)(item->arg);
+ SetEvent(item->hDoneEvent);
+}
+
+MIR_CORE_DLL(INT_PTR) CallFunctionSync(INT_PTR (__stdcall *func)(void *), void *arg)
+{
+ if (GetCurrentThreadId() == mainThreadId)
+ return func(arg);
+
+ TSyncCallParam param = { func, arg, getThreadEvent() };
+ QueueMainThread(CallFuncToMainAPCFunc, &param, param.hDoneEvent);
+ return param.result;
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
MIR_CORE_DLL(void) KillModuleServices(HINSTANCE hInst)
{
mir_cslock lck(csServices);