[wxPython-user] Is this a bug in TaskBarIcon?

甜瓜 wrote:

Howdy all,
      I run my wxPython project in WinXP of different languages.
(python2.5, latest wxPython) It is a simply frame with a taskbar icon.
In some systems, without any user operation, explorer.exe will restart
itself frequently if my project resides to taskbar. I get the error
log:

Traceback (most recent call last):
  File "main.py", line 74, in CreatePopupMenu
  File "wx\_core.pyo", line 9015, in IsShown
wx._core.PyAssertionError: C++ assertion "msg == gs_msgTaskbar" failed
at ..\..\src\msw\taskbar.cpp(282) in wxTaskBarIcon::WindowProc()

The code is listed here:

[...]

My question is:
1. Why does wxTaskBarIcon register window message? MSDN says The
"RegisterWindowMessage function is typically used to register messages
for communicating between two cooperating applications. " but
wxTaskBarIcon is only used in a single process.

The "TaskbarCreated" message comes from explorer, so it is interprocess
in this case. The "wxTaskBarIconMessage" is obviously wx specific, and
is used internally to know how to direct other messages to the hidden
frame down to the icon's WinProc.

Furthermore, if there
are different wx projects, they will use the same MSG value because
they register MSG with same message name. Will they conflict with each
other?

This I don't know. You can ask about it on wx-dev.

2. In wxTaskBarIcon::WindowProc, it seems logically confused:
    if (msg == gs_msgRestartTaskbar) {...}
    wxASSERT(msg == gs_msgTaskbar); // maybe fail if msg ==
gs_msgRestartTaskbar

If it was gs_msgRestartTaskbar then it couldn't get to this line of code
because of the previous if statement. The function would already have
exited because of the return in that if statement.

3. What type of wxWidget library is used in wxPython? If using a
release mode library, why does the error log show
"wx._core.PyAssertionError: C++ assertion "msg == gs_msgTaskbar"? The
assert will becomes nothing in release mode.

The Windows binaries use what I call a "Hybrid Build" where the wx
asserts are still active but debug info is turned off and compiler
optimizations are turned on like in a release build. This allows the
programmers who are using the binaries to have the benefit of the C++
assertions being turned into Python exceptions without my having to
provide two sets of binaries. In most cases the runtime overhead of the
wx asserts is minor.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Thank you Robin! I learned a lot from you.

Again for question 2, below is a section of continuous code in wxWidget:
   if (msg == gs_msgRestartTaskbar) // does the icon need to be redrawn?
   {
       m_iconAdded = false;
       SetIcon(m_icon, m_strTooltip);
   }

   // this function should only be called for gs_msg(Restart)Taskbar messages
   wxASSERT(msg == gs_msgTaskbar);

I don't see a explicit return in if(...) { } statement... @_@

···

---
ShenLei