Skip to content
Tcl Source Code Artifact [f538914aba]
Login

Artifact [f538914aba]

Artifact f538914aba889b16dd99efc2d55dcb8fef90ca50:

Ticket change [f538914aba] - Ticket [1113452fffffffff|1113452fff] <i>Tk_MainLoop processes WM_DEVICE_CHANGE infinitely often.</i> status still Open with 7 other changes by dkf on 2014-02-23 16:52:14.
D 2014-02-23T16:52:14.501
J closer nobody
J comment Here\sis\swhat\shappens:\r\n\r\n0.\sIn\sMacroMedia's\sDirector\sMX\s2004,\sI\slaunch\sa\sthread\s\r\n(via\s_beginthread,\scalled\sfrom\san\sxtra)\sthat\sstarts\sa\s\r\nTcl\sinterpreter\s(with\sTk,\sTclX\set\sal\sbuilt\sin).\s\r\n1.\sThe\sTask\sManager\sin\sWindows\sXP\sshows\sthat\sCPU\s\r\nconsumption\s\r\nrises\sto\s50-60%.\s\s(Note\sthat\sif\sI\suse\sthe\ssame\sTcl/Tk\s\r\nlibraries\soutside\sof\sthe\scontext\sof\sa\sDirector\sxtra,\sno\s\r\nsuch\spenalty\soccurs.)\s\r\n2.\sI\sthen\sload\sthe\sxtra\sand\sdebugged\sversion\sof\sTcl/Tk\s\r\n8.4.9\s\r\ninto\sVC++.\s\sI\sset\sbreakpoints\sat\sTk_MainLoop,\s\r\nTcl_DoOneEvent­,\s\r\nand\sTcl_WaitForEvent.\s\r\n3.\sWhat\sI\sobserve\sis\sthat\safter\sinitialization,\sthe\sTcl\s\r\nthread\sessentially\sgoes\sinto\sa\spolling\smode\sin\swhich\s\r\nit\stries\sto\sprocess\sa\sWM_DEVICE_CHANGE\s(0x0219)\s\r\nmessage.\s\r\nThe\ssequence\sof\ssteps\sis\sthis\s(Note\sthat\sall\smessaging\s\r\nhere\sis\sdone\son\sthe\sthread;\sie,\sno\swindow\sis\sinvolved.):\s\r\n\r\n\r\n*\sTcl_DoOneEvent\sis\scalled.\s\r\n*\sTcl_WaitForEvent\sis\scalled.\s\r\n*\sPeekMessage\sis\scalled\sand\sfinds\sa\s\r\nWM_DEVICE_CHANGE\swith\s\r\nthe\swParam\sset\sto\sDBT_DEVNODES_CHANGED\s(0x0007).\s\r\n*\sGetMessage\sis\scalled\sand\sfinds\sthe\s\r\nWM_DEVICE_CHANGE\smsg.\s\r\n*\sTranslateMessage\sis\scalled\sand\sposts\sback\sthe\s\r\nWM_DEVICE_CHANGE\smsg\sto\sthe\smessaging\squeue\sfor\s\r\nthe\s\r\nthread.\s\r\n*\sDispatchMessage\sis\scalled\swith\sthe\s\r\nWM_DEVICE_CHANGE\smsg.\s\r\n\r\n\r\nAt\sthis\spoint,\sprogram\sexecution\sgoes\sback\sto\s\r\nTk_MainLoop,\sand\sthen\sTcl_DoOneEvent\sis\scalled\sand\s\r\nthe\swhole\ssequence\sof\ssteps\scontinues\sad\sinfinitum.\s\r\n\r\nNOTE:\sI\shave\sobserved\sthis\ssame\sbehavior\sfor\r\nan\sundefined\smessage\swith\sID\s0x0118.\s\sTo\scorrect\r\nthis\sinfinite\smessage-processing\sloop,\sI\sinserted\r\nthe\sfollowing\scode\sin\stcl8.4.9/win/tclWinNotify.c:\r\n\r\n\s\s\s\s\s\s\s\sresult\s=\sGetMessage(&msg,\sNULL,\s0,\s0);\r\n\s\s\s\s\s\s\s\swhile\s(msg.message\s==\sWM_DEVICECHANGE\s||\s\r\nmsg.message\s==\s0x0118)\s{\r\n\s\s\s\s\s\s\s\s\s\sresult\s=\sGetMessage(&msg,\sNULL,\s0,\s0);\r\n\s\s\s\s\s\s\s\s}\r\n\r\nThis\s"worked",\sin\sthe\ssense\sthat\ssaid\sinifinite\r\nprocessing\sloop\sno\slonger\soccurs.\r\n\r\nAlthough\sI'm\snot\ssure,\sI\sbelieve\sthat\slaunching\sa\sTcl\s\r\nthread\s\r\nin\sthis\smanner\striggers\sthe\sWM_DEVICE_CHANGE\s\r\nmessage,\sand\s\r\nthat\sthe\sTcl_DoOneEvent\sprocessing\slogic\sjust\sdoesn't\s\r\nhandle\s\r\nthis\scase\sgracefully.\s\sIE,\sthings\s"still\swork",\sbut\syou\s\r\nsacrifice\sa\shuge\samount\sof\sCPU\shorsepower\sin\sthe\s\r\nprocess.\s\r\n\r\nkodeCharlie
J icomment <tt>0x0118</tt>\sis\s“<a\shref="http://social.msdn.microsoft.com/Forums/vstudio/en-US/c0f9bac9-d211-4b8b-ba99-f5a0ed0d2e0a/what-is-wm-id-code-0x0118?forum=vclanguage">the\sundocumented\sWM_SYSTIMER,\swhich\sappears\sto\sbe\sused\sfor\scaret\sblinks</a>”.
J login dkf
J mimetype text/html
J severity Minor
J username dkf
K 1113452fffffffffffffffffffffffffffffffff
U dkf
Z fa3a39e23b8e246b5d15c511a4d06fae