Changeset 824


Ignore:
Timestamp:
Aug 13, 2011, 10:05:51 PM (8 years ago)
Author:
sam
Message:

gtk: refactor the GtkGlArea handling so that it can be destroyed even if
we are not actually closing the whole application.

Location:
trunk/deushax/gtk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/deushax/gtk/editor.cpp

    r785 r824  
    2323#include "glmapview.h"
    2424
    25 static gboolean delayed_quit(GtkWidget *w, GdkEvent *e, void *data)
     25/* Closing the window does not quit directly, we must first make sure the
     26 * GL widget is destroyed cleanly. */
     27static gboolean close_window(GtkWidget *w, GdkEvent *e, void *data)
    2628{
    2729    (void)w;
    2830    (void)e;
    29     (void)data;
     31    GlMapView *glmapview = (GlMapView *)data;
     32    glmapview->Shutdown();
    3033    gtk_main_quit();
    31     return TRUE;
     34    return FALSE;
    3235}
    3336
     
    6366    gtk_widget_show_all(window);
    6467    gtk_signal_connect(GTK_OBJECT(window), "delete_event",
    65                        GTK_SIGNAL_FUNC(delayed_quit), NULL);
     68                       GTK_SIGNAL_FUNC(close_window), glmapview);
    6669    g_object_unref(G_OBJECT(builder));
    6770
  • trunk/deushax/gtk/glmapview.cpp

    r755 r824  
    2323  : hadj(GTK_ADJUSTMENT(gtk_builder_get_object(builder, "gl_hadj"))),
    2424    vadj(GTK_ADJUSTMENT(gtk_builder_get_object(builder, "gl_vadj"))),
    25     ticking(FALSE), panning(FALSE),
     25    ticking(FALSE), panning(FALSE), destroyed(FALSE),
    2626    mapviewer(0),
    2727    xpan(0.0), ypan(0.0)
     
    101101    if (Ticker::Finished())
    102102    {
     103        /* Release the hijacked exit sequence */
    103104        gtk_main_quit();
    104105        return FALSE;
     
    138139gboolean GlMapView::Shutdown()
    139140{
    140     CloseMap();
    141     Ticker::Shutdown();
    142     /* Hijack the exit process by adding another level of gtk_main */
    143     gtk_widget_set_sensitive(gtk_widget_get_toplevel(glarea), FALSE);
    144     gtk_main();
    145     return TRUE;
     141    if (!destroyed)
     142    {
     143        destroyed = TRUE;
     144        CloseMap();
     145        Ticker::Shutdown();
     146        gtk_widget_set_sensitive(gtk_widget_get_toplevel(glarea), FALSE);
     147        /* Hijack the exit sequence by adding another level of gtk_main */
     148        gtk_main();
     149    }
     150    return FALSE;
    146151}
    147152
  • trunk/deushax/gtk/glmapview.h

    r220 r824  
    1717    void LoadMap(char const *path);
    1818    void CloseMap();
     19    gboolean Shutdown();
    1920
    2021private:
     
    2223    gboolean IdleTick();
    2324    gboolean Setup();
    24     gboolean Shutdown();
    2525    gboolean Draw(GdkEventExpose *e);
    2626    void Scroll(double dx, double dy);
     
    4848    GtkAdjustment *hadj, *vadj;
    4949    GtkWidget *glarea;
    50     gboolean ticking, panning;
     50    gboolean ticking, panning, destroyed;
    5151
    5252    MapViewer *mapviewer;
Note: See TracChangeset for help on using the changeset viewer.