gnome-panel r10973 - trunk/applets/clock



Author: vuntz
Date: Wed Apr  2 17:22:11 2008
New Revision: 10973
URL: http://svn.gnome.org/viewvc/gnome-panel?rev=10973&view=rev

Log:
2008-04-02  Vincent Untz  <vuntz gnome org>

	Fix crash when closing the clock window while a city is blinking on the
	map. Fix bug #519493.
	Also improve things a bit if you click quickly on two cities.

	* clock-map.c: (clock_map_init): add a timeout id for the blinking
	(clock_map_finalize): stop blinking. This fixes the crash
	(highlight): simplify a bit because of the destroy handler
	(highlight_destroy): new, destroy handler for the timeout
	(clock_map_blink_location): if there was already something blinking,
	stop it first. Add a destroy handler for the timeout.


Modified:
   trunk/applets/clock/ChangeLog
   trunk/applets/clock/clock-map.c

Modified: trunk/applets/clock/clock-map.c
==============================================================================
--- trunk/applets/clock/clock-map.c	(original)
+++ trunk/applets/clock/clock-map.c	Wed Apr  2 17:22:11 2008
@@ -28,6 +28,8 @@
         gint width;
         gint height;
 
+	guint highlight_timeout_id;
+
         GdkPixbuf *stock_map_pixbuf;
         GdkPixbuf *location_marker_pixbuf[3];
 
@@ -121,6 +123,7 @@
 
 	GTK_WIDGET_SET_FLAGS (this, GTK_NO_WINDOW);
 
+	priv->highlight_timeout_id = 0;
         priv->stock_map_pixbuf = NULL;
         priv->location_marker_pixbuf[0] = NULL;
         priv->location_marker_pixbuf[1] = NULL;
@@ -133,6 +136,11 @@
         ClockMapPrivate *priv = PRIVATE (g_obj);
 	int i;
 
+	if (priv->highlight_timeout_id) {
+		g_source_remove (priv->highlight_timeout_id);
+		priv->highlight_timeout_id = 0;
+	}
+
         if (priv->stock_map_pixbuf) {
                 gdk_pixbuf_unref (priv->stock_map_pixbuf);
                 priv->stock_map_pixbuf = NULL;
@@ -661,11 +669,8 @@
 {
        BlinkData *data = user_data;
 
-       if (data->count == 6) {
-	       g_object_unref (data->location);
-               g_free (data);
+       if (data->count == 6)
                return FALSE;
-       }
 
        if (data->count % 2 == 0)
                  clock_map_place_location (data->map, data->location, TRUE);
@@ -680,10 +685,26 @@
        return TRUE;
 }
 
+static void
+highlight_destroy (gpointer user_data)
+{
+       BlinkData *data = user_data;
+       ClockMapPrivate *priv;
+
+       priv = PRIVATE (data->map);
+       priv->highlight_timeout_id = 0;
+
+       g_object_unref (data->location);
+       g_free (data);
+}
+
 void
 clock_map_blink_location (ClockMap *this, ClockLocation *loc)
 {
        BlinkData *data;
+       ClockMapPrivate *priv;
+
+       priv = PRIVATE (this);
 
        g_return_if_fail (IS_CLOCK_MAP (this));
        g_return_if_fail (IS_CLOCK_LOCATION (loc));
@@ -692,9 +713,16 @@
        data->map = this;
        data->location = g_object_ref (loc);
 
+       if (priv->highlight_timeout_id) {
+	       g_source_remove (priv->highlight_timeout_id);
+	       clock_map_place_locations (this);
+       }
+
        highlight (data);
 
-       g_timeout_add (300, highlight, data);
+       priv->highlight_timeout_id = g_timeout_add_full (G_PRIORITY_DEFAULT_IDLE,
+							300, highlight, data,
+							highlight_destroy);
 }
 
 static gboolean



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