[gtk/matthiasc/for-master] gtk-demo: Fix a crash in the puzzle



commit cc878160bd2dc1fc4cc2c241fec6805c6dcb716d
Author: Matthias Clasen <mclasen redhat com>
Date:   Mon Jun 1 00:10:42 2020 -0400

    gtk-demo: Fix a crash in the puzzle
    
    Avoid a crash when clicking the refresh button
    after solving the puzzle.

 demos/gtk-demo/sliding_puzzle.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
---
diff --git a/demos/gtk-demo/sliding_puzzle.c b/demos/gtk-demo/sliding_puzzle.c
index 925d981764..c7897f2dfd 100644
--- a/demos/gtk-demo/sliding_puzzle.c
+++ b/demos/gtk-demo/sliding_puzzle.c
@@ -355,11 +355,16 @@ reshuffle (void)
 {
   GtkWidget *grid;
 
-  grid = gtk_aspect_frame_get_child (GTK_ASPECT_FRAME (frame));
   if (solved)
-    start_puzzle (puzzle);
+    {
+      start_puzzle (puzzle);
+      grid = gtk_aspect_frame_get_child (GTK_ASPECT_FRAME (frame));
+    }
   else
-    shuffle_puzzle (grid);
+    {
+      grid = gtk_aspect_frame_get_child (GTK_ASPECT_FRAME (frame));
+      shuffle_puzzle (grid);
+    }
   gtk_widget_grab_focus (grid);
 }
 


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