[gtk+/touchscreens: 24/39] scrolledwindow: Don't crash on 0-sized motion buffer
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/touchscreens: 24/39] scrolledwindow: Don't crash on 0-sized motion buffer
- Date: Wed, 23 Nov 2011 23:11:43 +0000 (UTC)
commit 7015dfe5c35345b0af7b554ea0bbbcdaaa71829d
Author: Carlos Garnacho <carlosg gnome org>
Date: Tue Nov 1 12:49:18 2011 +0100
scrolledwindow: Don't crash on 0-sized motion buffer
gtk/gtkscrolledwindow.c | 26 ++++++++++++++++----------
1 files changed, 16 insertions(+), 10 deletions(-)
---
diff --git a/gtk/gtkscrolledwindow.c b/gtk/gtkscrolledwindow.c
index 9ca46ef..24480a8 100644
--- a/gtk/gtkscrolledwindow.c
+++ b/gtk/gtkscrolledwindow.c
@@ -2297,6 +2297,9 @@ motion_event_list_last (MotionEventList *motion_events)
{
guint n_motions = MIN (motion_events->len, motion_events->buffer->len);
+ if (n_motions == 0)
+ return NULL;
+
return &g_array_index (motion_events->buffer, MotionData, n_motions - 1);
}
@@ -2998,18 +3001,21 @@ gtk_scrolled_window_motion_notify_event (GtkWidget *widget,
motion = motion_event_list_last (&priv->motion_events);
- hadjustment = gtk_range_get_adjustment (GTK_RANGE (priv->hscrollbar));
- if (hadjustment)
+ if (motion)
{
- dx = (motion->x - event->x_root) + gtk_adjustment_get_value (hadjustment);
- gtk_adjustment_set_value (hadjustment, dx);
- }
+ hadjustment = gtk_range_get_adjustment (GTK_RANGE (priv->hscrollbar));
+ if (hadjustment)
+ {
+ dx = (motion->x - event->x_root) + gtk_adjustment_get_value (hadjustment);
+ gtk_adjustment_set_value (hadjustment, dx);
+ }
- vadjustment = gtk_range_get_adjustment (GTK_RANGE (priv->vscrollbar));
- if (vadjustment)
- {
- dy = (motion->y - event->y_root) + gtk_adjustment_get_value (vadjustment);
- gtk_adjustment_set_value (vadjustment, dy);
+ vadjustment = gtk_range_get_adjustment (GTK_RANGE (priv->vscrollbar));
+ if (vadjustment)
+ {
+ dy = (motion->y - event->y_root) + gtk_adjustment_get_value (vadjustment);
+ gtk_adjustment_set_value (vadjustment, dy);
+ }
}
motion = motion_event_list_append (&priv->motion_events);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]