Permalink
Browse files

Improved handling of AHK_ATTACH_DEBUGGER message.

It must now be sent or posted to the script's main window (not a GUI),
  and should work even if a message loop other than the one in
  MsgSleep() is running. (For instance, while waiting for MsgBox.)
  • Loading branch information...
1 parent 69181d3 commit 83f0a0e39a0f69fc8861f8c4234690557c4ab347 @Lexikos committed Mar 30, 2012
Showing with 24 additions and 25 deletions.
  1. +0 −25 source/application.cpp
  2. +24 −0 source/script2.cpp
@@ -1424,31 +1424,6 @@ bool MsgSleep(int aSleepDuration, MessageMode aMode)
// external ever explicitly posts a WM_QUIT to our thread's queue:
g_script.ExitApp(EXIT_WM_QUIT);
continue; // Since ExitApp() won't necessarily exit.
-
-#ifdef CONFIG_DEBUGGER
- default:
- static UINT sAttachDebuggerMessage = RegisterWindowMessage(_T("AHK_ATTACH_DEBUGGER"));
- if (msg.message == sAttachDebuggerMessage && !g_Debugger.IsConnected())
- {
- char dbg_host[16] = "localhost"; // IPv4 max string len
- char dbg_port[6] = "9000";
-
- if (msg.wParam)
- { // Convert 32-bit address to string for Debugger::Connect().
- in_addr addr;
- addr.S_un.S_addr = (ULONG)msg.wParam;
- char *tmp = inet_ntoa(addr);
- if (tmp)
- strcpy(dbg_host, tmp);
- }
- if (msg.lParam)
- // Convert 16-bit port number to string for Debugger::Connect().
- _itoa(LOWORD(msg.lParam), dbg_port, 10);
-
- if (g_Debugger.Connect(dbg_host, dbg_port) == DEBUGGER_E_OK)
- g_Debugger.ProcessCommands();
- }
-#endif
} // switch()
break_out_of_main_switch:
View
@@ -5513,6 +5513,30 @@ LRESULT CALLBACK MainWindowProc(HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lPar
g_script.UpdateTrayIcon(true); // Force the icon into the correct pause, suspend, or mIconFrozen state.
// And now pass this iMsg on to DefWindowProc() in case it does anything with it.
}
+
+#ifdef CONFIG_DEBUGGER
+ static UINT sAttachDebuggerMessage = RegisterWindowMessage(_T("AHK_ATTACH_DEBUGGER"));
+ if (iMsg == sAttachDebuggerMessage && !g_Debugger.IsConnected())
+ {
+ char dbg_host[16] = "localhost"; // IPv4 max string len
+ char dbg_port[6] = "9000";
+
+ if (wParam)
+ { // Convert 32-bit address to string for Debugger::Connect().
+ in_addr addr;
+ addr.S_un.S_addr = (ULONG)wParam;
+ char *tmp = inet_ntoa(addr);
+ if (tmp)
+ strcpy(dbg_host, tmp);
+ }
+ if (lParam)
+ // Convert 16-bit port number to string for Debugger::Connect().
+ _itoa(LOWORD(lParam), dbg_port, 10);
+
+ if (g_Debugger.Connect(dbg_host, dbg_port) == DEBUGGER_E_OK)
+ g_Debugger.ProcessCommands();
+ }
+#endif
} // switch()

0 comments on commit 83f0a0e

Please sign in to comment.