[dia/dia-0-97] grid-object: avoid crash on shrink
- From: Hans Breuer <hans src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [dia/dia-0-97] grid-object: avoid crash on shrink
- Date: Sat, 23 Jun 2012 13:56:18 +0000 (UTC)
commit ae8bcaa703197d090c0c746c54289ddcc6bbbbb1
Author: Hans Breuer <hans breuer org>
Date: Thu Oct 7 13:21:16 2010 +0200
grid-object: avoid crash on shrink
Fix some confusion about rows/columns using the wrong limits.
Resizing object::connections was too early.
(cherry picked from commit cddd958b71a4075751ab76ac3530ced3c33972ea)
objects/Misc/grid_object.c | 13 +++++++------
1 files changed, 7 insertions(+), 6 deletions(-)
---
diff --git a/objects/Misc/grid_object.c b/objects/Misc/grid_object.c
index 05d1b16..11dca8b 100644
--- a/objects/Misc/grid_object.c
+++ b/objects/Misc/grid_object.c
@@ -460,12 +460,6 @@ grid_object_reallocate_cells (Grid_Object* grid_object)
if (old_rows == new_rows && old_cols == new_cols)
return; /* no reallocation necessary */
- /* obj->connections doesn't own the pointers, so just realloc; values
- * will be updated later */
- obj->num_connections = GRID_OBJECT_BASE_CONNECTION_POINTS + new_rows*new_cols;
- obj->connections = (ConnectionPoint **) g_realloc(obj->connections,
- obj->num_connections * sizeof(ConnectionPoint *));
-
/* If either new dimension is smaller, some connpoints will have to
* be disconnected before reallocating */
@@ -485,6 +479,13 @@ grid_object_reallocate_cells (Grid_Object* grid_object)
object_remove_connections_to(&grid_object->cells[cell]);
}
+ /* must be done after disconnecting */
+ /* obj->connections doesn't own the pointers, so just realloc; values
+ * will be updated later */
+ obj->num_connections = GRID_OBJECT_BASE_CONNECTION_POINTS + new_rows*new_cols;
+ obj->connections = (ConnectionPoint **) g_realloc(obj->connections,
+ obj->num_connections * sizeof(ConnectionPoint *));
+
/* Can't use realloc; if grid has different dims, memory lays out
* differently. Must copy by hand. */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]