Re: Program suddenly quits after hiding Gtk::Window(Gtk::WINDOW_POPUP) (Attachment included)



2011-11-21 13:01, Phong Cao skrev:
Hello everybody,

I am writing a small media player that allows the users to click on Gtk::DrawingArea to switch to fullscreen() or unfullscreen() mode, as well as hide() or show() a popup window (which is used to put play/pause/stop/progress widgets on top to control the progress of the video)
- When the users do a double right-click, the main window will be fullscreen() or unfullscreen().
- If the users do a right-click, and the window is in fullscreen() mode, the popup window will be hide() or show().

However, whenever I switch to fullscreen() mode (which also show() the popup window), then right-click 3 times (hide(), show(), then hide() the popup window), the whole program suddenly quits. I dont know why this happens and whether this is because of me.

I already attached the source code of the program with this email. If you can please download and see what I did wrong. 

Just uncompress it & run `make` to compile. My program uses gtkmm-3.0

Thank you for reading my message! Have a good Thanksgiving!

Best regards,

--
Phong V. Cao
You need one Gtk::Main::run(d_popup_win) for each d_popup_win.hide(), otherwise the main loop that was started by Gtk::Main::run(topwin) in main.cc ends. Add a line in TopWin::onDrawingAreaClicked:

else if ((event->type == GDK_BUTTON_PRESS) && (event->button == 3)) {
    if (is_fullscreen) {
    // if we are in fullscreen mode...
   
      if (is_hide) {
        // ...and d_popup_win is hidden then show d_popup_win
        d_popup_win.show();
        is_hide = false;

      Gtk::Main::run(d_popup_win); // !!! added
      }

A question that you don't have to answer: Are you really sure you don't want to use a Gtk::Dialog instead?

Kjell Ahlstedt


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