[Gtk-sharp-list] RadioMenuItem Problems

Jeremiah McElroy jeremiah@facility9.com
Tue, 02 Mar 2004 12:03:54 -0500


I have a bit of code for a debug window that prints messages when they 
are at or below a certain logging threshold.  The threshold is set when 
the window is created, but I wanted to add functionality to change the 
threshold on the fly.

I have attempted to implement this using a menu containing 
RadioMenuItems that correspond to the various log levels.  However, when 
I close the DebugWindow (which is created by my main app) mono crashes 
with a System.NullReferenceException:

Unhandled Exception: System.NullReferenceException: A null value was 
found where an object instance was required
in (unmanaged) (wrapper managed-to-native) Gtk.Widget:gtk_widget_destroy 
(intptr)
in <0x00004> (wrapper managed-to-native) Gtk.Widget:gtk_widget_destroy 
(intptr)
in <0x0001f> Gtk.Widget:Destroy ()
in <0x0000e> SharpJab.DebugWindow:OnMenuCloseEvent (object,System.EventArgs)
in <0x0005a> (wrapper delegate-invoke) 
System.MulticastDelegate:invoke_void_object_EventArgs 
(object,System.EventArgs)
in <0x0012b> GtkSharp.voidObjectSignal:voidObjectCallback (intptr,int)
in <0x00030> (wrapper native-to-managed) 
GtkSharp.voidObjectSignal:voidObjectCallback (intptr,int)
in (unmanaged) (wrapper managed-to-native) Gtk.Application:gtk_main ()
in <0x00004> (wrapper managed-to-native) Gtk.Application:gtk_main ()
in <0x00007> Gtk.Application:Run ()
in <0x005cb> Projects.TestApp2:.ctor (string[])
in <0x00024> Projects.TestApp2:Main (string[])

Here is the code for creating the menu:

Menu LogLevelMenu = new Menu();
                                                                               
RadioMenuItem DebugItem   = new RadioMenuItem ("_Debug");
                                                                               
group = DebugItem.Group;
                                                                               
RadioMenuItem HighItem    = new RadioMenuItem (group, "_High");
RadioMenuItem NormalItem  = new RadioMenuItem (group, "_Normal");
RadioMenuItem MinimalItem = new RadioMenuItem (group, "_Minimal");
RadioMenuItem NoneItem    = new RadioMenuItem (group, "N_one");
                                                                               
LogLevelMenu.Append (DebugItem);
LogLevelMenu.Append (HighItem);
LogLevelMenu.Append (NormalItem);
LogLevelMenu.Append (MinimalItem);
LogLevelMenu.Append (NoneItem);
                                                                               
MenuItem LogLevelItem = new MenuItem ("_Log Level");
LogLevelItem.Submenu = LogLevelMenu;
                                                                               
MenuBar.Append (LogLevelItem);


Thanks in advance,

Jeremiah