summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArun Thondapu <arunkumar.thondapu@in.ibm.com>2012-08-24 16:57:00 +0530
committerArun Thondapu <arunkumar.thondapu@in.ibm.com>2012-08-27 19:10:40 +0530
commita3a1752d4cca52a10819bc086957df9ad04a0a87 (patch)
tree045212f6b92f7fc69c98fa67bd210cc1aba2ed72
parentd76702a2326c8925f4c372c75a6a780c55def417 (diff)
downloadeclipse.platform.swt-a3a1752d4cca52a10819bc086957df9ad04a0a87.tar.gz
eclipse.platform.swt-a3a1752d4cca52a10819bc086957df9ad04a0a87.tar.xz
eclipse.platform.swt-a3a1752d4cca52a10819bc086957df9ad04a0a87.zip
Bug 379792 Fix memory leak in Table/Tree
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Table.java17
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tree.java18
2 files changed, 26 insertions, 9 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Table.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Table.java
index 1b38aa9357..70e71fc6a9 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Table.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Table.java
@@ -541,8 +541,7 @@ void createColumn (TableColumn column, int index) {
}
}
OS.gtk_tree_view_set_model (handle, newModel);
- OS.g_object_unref (oldModel);
- modelHandle = newModel;
+ setModel (newModel);
}
}
int /*long*/ columnHandle = OS.gtk_tree_view_column_new ();
@@ -990,8 +989,7 @@ void destroyItem (TableColumn column) {
}
}
OS.gtk_tree_view_set_model (handle, newModel);
- OS.g_object_unref (oldModel);
- modelHandle = newModel;
+ setModel (newModel);
createColumn (null, 0);
} else {
for (int i=0; i<itemCount; i++) {
@@ -3092,6 +3090,17 @@ public void setLinesVisible (boolean show) {
}
}
+void setModel (int /*long*/ newModel) {
+ display.removeWidget (modelHandle);
+ OS.g_object_unref (modelHandle);
+ modelHandle = newModel;
+ display.addWidget (modelHandle, this);
+ if (fixAccessibility ()) {
+ OS.g_signal_connect_closure (modelHandle, OS.row_inserted, display.closures [ROW_INSERTED], true);
+ OS.g_signal_connect_closure (modelHandle, OS.row_deleted, display.closures [ROW_DELETED], true);
+ }
+}
+
void setOrientation (boolean create) {
super.setOrientation (create);
for (int i=0; i<itemCount; i++) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tree.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tree.java
index 5f2cb67736..c7b41569dc 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tree.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tree.java
@@ -646,8 +646,7 @@ void createColumn (TreeColumn column, int index) {
if (newModel == 0) error (SWT.ERROR_NO_HANDLES);
copyModel (oldModel, FIRST_COLUMN, newModel, FIRST_COLUMN, types, (int /*long*/)0, (int /*long*/)0, modelLength);
OS.gtk_tree_view_set_model (handle, newModel);
- OS.g_object_unref (oldModel);
- modelHandle = newModel;
+ setModel (newModel);
}
}
int /*long*/ columnHandle = OS.gtk_tree_view_column_new ();
@@ -994,10 +993,8 @@ void destroyItem (TreeColumn column) {
if (newModel == 0) error (SWT.ERROR_NO_HANDLES);
copyModel(oldModel, column.modelIndex, newModel, FIRST_COLUMN, types, (int /*long*/)0, (int /*long*/)0, FIRST_COLUMN + CELL_TYPES);
OS.gtk_tree_view_set_model (handle, newModel);
- OS.g_object_unref (oldModel);
- modelHandle = newModel;
+ setModel (newModel);
createColumn (null, 0);
-
} else {
for (int i=0; i<items.length; i++) {
TreeItem item = items [i];
@@ -3027,6 +3024,17 @@ public void setLinesVisible (boolean show) {
}
}
+void setModel (int /*long*/ newModel) {
+ display.removeWidget (modelHandle);
+ OS.g_object_unref (modelHandle);
+ modelHandle = newModel;
+ display.addWidget (modelHandle, this);
+ if (fixAccessibility ()) {
+ OS.g_signal_connect_closure (modelHandle, OS.row_inserted, display.closures [ROW_INSERTED], true);
+ OS.g_signal_connect_closure (modelHandle, OS.row_deleted, display.closures [ROW_DELETED], true);
+ }
+}
+
void setOrientation (boolean create) {
super.setOrientation (create);
if (items != null) {