[Gtk-sharp-list] Still can't show config dialog, but can show anything else

Aaron Oxford aaron at hardwarehookups.com.au
Sat May 12 01:42:30 EDT 2007


Hi again,

As promised, here is a modified test program demonstrating the 
timer/dialog lockup. The expected behaviour is to see the main window 
pop up, then be obscured by a dialog saying 'testing testing 1 2 3', 
which in turn is partially obscured by a blank dialog. The app will 
then freeze, and after a while Windows will unblock it and let you kill it.

The desired behaviour is to see the second dialog, full of 'the quick 
brown fox jumped over the lazy dog', and to be able to close all 
three windows and exit the program.

Hope you're enjoying your weekend.

Aaron.

------------------------------------------

using System;
using Gtk;
using Gdk;

public class Test
{
     private Label label = null;
     private int counter = 0;
     private bool configurationFailed = false;
     private Gtk.Window wnd;

     // Create the window.
     public static void Main()
     {
         if (!GLib.Thread.Supported) GLib.Thread.Init();
         Gdk.Threads.Init();
         Gdk.Threads.Enter();

         Application.Init();

         Test t = new Test();

         GLib.Timeout.Add(100, new GLib.TimeoutHandler(t.Tick));

         t.showMessage("testing testing 1 2 3");

         Application.Run();
         Gdk.Threads.Leave();
     }

     // This is our window.
     public Test()
     {
         wnd = new Gtk.Window("Test");
         wnd.Destroyed += new EventHandler(wnd_Destroyed);

         // Ladida, Gtk# is cool...
         VBox vbox = new VBox();
         label = new Label(counter.ToString());
         vbox.PackStart(label, false, false, 0);
         wnd.Add(vbox);
         wnd.ShowAll();

         // ...and then for some reason:
         // (this line invokes the timer based popup).
         configurationFailed = true;
     }

     // Timer function.
     private bool Tick()
     {
         if (configurationFailed)
         {
             // ...during a timer (ie AFTER Gtk starts)
             string s = "the quick brown fox jumped over the lazy dog. ";
             s += s;
             s += s;
             s += s;
             s += s;
             s += s;

             showMessage(s);  // <-- Crash right here.

             configurationFailed = false;
         }
         label.Text = "" + counter;
         counter++;
         return true;
     }



     // Show a dialog.
     private void showMessage(string p)
     {
         Gtk.Dialog dlg = new Dialog("caption", wnd, DialogFlags.Modal);
         dlg.AddButton(Gtk.Stock.Ok, Gtk.ResponseType.Ok);
         dlg.DefaultResponse = Gtk.ResponseType.Ok;
         ScrolledWindow sw = new ScrolledWindow();
         Label l = new Label(p);
         l.WidthRequest = 285;
         l.Wrap = true;
         sw.AddWithViewport(l);
         dlg.VBox.PackStart(sw);
         dlg.SetDefaultSize(320, 160);

         dlg.ShowAll();
         dlg.Run();
         dlg.Destroy();
     }

     // Close program.
     void wnd_Destroyed(object sender, EventArgs e)
     {
         Application.Quit();
     }
}

---------------------------------------------------------------------------------
Aaron Oxford   -   aaron+hardwarehookups .com .au
Director, Innovative Computer Solutions (Aust) Pty. Ltd.
49 Maitland Rd, Mayfield, NSW 2304 Australia
http://www.ic-solutions.com.au
Developer, SourceForge project VioLet Composer
http://sourceforge.net/projects/buzz-like



More information about the Gtk-sharp-list mailing list