GTK+ menu stock item support

Francesco Montorsi f18m_cpp217828 at yahoo.it
Tue Oct 3 15:19:01 PDT 2006


Robert Roebling ha scritto:
> Francesco Montorsi wrote:
> 
>> Robert Roebling ha scritto:
>>>  Hi,
>>>
>>> currently wxID_ABOUT causes
>>>
>>>  Gtk-CRITICAL **: file gtkstock.c: line 128 (gtk_stock_lookup):
>>> assertion `stock_id != NULL' failed
>>>
>>> when uses with my GTK+ 2.2.3. I haven't been able to 
>>> spot the cause quickly. Could the author of the patch
>>> look into that?
>> sure - could you just run that program with gdb, then "break g_log", run 
>> it and post the backtrace?
>> Also, is it coming from a wx sample?
>>
>> I've never seen such warning with my gtk 2.10...
>>
> 
> dataview sample from CVS:
> 
> (gdb) set args --g-fatal-warnings
> (gdb) r
> Starting program: /home/robert/wxNew/shared/samples/dataview/dataview
> --g-fatal-warnings
> [New Thread 16384 (LWP 27384)]
>  
> Gtk-CRITICAL **: file gtkstock.c: line 128 (gtk_stock_lookup): assertion
> `stock_id != NULL' failed
> aborting...
>  
> Program received signal SIGABRT, Aborted.
> [Switching to Thread 16384 (LWP 27384)]
> 0x40b39b71 in kill () from /lib/i686/libc.so.6
> (gdb) bt
> #0  0x40b39b71 in kill () from /lib/i686/libc.so.6
> #1  0x40ac7cf1 in pthread_kill () from /lib/i686/libpthread.so.0
> #2  0x40ac800b in raise () from /lib/i686/libpthread.so.0
> #3  0x40b39904 in raise () from /lib/i686/libc.so.6
> #4  0x40b3ae8c in abort () from /lib/i686/libc.so.6
> #5  0x408ea560 in g_logv () from /opt/gnome/lib/libglib-2.0.so.0
> #6  0x408ea592 in g_log () from /opt/gnome/lib/libglib-2.0.so.0
> #7  0x4062e326 in gtk_stock_lookup () from
> /opt/gnome/lib/libgtk-x11-2.0.so.0
> #8  0x402d6468 in wxGetStockGtkAccelerator(char const*,
> GdkModifierType*, unsigned*) ()
>    from ../../lib/libwx_gtk2u_core-2.7.so.0
> #9  0x40249522 in wxMenu::GtkAppend(wxMenuItem*, int) ()
>    from ../../lib/libwx_gtk2u_core-2.7.so.0
> #10 0x40249804 in wxMenu::DoAppend(wxMenuItem*) ()
>    from ../../lib/libwx_gtk2u_core-2.7.so.0
> #11 0x080533ef in MyFrame::MyFrame(wxFrame*, wchar_t*, int, int, int,
> int) ()
> #12 0x08051f53 in MyApp::OnInit() ()
> #13 0x0805b82f in wxAppConsole::CallOnInit() ()
> #14 0x404516ae in wxEntry(int&, wchar_t**) () from
> ../../lib/libwx_baseu-2.7.so.0
> #15 0x404517a1 in wxEntry(int&, char**) () from
> ../../lib/libwx_baseu-2.7.so.0
> #16 0x08051f17 in main ()
> (gdb)
thanks for the backtrace.

I think the following patch should be enough to fix that:

Index: src/common/stockitem.cpp
===================================================================
RCS file: /pack/cvsroots/wxwidgets/wxWidgets/src/common/stockitem.cpp,v
retrieving revision 1.21
diff -bu2 -r1.21 src/common/stockitem.cpp
--- src/common/stockitem.cpp
+++ src/common/stockitem.cpp
@@ -381,4 +381,7 @@
  bool wxGetStockGtkAccelerator(const char *id, GdkModifierType *mod, 
guint *key)
  {
+    if (!id)
+        return false;
+
      GtkStockItem stock_item;
      if (gtk_stock_lookup (id, &stock_item))


since wxGetStockGtkAccelerator return code is always checked by 
gtk\menu.cpp...

Francesco





More information about the wx-dev mailing list