Complete.Org: Mailing Lists: Archives: freeciv-dev: February 2004:
[Freeciv-Dev] Re: (PR#7499) problems with detachable panes
Home

[Freeciv-Dev] Re: (PR#7499) problems with detachable panes

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients: ;
Subject: [Freeciv-Dev] Re: (PR#7499) problems with detachable panes
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 24 Feb 2004 13:05:46 -0800
Reply-to: rt@xxxxxxxxxxx

<URL: http://rt.freeciv.org/Ticket/Display.html?id=7499 >

Vasco Alexandre da Silva Costa wrote:

> I think I know why the bug happens. The code used to draw directly to
> 'overview_canvas->window'. Now you copy the pointer to a struct, and use
> that pointer. But what if the pointer value in the original
> 'overview_canvas' was changed uh? Yep. Boom!

OK, so my idea for a fix is the ugliest.

Here's a partial implementation of Raimar's idea.  Every time the common 
code needs to know the window the GUI gives it.

I'm not entirely sure that this is better.  If we do use this, then we 
may eventually have to do the same thing for the mapview.  And of course 
we'll need support for the other GUIs before using it.

jason

? coasts.diff
Index: client/mapview_common.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/mapview_common.c,v
retrieving revision 1.80
diff -u -r1.80 mapview_common.c
--- client/mapview_common.c     2004/02/24 05:20:24     1.80
+++ client/mapview_common.c     2004/02/24 21:03:31
@@ -1645,7 +1645,7 @@
 **************************************************************************/
 static void redraw_overview(void)
 {
-  struct canvas_store *dest = overview.window;
+  struct canvas_store *dest = get_overview_window();
 
   if (!dest || !overview.store) {
     return;
Index: client/mapview_common.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/mapview_common.h,v
retrieving revision 1.45
diff -u -r1.45 mapview_common.h
--- client/mapview_common.h     2004/02/24 05:20:24     1.45
+++ client/mapview_common.h     2004/02/24 21:03:31
@@ -35,9 +35,6 @@
   int map_x0, map_y0;
   int width, height;           /* Size in pixels. */
   struct canvas_store *store;
-
-  /* The following fields are controlled by gui-.../mapview.c. */
-  struct canvas_store *window;
 };
 
 extern struct canvas mapview_canvas;
Index: client/gui-gtk-2.0/gui_main.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/gui_main.c,v
retrieving revision 1.66
diff -u -r1.66 gui_main.c
--- client/gui-gtk-2.0/gui_main.c       2004/02/18 02:20:51     1.66
+++ client/gui-gtk-2.0/gui_main.c       2004/02/24 21:03:32
@@ -1194,10 +1194,6 @@
 
   init_mapcanvas_and_overview();
 
-  overview.window = fc_malloc(sizeof(*overview.window));
-  overview.window->pixmap = overview_canvas->window;
-  overview.window->pixcomm = NULL;
-
   single_tile_pixmap = gdk_pixmap_new(root_window, 
                                      UNIT_TILE_WIDTH, UNIT_TILE_HEIGHT, -1);
 
Index: client/gui-gtk-2.0/mapview.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/mapview.c,v
retrieving revision 1.97
diff -u -r1.97 mapview.c
--- client/gui-gtk-2.0/mapview.c        2004/02/24 05:20:25     1.97
+++ client/gui-gtk-2.0/mapview.c        2004/02/24 21:03:32
@@ -455,6 +455,18 @@
 /**************************************************************************
 ...
 **************************************************************************/
+struct canvas_store *get_overview_window(void)
+{
+  static struct canvas_store store;
+
+  store.pixmap = overview_canvas->window;
+
+  return &store;
+}
+
+/**************************************************************************
+...
+**************************************************************************/
 gboolean overview_canvas_expose(GtkWidget *w, GdkEventExpose *ev, gpointer 
data)
 {
   if (!can_client_change_view()) {
Index: client/include/mapview_g.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/include/mapview_g.h,v
retrieving revision 1.44
diff -u -r1.44 mapview_g.h
--- client/include/mapview_g.h  2004/02/24 05:20:25     1.44
+++ client/include/mapview_g.h  2004/02/24 21:03:33
@@ -31,6 +31,7 @@
 void map_size_changed(void);
 struct canvas_store *canvas_store_create(int width, int height);
 void canvas_store_free(struct canvas_store *store);
+struct canvas_store *get_overview_window(void);
 
 void show_city_desc(struct city *pcity, int canvas_x, int canvas_y);
 void prepare_show_city_descriptions(void);

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