[gnumeric] Timers: type is guint, not gint.



commit 6e5118cad1e78a9712fc591451e9450a8696340a
Author: Morten Welinder <terra gnome org>
Date:   Wed Apr 24 09:24:03 2013 -0400

    Timers: type is guint, not gint.
    
    And (guint)-1 is a valid timer tag that glib can and will return.

 ChangeLog                         |   18 ++++++++++++++++++
 NEWS                              |    1 +
 src/application.c                 |    6 +++---
 src/gnm-pane-impl.h               |    2 +-
 src/gnm-pane.c                    |   17 ++++++++---------
 src/item-cursor.c                 |   10 +++++-----
 src/item-edit.c                   |    8 ++++----
 src/sheet-control-gui.c           |   24 ++++++++++++------------
 src/wbc-gtk-impl.h                |    2 +-
 src/widgets/gnm-cell-combo-view.c |    6 +++---
 10 files changed, 56 insertions(+), 38 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 20950ef..a75b2f8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,21 @@
+2013-04-24  Morten Welinder  <terra gnome org>
+
+       * src/sheet-control-gui.c (scg_init): Ditto comment.timer and
+       delayedMovement.timer.
+
+       * src/item-cursor.c (gnm_item_cursor_init): Ditto
+       animation_cursor.
+
+       * src/application.c (_gnm_app_flag_windows_changed): Ditto for
+       windows_update_timer.
+
+       * src/item-edit.c (GnmItemEdit): change type of blink_timer to
+       guint to match glib.  Use 0 as undefined since (guint)-1 is a
+       valid tag.
+
+       * src/gnm-pane.c (gnm_pane_init): Ditto sliding_timer (nee
+       sliding).
+
 2013-04-23  Morten Welinder  <terra gnome org>
 
        * src/mstyle.c (gnm_style_link_dependents): Fix segfault.
diff --git a/NEWS b/NEWS
index ece2d0f..f50366a 100644
--- a/NEWS
+++ b/NEWS
@@ -68,6 +68,7 @@ Morten:
        * Improve handling of broken xls.  [#698424]
        * Fix failed-read focus problem.  [#625687]
        * Fix critical.  [#698680]
+       * Fix type problems with glib timers.
 
 --------------------------------------------------------------------------
 Gnumeric 1.12.1
diff --git a/src/application.c b/src/application.c
index c1977ce..b11a5be 100644
--- a/src/application.c
+++ b/src/application.c
@@ -1545,13 +1545,13 @@ gnm_app_foreach_extra_ui (GFunc func, gpointer data)
 
 /**********************************************************************/
 
-static gint windows_update_timer = -1;
+static gint windows_update_timer = 0;
 static gboolean
 cb_flag_windows_changed (void)
 {
        if (app)
                g_signal_emit (G_OBJECT (app), signals[WINDOW_LIST_CHANGED], 0);
-       windows_update_timer = -1;
+       windows_update_timer = 0;
        return FALSE;
 }
 
@@ -1563,7 +1563,7 @@ cb_flag_windows_changed (void)
 void
 _gnm_app_flag_windows_changed (void)
 {
-       if (windows_update_timer < 0)
+       if (windows_update_timer == 0)
                windows_update_timer = g_timeout_add (100,
                        (GSourceFunc)cb_flag_windows_changed, NULL);
 }
diff --git a/src/gnm-pane-impl.h b/src/gnm-pane-impl.h
index 52a7d77..c304681 100644
--- a/src/gnm-pane-impl.h
+++ b/src/gnm-pane-impl.h
@@ -28,7 +28,7 @@ struct _GnmPane {
        /* Sliding scroll */
        GnmPaneSlideHandler slide_handler;
        gpointer   slide_data;
-       int        sliding;     /* a gtk_timeout tag, -1 means not set */
+       guint      sliding_timer;       /* a gtk_timeout tag, 0 means not set */
        int        sliding_x, sliding_y;
        int        sliding_dx, sliding_dy;
        gboolean   sliding_adjacent_h, sliding_adjacent_v;
diff --git a/src/gnm-pane.c b/src/gnm-pane.c
index c5b31e5..91290fe 100644
--- a/src/gnm-pane.c
+++ b/src/gnm-pane.c
@@ -919,7 +919,7 @@ gnm_pane_init (GnmPane *pane)
 
        pane->slide_handler = NULL;
        pane->slide_data = NULL;
-       pane->sliding = -1;
+       pane->sliding_timer = 0;
        pane->sliding_x  = pane->sliding_dx = -1;
        pane->sliding_y  = pane->sliding_dy = -1;
        pane->sliding_adjacent_h = pane->sliding_adjacent_v = FALSE;
@@ -1525,13 +1525,13 @@ gnm_pane_redraw_range (GnmPane *pane, GnmRange const *r)
 void
 gnm_pane_slide_stop (GnmPane *pane)
 {
-       if (pane->sliding == -1)
+       if (pane->sliding_timer == 0)
                return;
 
-       g_source_remove (pane->sliding);
+       g_source_remove (pane->sliding_timer);
        pane->slide_handler = NULL;
        pane->slide_data = NULL;
-       pane->sliding = -1;
+       pane->sliding_timer = 0;
 }
 
 static int
@@ -1716,9 +1716,8 @@ cb_pane_sliding (GnmPane *pane)
 
        if (!slide_x && !slide_y)
                gnm_pane_slide_stop (pane);
-       else if (pane->sliding == -1)
-               pane->sliding = g_timeout_add (
-                                              300, (GSourceFunc) cb_pane_sliding, pane);
+       else if (pane->sliding_timer == 0)
+               pane->sliding_timer = g_timeout_add (300, (GSourceFunc)cb_pane_sliding, pane);
 
        return TRUE;
 }
@@ -1852,7 +1851,7 @@ gnm_pane_handle_motion (GnmPane *pane,
        pane->slide_handler = slide_handler;
        pane->slide_data = user_data;
 
-       if (pane->sliding == -1)
+       if (pane->sliding_timer == 0)
                cb_pane_sliding (pane);
        return FALSE;
 }
@@ -1969,7 +1968,7 @@ gnm_pane_object_autoscroll (GnmPane *pane, GdkDragContext *context,
        pane->slide_data    = NULL;
        pane->sliding_x     = x;
        pane->sliding_y     = y;
-       if (pane->sliding == -1)
+       if (pane->sliding_timer == 0)
                cb_pane_sliding (pane);
 }
 
diff --git a/src/item-cursor.c b/src/item-cursor.c
index c6ce8bc..208be1e 100644
--- a/src/item-cursor.c
+++ b/src/item-cursor.c
@@ -59,7 +59,7 @@ struct _GnmItemCursor {
 
        GnmItemCursorStyle style;
        int      state;
-       int      animation_timer;
+       guint    animation_timer;
 
        /*
         * For the autofill mode:
@@ -173,7 +173,7 @@ item_cursor_realize (GocItem *item)
        ic_reload_style (ic);
 
        if (ic->style == GNM_ITEM_CURSOR_ANTED) {
-               g_return_if_fail (ic->animation_timer == -1);
+               g_return_if_fail (ic->animation_timer == 0);
                ic->animation_timer = g_timeout_add (
                        150, (GSourceFunc) cb_item_cursor_animation,
                        ic);
@@ -185,9 +185,9 @@ item_cursor_unrealize (GocItem *item)
 {
        GnmItemCursor *ic = GNM_ITEM_CURSOR (item);
 
-       if (ic->animation_timer != -1) {
+       if (ic->animation_timer != 0) {
                g_source_remove (ic->animation_timer);
-               ic->animation_timer = -1;
+               ic->animation_timer = 0;
        }
 
        parent_class->unrealize (item);
@@ -1507,7 +1507,7 @@ gnm_item_cursor_init (GnmItemCursor *ic)
 
        ic->style = GNM_ITEM_CURSOR_SELECTION;
        ic->state = 0;
-       ic->animation_timer = -1;
+       ic->animation_timer = 0;
 
        ic->visible = TRUE;
        ic->auto_fill_handle_at_top = FALSE;
diff --git a/src/item-edit.c b/src/item-edit.c
index 1bc3dea..58c6e30 100644
--- a/src/item-edit.c
+++ b/src/item-edit.c
@@ -54,7 +54,7 @@ struct _GnmItemEdit {
        /* Where are we */
        GnmCellPos pos;
        gboolean   cursor_visible;
-       int        blink_timer;
+       guint      blink_timer;
        int        sel_start;
 
        GnmFont   *gfont;
@@ -568,9 +568,9 @@ cb_item_edit_cursor_blink (GnmItemEdit *ie)
 static void
 item_edit_cursor_blink_stop (GnmItemEdit *ie)
 {
-       if (ie->blink_timer != -1) {
+       if (ie->blink_timer != 0) {
                g_source_remove (ie->blink_timer);
-               ie->blink_timer = -1;
+               ie->blink_timer = 0;
        }
 }
 
@@ -693,7 +693,7 @@ gnm_item_edit_init (GnmItemEdit *ie)
        ie->style      = NULL;
        ie->cursor_visible = TRUE;
        ie->sel_start = -1;
-       ie->blink_timer = -1;
+       ie->blink_timer = 0;
 }
 
 static void
diff --git a/src/sheet-control-gui.c b/src/sheet-control-gui.c
index 643f72b..bfb492a 100644
--- a/src/sheet-control-gui.c
+++ b/src/sheet-control-gui.c
@@ -710,9 +710,9 @@ scg_init (SheetControlGUI *scg)
 {
        scg->comment.selected = NULL;
        scg->comment.item = NULL;
-       scg->comment.timer = -1;
+       scg->comment.timer = 0;
 
-       scg->delayedMovement.timer = -1;
+       scg->delayedMovement.timer = 0;
        scg->delayedMovement.handler = NULL;
 
        scg->grab_stack = 0;
@@ -1733,9 +1733,9 @@ sheet_control_gui_new (SheetView *sv, WBCGtk *wbcg)
 static void
 scg_comment_timer_clear (SheetControlGUI *scg)
 {
-       if (scg->comment.timer != -1) {
+       if (scg->comment.timer != 0) {
                g_source_remove (scg->comment.timer);
-               scg->comment.timer = -1;
+               scg->comment.timer = 0;
        }
 }
 
@@ -1763,9 +1763,9 @@ scg_finalize (GObject *object)
 
        scg_comment_timer_clear (scg);
 
-       if (scg->delayedMovement.timer != -1) {
+       if (scg->delayedMovement.timer != 0) {
                g_source_remove (scg->delayedMovement.timer);
-               scg->delayedMovement.timer = -1;
+               scg->delayedMovement.timer = 0;
        }
        scg_comment_unselect (scg, scg->comment.selected);
 
@@ -3081,9 +3081,9 @@ static gint
 cb_cell_comment_timer (SheetControlGUI *scg)
 {
        g_return_val_if_fail (IS_SHEET_CONTROL_GUI (scg), FALSE);
-       g_return_val_if_fail (scg->comment.timer != -1, FALSE);
+       g_return_val_if_fail (scg->comment.timer != 0, FALSE);
 
-       scg->comment.timer = -1;
+       scg->comment.timer = 0;
        scg_comment_display (scg, scg->comment.selected,
                             scg->comment.x, scg->comment.y);
        return FALSE;
@@ -3104,7 +3104,7 @@ scg_comment_select (SheetControlGUI *scg, GnmComment *cc, int x, int y)
        if (scg->comment.selected != NULL)
                scg_comment_unselect (scg, scg->comment.selected);
 
-       g_return_if_fail (scg->comment.timer == -1);
+       g_return_if_fail (scg->comment.timer == 0);
 
        scg->comment.selected = cc;
        scg->comment.timer = g_timeout_add (1000,
@@ -3671,7 +3671,7 @@ static gint
 cb_scg_queued_movement (SheetControlGUI *scg)
 {
        Sheet const *sheet = scg_sheet (scg);
-       scg->delayedMovement.timer = -1;
+       scg->delayedMovement.timer = 0;
        (*scg->delayedMovement.handler) (scg,
                scg->delayedMovement.n, FALSE,
                scg->delayedMovement.horiz);
@@ -3701,7 +3701,7 @@ scg_queue_movement (SheetControlGUI       *scg,
        g_return_if_fail (IS_SHEET_CONTROL_GUI (scg));
 
        /* do we need to flush a pending movement */
-       if (scg->delayedMovement.timer != -1) {
+       if (scg->delayedMovement.timer != 0) {
                if (jump ||
                    /* do not skip more than 3 requests at a time */
                    scg->delayedMovement.counter > 3 ||
@@ -3712,7 +3712,7 @@ scg_queue_movement (SheetControlGUI       *scg,
                                scg->delayedMovement.n, FALSE,
                                scg->delayedMovement.horiz);
                        scg->delayedMovement.handler = NULL;
-                       scg->delayedMovement.timer = -1;
+                       scg->delayedMovement.timer = 0;
                } else {
                        scg->delayedMovement.counter++;
                        scg->delayedMovement.n += n;
diff --git a/src/wbc-gtk-impl.h b/src/wbc-gtk-impl.h
index c8c581b..2c974de 100644
--- a/src/wbc-gtk-impl.h
+++ b/src/wbc-gtk-impl.h
@@ -86,7 +86,7 @@ struct _WBCGtk {
        /* Autosave */
         gboolean   autosave_prompt;
         gint       autosave_time;
-        gint       autosave_timer;
+        guint      autosave_timer;
 
        PangoFontDescription *font_desc;
 
diff --git a/src/widgets/gnm-cell-combo-view.c b/src/widgets/gnm-cell-combo-view.c
index 1a862a3..88a14ab 100644
--- a/src/widgets/gnm-cell-combo-view.c
+++ b/src/widgets/gnm-cell-combo-view.c
@@ -128,13 +128,13 @@ ccombo_autoscroll_set (GObject *list, int dir)
        gpointer id = g_object_get_data (list, AUTOSCROLL_ID);
        if (id == NULL) {
                if (dir != 0) {
-                       int timer_id = g_timeout_add (50,
+                       guint timer_id = g_timeout_add (50,
                                (GSourceFunc)cb_ccombo_autoscroll, list);
                        g_object_set_data (list, AUTOSCROLL_ID,
-                               GINT_TO_POINTER (timer_id));
+                               GUINT_TO_POINTER (timer_id));
                }
        } else if (dir == 0) {
-               g_source_remove (GPOINTER_TO_INT (id));
+               g_source_remove (GPOINTER_TO_UINT (id));
                g_object_set_data (list, AUTOSCROLL_ID, NULL);
        }
        g_object_set_data (list, AUTOSCROLL_DIR, GINT_TO_POINTER (dir));


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