Advice: Don't use MessageBox() for temporary debugging output or pausing
Tor Lillqvist
tml at iki.fi
Thu Aug 13 08:00:12 PDT 2015
This might be obvious to some, but it wasn't to me.
If you are hacking on vcl, for Windows, do not add MessageBox() calls. (You
might want to do it either to get debugging output more visible than a
SAL_DEBUG(), or to make the execution pause until you press the OK button
so that you have time to attach the process in Visual Studio, for instance.)
MessageBox() runs its own message loop, and for some reason that will cause
our SalComWndProcW() window procedure to be called, and that might cause
timers to fire, and the code timers invoke might have fun side effects.
For instance, zeroing out the mpGraphics member of a Window object. (See
the "// steal the wingraphics from the other outdev" code in
Window::AcquireGraphics().)
This will wreak havoc on code that otherwise works fine as soon as you
comment out the MessageBox() call and let it run at its normal pace.
Instead, if you need to make execution stop at some point until you have
time to attach the debugger, for instance use some "volatile int foo=1;
while (foo);" type of thing, and once you have the process attached, break
it, set foo to zero, and continue. Or Sleep(10000). Etc.
--tml
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/libreoffice/attachments/20150813/2f4f2e28/attachment.html>
More information about the LibreOffice
mailing list