Complete.Org: Mailing Lists: Archives: freeciv-dev: January 2005:
[Freeciv-Dev] (PR#11802) gui-xaw: crash while swithing tilesets
Home

[Freeciv-Dev] (PR#11802) gui-xaw: crash while swithing tilesets

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] (PR#11802) gui-xaw: crash while swithing tilesets
From: "Egor Vyscrebentsov" <evyscr@xxxxxxxxx>
Date: Mon, 24 Jan 2005 13:14:57 -0800
Reply-to: bugs@xxxxxxxxxxx

<URL: http://bugs.freeciv.org/Ticket/Display.html?id=11802 >

> [jdorje - Срд. Янв. 05 09:02:19 2005]:
> 
> Egor Vyscrebentsov wrote:
> > CVS S2_0, Xaw client.
> > When i'm swithing tilesets (trident to iso-trident or vice versa),
> > i get a civclient crash with X error.
>
> There is a tileset_changed() function in mapview.c where you can put 
> code that does any additional cleanups needed when switching tilesets. 
> Without knowing what the error is here I don't know what needs to go
> there.

Something like PR#10023.
Patch attached.

Thanks, evyscr
Index: client/gui-xaw/gui_main.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-xaw/gui_main.c,v
retrieving revision 1.95.2.3
diff -u -r1.95.2.3 gui_main.c
--- client/gui-xaw/gui_main.c   1 Dec 2004 22:14:52 -0000       1.95.2.3
+++ client/gui-xaw/gui_main.c   24 Jan 2005 21:07:28 -0000
@@ -80,6 +80,8 @@
 static int unit_ids[MAX_NUM_UNITS_BELOW];  
 
 static void setup_widgets(void);
+void fill_econ_label_pixmaps(void);
+void fill_unit_below_pixmaps(void);
 
 /**************************************************************************
 ...
@@ -440,14 +442,8 @@
   InitializeActions(app_context);
 
   /* Do this outside setup_widgets() so after tiles are loaded */
-  for(i=0;i<10;i++)  {
-    struct Sprite *s = i < 5 ? sprites.tax_science : sprites.tax_gold;
 
-    XtVaSetValues(econ_label[i], XtNbitmap,
-                 s->pixmap, NULL);
-    XtAddCallback(econ_label[i], XtNcallback, taxrates_callback,
-                 INT_TO_XTPOINTER(i));
-  }
+  fill_econ_label_pixmaps();
                
   XtAddCallback(map_horizontal_scrollbar, XtNjumpProc, 
                scrollbar_jump_callback, NULL);
@@ -468,10 +464,7 @@
 
   init_mapcanvas_and_overview();
 
-  for(i=0; i<num_units_below; i++)
-    unit_below_pixmap[i]=XCreatePixmap(display, XtWindow(overview_canvas), 
-                                      UNIT_TILE_WIDTH, UNIT_TILE_HEIGHT, 
-                                      display_depth);  
+  fill_unit_below_pixmaps();
 
   set_indicator_icons(0, 0, 0, 0);
 
@@ -888,3 +881,61 @@
     showing = FALSE;
   }
 }
+
+/**************************************************************************
+  Called to fill econ_label pixmaps (showing tax/lux/sci rates).
+
+  It may be called again if the tileset changes.
+**************************************************************************/
+void fill_econ_label_pixmaps(void)
+{
+  int i;
+  int econ_label_count = 10;
+
+  for(i = 0; i < econ_label_count; i++) {
+    struct Sprite *s = i < 5 ? sprites.tax_science : sprites.tax_gold;
+
+    XtVaSetValues(econ_label[i], XtNbitmap,
+                 s->pixmap, NULL);
+    XtAddCallback(econ_label[i], XtNcallback, taxrates_callback,
+                 INT_TO_XTPOINTER(i));
+  }
+}
+
+/**************************************************************************
+  Called to fill unit_below pixmaps. They are on the left of the
+  screen that shows all of the inactive units in the current tile.
+
+  It may be called again if the tileset changes.
+**************************************************************************/
+void fill_unit_below_pixmaps(void)
+{
+  long i;
+
+  for (i = 0; i < num_units_below; i++) {
+    unit_below_pixmap[i] = XCreatePixmap(display, XtWindow(overview_canvas),
+                                        UNIT_TILE_WIDTH, UNIT_TILE_HEIGHT,
+                                        display_depth);
+  }
+}
+
+/**************************************************************************
+  Called when the tileset is changed to reset indicators pixmaps.
+**************************************************************************/
+void reset_econ_label_pixmaps(void)
+{
+  fill_econ_label_pixmaps();
+}
+
+/**************************************************************************
+  Called when the tileset is changed to reset unit pixmaps.
+**************************************************************************/
+void reset_unit_below_pixmaps(void)
+{
+  long i;
+
+  for (i = 0; i < num_units_below; i++) {
+    XFreePixmap(display, unit_below_pixmap[i]);
+  }
+  fill_unit_below_pixmaps();
+}
Index: client/gui-xaw/gui_main.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-xaw/gui_main.h,v
retrieving revision 1.14.2.1
diff -u -r1.14.2.1 gui_main.h
--- client/gui-xaw/gui_main.h   1 Dec 2004 19:02:30 -0000       1.14.2.1
+++ client/gui-xaw/gui_main.h   24 Jan 2005 21:07:28 -0000
@@ -19,6 +19,8 @@
 
 void xaw_ui_exit(void);
 void main_show_info_popup(XEvent *event);
+void reset_econ_label_pixmaps(void);
+void reset_unit_below_pixmaps(void);
 
 extern Atom         wm_delete_window;
 extern Display     *display;
Index: client/gui-xaw/mapview.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-xaw/mapview.c,v
retrieving revision 1.182.2.4
diff -u -r1.182.2.4 mapview.c
--- client/gui-xaw/mapview.c    1 Dec 2004 19:02:30 -0000       1.182.2.4
+++ client/gui-xaw/mapview.c    24 Jan 2005 21:07:28 -0000
@@ -896,4 +896,7 @@
   /* Here you should do any necessary redraws (for instance, the city
    * dialogs usually need to be resized).
    */
+   reset_econ_label_pixmaps();
+   update_info_label();
+   reset_unit_below_pixmaps();
 }

[Prev in Thread] Current Thread [Next in Thread]