question about multi gtk_main



Guys,

I use multi gtk_main call to do blocking on multi-window application.
However, I run into this situation:
Example:

Bring upWindow 1
gtk_main()                        //gtk main level 0
                 ----->Window 1 receive button signal call handle
function  Window1_B1
                                    Bring up Window 2
                                    gtk_main()                 //gtk
main level 1
                                             ---------> Window 2 receive
button signal call handle function Window2_B2

    Bring up Window 3

    gtk_main()                    //gtk main level 2

//--------Problem happens as the following:
First simplified the above chart

   gtk_main()    //level 0 for Window 1
            |-------> gtk_main() //level 1 for Window 2
                                            |-------->gtk_main() level 2
for Window 3

Now the active gtk_main loop is at level2.
The user push the close buttion in Window1 to close Window1.
All the window destroy functiones looks like this:
 OnWindowDestroy()
{
        if another window is up, call to destroy the child window
        gtk_quit_main();
}
What I then found is:  it happened like this: ( gtk_main() level2 is
active )
OnWindowDestroy()        //window1
{
            Destroying Window2()
            OnWindowDestroy()  //window 2
                                |------------->Detroying Window 3

   OnWindowDestroy()//window 3

             No more Window

             gtk_quit_main()

   //end OnDetroy window 3
                                  <-----------------|
                              gtk_quit_main ()
            //end of On Destroy window 2

           gtk_quit_main()
        //end of OnDestroy 1
}

Simplified above
gtk_main()    //level0
       |---->gtk_main()     //level 1
            |------>gtk_main()  //level 2
                                    gtk_main_quit()
                                    gtk_main_quit()   //DOES NOT WORK
As you can see the seconde gtk_main_quit, that is in OnWindowDestroy for
Window 2 Does not work.
gtk_main never goes back to level 0

How I can solve this??

Jiang





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]