summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/core/miranda.cpp2
-rw-r--r--src/core/miranda.h1
-rw-r--r--src/modules/protocols/protochains.cpp26
-rw-r--r--src/modules/protocols/protocols.cpp2
-rw-r--r--src/modules/skin/hotkeys.cpp2
5 files changed, 15 insertions, 18 deletions
diff --git a/src/core/miranda.cpp b/src/core/miranda.cpp
index 9f0da67b09..66a3ca8e80 100644
--- a/src/core/miranda.cpp
+++ b/src/core/miranda.cpp
@@ -85,6 +85,7 @@ static char *pszWaitServices[MAXIMUM_WAIT_OBJECTS-1];
static int waitObjectCount = 0;
HANDLE hMirandaShutdown;
HINSTANCE hInst;
+DWORD hMainThreadId;
int hLangpack = 0;
bool bModulesLoadedFired = false;
@@ -210,6 +211,7 @@ void CheckRestart()
int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE, LPTSTR cmdLine, int)
{
hInst = hInstance;
+ hMainThreadId = GetCurrentThreadId();
CmdLine_Parse(cmdLine);
setlocale(LC_ALL, "");
diff --git a/src/core/miranda.h b/src/core/miranda.h
index 49fbfa68ae..3cfaab2b76 100644
--- a/src/core/miranda.h
+++ b/src/core/miranda.h
@@ -132,6 +132,7 @@ void KillModuleSounds(int hLangpack);
/**** miranda.cpp **********************************************************************/
extern HINSTANCE hInst;
+extern DWORD hMainThreadId;
extern HANDLE hOkToExitEvent, hModulesLoadedEvent, hevLoadModule, hevUnloadModule;
/**** newplugins.cpp *******************************************************************/
diff --git a/src/modules/protocols/protochains.cpp b/src/modules/protocols/protochains.cpp
index d9737bdb06..176711ce34 100644
--- a/src/modules/protocols/protochains.cpp
+++ b/src/modules/protocols/protochains.cpp
@@ -127,23 +127,24 @@ INT_PTR Proto_CallContactService(WPARAM wParam, LPARAM lParam)
/////////////////////////////////////////////////////////////////////////////////////////
-static INT_PTR CallRecvChain(WPARAM wParam, LPARAM lParam)
+static INT_PTR Proto_RecvChain(WPARAM wParam, LPARAM lParam)
{
CCSDATA *ccs = (CCSDATA*)lParam;
INT_PTR ret;
if (wParam == (WPARAM)(-1)) return 1; //shouldn't happen - sanity check
- if (wParam == 0) //begin processing by finding end of chain
+ if (wParam == 0) { //begin processing by finding end of chain
+ if (GetCurrentThreadId() != hMainThreadId) // restart this function in the main thread
+ return CallServiceSync(MS_PROTO_CHAINRECV, wParam, lParam);
+
wParam = filters.getCount();
- else
- wParam--;
+ }
+ else wParam--;
- for (int i = wParam-1; i >= 0; i--) {
- if ((ret = CallProtoServiceInt(NULL, filters[i]->szName, ccs->szProtoService, i+1, lParam)) != CALLSERVICE_NOTFOUND) {
+ for (int i = wParam-1; i >= 0; i--)
+ if ((ret = CallProtoServiceInt(NULL, filters[i]->szName, ccs->szProtoService, i+1, lParam)) != CALLSERVICE_NOTFOUND)
//chain was started, exit
return ret;
- }
- }
//end of chain, call network protocol again
char szProto[40];
@@ -164,12 +165,6 @@ static INT_PTR CallRecvChain(WPARAM wParam, LPARAM lParam)
return ret;
}
-static INT_PTR Proto_ChainRecv(WPARAM wParam, LPARAM lParam)
-{
- /* this will switch threads just like before */
- return CallServiceSync(MS_PROTO_CHAINRECV "ThreadSafe", wParam, lParam);
-}
-
PROTOACCOUNT* __fastcall Proto_GetAccount(HANDLE hContact)
{
if (hContact == NULL)
@@ -252,8 +247,7 @@ int LoadProtoChains(void)
CreateServiceFunction(MS_PROTO_CALLCONTACTSERVICE, Proto_CallContactService);
CreateServiceFunction(MS_PROTO_CHAINSEND, Proto_CallContactService);
- CreateServiceFunction(MS_PROTO_CHAINRECV, Proto_ChainRecv);
- CreateServiceFunction(MS_PROTO_CHAINRECV "ThreadSafe", CallRecvChain);
+ CreateServiceFunction(MS_PROTO_CHAINRECV, Proto_RecvChain);
CreateServiceFunction(MS_PROTO_GETCONTACTBASEPROTO, Proto_GetContactBaseProto);
CreateServiceFunction(MS_PROTO_GETCONTACTBASEACCOUNT, Proto_GetContactBaseAccount);
CreateServiceFunction(MS_PROTO_ISPROTOONCONTACT, Proto_IsProtoOnContact);
diff --git a/src/modules/protocols/protocols.cpp b/src/modules/protocols/protocols.cpp
index 7589693e3b..0b471da68a 100644
--- a/src/modules/protocols/protocols.cpp
+++ b/src/modules/protocols/protocols.cpp
@@ -147,7 +147,7 @@ static INT_PTR Proto_RegisterModule(WPARAM, LPARAM lParam)
else *p = *pd;
p->szName = mir_strdup(pd->szName);
protos.insert(p);
- if (p->type != PROTOTYPE_PROTOCOL)
+ if (p->type != PROTOTYPE_PROTOCOL && p->type != PROTOTYPE_VIRTUAL)
filters.insert(p);
return 0;
}
diff --git a/src/modules/skin/hotkeys.cpp b/src/modules/skin/hotkeys.cpp
index 96f1f7c268..81b24e2e42 100644
--- a/src/modules/skin/hotkeys.cpp
+++ b/src/modules/skin/hotkeys.cpp
@@ -357,7 +357,7 @@ int LoadSkinHotkeys(void)
g_hwndHotkeyHost = CreateWindow(_T("MirandaHotkeyHostWnd"), NULL, 0, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, HWND_DESKTOP, NULL, hInst, NULL);
SetWindowPos(g_hwndHotkeyHost, 0, 0, 0, 0, 0, SWP_NOZORDER|SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE|SWP_DEFERERASE|SWP_NOSENDCHANGING|SWP_HIDEWINDOW);
- hhkKeyboard = SetWindowsHookEx(WH_KEYBOARD, sttKeyboardProc, NULL, GetCurrentThreadId());
+ hhkKeyboard = SetWindowsHookEx(WH_KEYBOARD, sttKeyboardProc, NULL, hMainThreadId);
hEvChanged = CreateHookableEvent(ME_HOTKEYS_CHANGED);