From 4e3026c63789e50855714015dbc8285c21d84a0b Mon Sep 17 00:00:00 2001 From: Sven Neumann Date: Sun, 2 Jan 2005 23:09:54 +0000 Subject: [PATCH] handle event time as guint32. That's the type we deal with here and it 2005-01-03 Sven Neumann * app/paint/gimpink.[ch]: handle event time as guint32. That's the type we deal with here and it avoids a crash that occured when autoscrolling with the Ink tool. * app/display/gimpdisplayshell-autoscroll.c: cosmetics. --- ChangeLog | 8 ++++ app/display/gimpdisplayshell-autoscroll.c | 54 ++++++++++++----------- app/paint/gimpink.c | 5 +-- app/paint/gimpink.h | 2 +- 4 files changed, 39 insertions(+), 30 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1488c05c24..fe73d30621 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2005-01-03 Sven Neumann + + * app/paint/gimpink.[ch]: handle event time as guint32. That's the + type we deal with here and it avoids a crash that occured when + autoscrolling with the Ink tool. + + * app/display/gimpdisplayshell-autoscroll.c: cosmetics. + 2005-01-02 Michael Natterer * app/display/Makefile.am diff --git a/app/display/gimpdisplayshell-autoscroll.c b/app/display/gimpdisplayshell-autoscroll.c index c3a503529b..5ff6e75d71 100644 --- a/app/display/gimpdisplayshell-autoscroll.c +++ b/app/display/gimpdisplayshell-autoscroll.c @@ -110,47 +110,49 @@ static gboolean gimp_display_shell_autoscroll_timeout (gpointer data) { GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (data); - GimpDisplay *gdisp = shell->gdisp; ScrollInfo *info = shell->scroll_info; GimpCoords device_coords; GimpCoords image_coords; - gint off_x = 0; - gint off_y = 0; + gint dx = 0; + gint dy = 0; - info->time += AUTOSCROLL_DT; - - gimp_display_shell_get_device_coords (shell, - info->device, &device_coords); + gimp_display_shell_get_device_coords (shell, info->device, &device_coords); if (device_coords.x < 0) - off_x = device_coords.x; + dx = device_coords.x; else if (device_coords.x > shell->disp_width) - off_x = device_coords.x - shell->disp_width; + dx = device_coords.x - shell->disp_width; if (device_coords.y < 0) - off_y = device_coords.y; + dy = device_coords.y; else if (device_coords.y > shell->disp_height) - off_y = device_coords.y - shell->disp_height; + dy = device_coords.y - shell->disp_height; - if (off_x == 0 && off_y == 0) + if (dx || dy) + { + GimpDisplay *gdisp = shell->gdisp; + + info->time += AUTOSCROLL_DT; + + gimp_display_shell_scroll (shell, + AUTOSCROLL_DX * (gdouble) dx, + AUTOSCROLL_DX * (gdouble) dy); + + gimp_display_shell_untransform_coords (shell, + &device_coords, &image_coords); + + tool_manager_motion_active (gdisp->gimage->gimp, + &image_coords, + info->time, info->state, + gdisp); + + return TRUE; + } + else { g_free (info); shell->scroll_info = NULL; return FALSE; } - - gimp_display_shell_scroll (shell, - AUTOSCROLL_DX * (gdouble) off_x, - AUTOSCROLL_DX * (gdouble) off_y); - - gimp_display_shell_untransform_coords (shell, - &device_coords, &image_coords); - - tool_manager_motion_active (gdisp->gimage->gimp, - &image_coords, - info->time, info->state, - gdisp); - - return TRUE; } diff --git a/app/paint/gimpink.c b/app/paint/gimpink.c index 23f97edc1a..c084a852b2 100644 --- a/app/paint/gimpink.c +++ b/app/paint/gimpink.c @@ -270,11 +270,10 @@ gimp_ink_motion (GimpPaintCore *paint_core, else { Blob *blob; - gdouble lasttime, thistime; gdouble dist; gdouble velocity; - - lasttime = ink->last_time; + guint32 lasttime = ink->last_time; + guint32 thistime; time_smoother_add (ink, time); thistime = ink->last_time = time_smoother_result (ink); diff --git a/app/paint/gimpink.h b/app/paint/gimpink.h index 54b2408409..26fe6d8251 100644 --- a/app/paint/gimpink.h +++ b/app/paint/gimpink.h @@ -54,7 +54,7 @@ struct _GimpInk guint32 ts_buffer[TIME_SMOOTHER_BUFFER]; gint ts_index; - gdouble last_time; /* previous time of a motion event */ + guint32 last_time; /* previous time of a motion event */ gdouble lastx, lasty; /* previous position of a motion event */ gboolean init_velocity;