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

甜瓜 littlesweetmelon at gmail.com
Thu Jan 24 01:57:51 PST 2008


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:
void wxTaskBarIcon::RegisterWindowMessages()
{
    static bool s_registered = false;

    if ( !s_registered )
    {
        // Taskbar restart msg will be sent to us if the icon needs to
be redrawn
        gs_msgRestartTaskbar = RegisterWindowMessage(wxT("TaskbarCreated"));

        // Also register the taskbar message here
        gs_msgTaskbar = ::RegisterWindowMessage(wxT("wxTaskBarIconMessage"));

        s_registered = true;
    }
}

long wxTaskBarIcon::WindowProc(unsigned int msg,
                               unsigned int WXUNUSED(wParam),
                               long lParam)
{
    wxEventType eventType = 0;

    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);
    ....
}

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. 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?

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

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.

---
ShenLei


More information about the wxpython-users mailing list