[Mono-list] Re: Gtk.TreeStore crashes the GTK mainloop

Haakon Nilsen haakonn@gmail.com
Thu, 5 Aug 2004 20:15:17 +0200

Well, I've received no hints so far, and today I found yet another
situation that would trigger the GTK mainloop to exit with a
NullReferenceException, exactly the way I described in the first mail.
I found that what triggered thisone was some code that updates the GUI
as a Gtk.ThreadNotify delegate, but I have no idea _why_ it happens.
The delegate does its job, but somewhere in between the calls to it,
the mainloop crashes, and only the thread lives on. When that
finishes, the application is shut down.

So with two different situations that triggers this crash, I suspect
I'm facing a whole class of triggering situations.

Anyway, I was able to conjure up a horrible hack to prevent the
shutdown and allow the application to hum along as if nothing had
happened. Instead of simply calling Application.Run to start things
up, I call this MainLoop instead:

      private void MainLoop () {
         try {
         } catch (NullReferenceException e) {
            MainLoop ();

Assuming mcs flattens out tail recursion, this should never overflow the stack.

So there. Now you can NullReference me all you want, evil
ghost-in-the-code. I win.