summaryrefslogtreecommitdiffstats
path: root/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt
diff options
context:
space:
mode:
authorFelipe Heidrich <felipe_heidrich@ca.ibm.com>2011-12-05 17:30:21 -0500
committerFelipe Heidrich <felipe_heidrich@ca.ibm.com>2011-12-05 17:30:21 -0500
commit399668ec62007974ac5ae7cf065fd3ab7640c5d3 (patch)
tree4ea2c715c783a0f51e66fca6ceb240cc250448df /bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt
parente0e004ceb02d4870eb82258243938757bd2367dc (diff)
downloadeclipse.platform.swt-399668ec62007974ac5ae7cf065fd3ab7640c5d3.tar.gz
eclipse.platform.swt-399668ec62007974ac5ae7cf065fd3ab7640c5d3.tar.xz
eclipse.platform.swt-399668ec62007974ac5ae7cf065fd3ab7640c5d3.zip
Revert "364593 - Memory leak in Table when changing cell background colors"
This reverts commit e0e004ceb02d4870eb82258243938757bd2367dc.
Diffstat (limited to 'bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt')
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Table.java32
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TableItem.java5
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tree.java33
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TreeItem.java5
4 files changed, 5 insertions, 70 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 90ff9f4852..7b38bd8312 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
@@ -229,7 +229,6 @@ int /*long*/ cellDataProc (int /*long*/ tree_column, int /*long*/ cell, int /*lo
if (isPixbuf) {
OS.gtk_tree_model_get (tree_model, iter, modelIndex + CELL_PIXBUF, ptr, -1);
OS.g_object_set (cell, OS.pixbuf, ptr [0], 0);
- OS.g_object_unref (ptr [0]);
} else {
OS.gtk_tree_model_get (tree_model, iter, modelIndex + CELL_TEXT, ptr, -1);
if (ptr [0] != 0) {
@@ -249,7 +248,6 @@ int /*long*/ cellDataProc (int /*long*/ tree_column, int /*long*/ cell, int /*lo
OS.gtk_tree_model_get (tree_model, iter, modelIndex + CELL_BACKGROUND, ptr, -1);
if (ptr [0] != 0) {
OS.g_object_set (cell, OS.cell_background_gdk, ptr [0], 0);
- OS.gdk_color_free (ptr [0]);
}
}
}
@@ -258,13 +256,11 @@ int /*long*/ cellDataProc (int /*long*/ tree_column, int /*long*/ cell, int /*lo
OS.gtk_tree_model_get (tree_model, iter, modelIndex + CELL_FOREGROUND, ptr, -1);
if (ptr [0] != 0) {
OS.g_object_set (cell, OS.foreground_gdk, ptr [0], 0);
- OS.gdk_color_free (ptr [0]);
}
ptr [0] = 0;
OS.gtk_tree_model_get (tree_model, iter, modelIndex + CELL_FONT, ptr, -1);
if (ptr [0] != 0) {
OS.g_object_set (cell, OS.font_desc, ptr [0], 0);
- OS.pango_font_description_free (ptr [0]);
}
}
}
@@ -548,17 +544,7 @@ void createColumn (TableColumn column, int index) {
for (int j=0; j<modelLength; j++) {
OS.gtk_tree_model_get (oldModel, oldItem, j, ptr, -1);
OS.gtk_list_store_set (newModel, newItem, j, ptr [0], -1);
- if (types [j] == OS.G_TYPE_STRING ()) {
- OS.g_free ((ptr [0]));
- } else if (ptr [0] != 0) {
- if (types [j] == OS.GDK_TYPE_COLOR()) {
- OS.gdk_color_free (ptr [0]);
- } else if (types [j] == OS.GDK_TYPE_PIXBUF()) {
- OS.g_object_unref (ptr [0]);
- } else if (types [j] == OS.PANGO_TYPE_FONT_DESCRIPTION()) {
- OS.pango_font_description_free (ptr [0]);
- }
- }
+ if (types [j] == OS.G_TYPE_STRING ()) OS.g_free ((ptr [0]));
}
OS.gtk_list_store_remove (oldModel, oldItem);
OS.g_free (oldItem);
@@ -1011,29 +997,18 @@ void destroyItem (TableColumn column) {
for (int j=0; j<FIRST_COLUMN; j++) {
OS.gtk_tree_model_get (oldModel, oldItem, j, ptr, -1);
OS.gtk_list_store_set (newModel, newItem, j, ptr [0], -1);
- if (ptr [0] != 0) {
- if (j == FOREGROUND_COLUMN || j == BACKGROUND_COLUMN) {
- OS.gdk_color_free (ptr [0]);
- } else if (j == FONT_COLUMN) {
- OS.pango_font_description_free (ptr [0]);
- }
- }
}
OS.gtk_tree_model_get (oldModel, oldItem, column.modelIndex + CELL_PIXBUF, ptr, -1);
OS.gtk_list_store_set (newModel, newItem, FIRST_COLUMN + CELL_PIXBUF, ptr [0], -1);
- if (ptr [0] != 0) OS.g_object_unref (ptr [0]);
OS.gtk_tree_model_get (oldModel, oldItem, column.modelIndex + CELL_TEXT, ptr, -1);
OS.gtk_list_store_set (newModel, newItem, FIRST_COLUMN + CELL_TEXT, ptr [0], -1);
OS.g_free (ptr [0]);
OS.gtk_tree_model_get (oldModel, oldItem, column.modelIndex + CELL_FOREGROUND, ptr, -1);
OS.gtk_list_store_set (newModel, newItem, FIRST_COLUMN + CELL_FOREGROUND, ptr [0], -1);
- if (ptr [0] != 0) OS.gdk_color_free (ptr [0]);
OS.gtk_tree_model_get (oldModel, oldItem, column.modelIndex + CELL_BACKGROUND, ptr, -1);
OS.gtk_list_store_set (newModel, newItem, FIRST_COLUMN + CELL_BACKGROUND, ptr [0], -1);
- if (ptr [0] != 0) OS.gdk_color_free (ptr [0]);
OS.gtk_tree_model_get (oldModel, oldItem, column.modelIndex + CELL_FONT, ptr, -1);
OS.gtk_list_store_set (newModel, newItem, FIRST_COLUMN + CELL_FONT, ptr [0], -1);
- if (ptr [0] != 0) OS.pango_font_description_free (ptr [0]);
OS.gtk_list_store_remove (oldModel, oldItem);
OS.g_free (oldItem);
item.handle = newItem;
@@ -2674,10 +2649,7 @@ int /*long*/ rendererRenderProc (int /*long*/ cell, int /*long*/ window, int /*l
int modelIndex = columnCount == 0 ? Table.FIRST_COLUMN : columns [columnIndex].modelIndex;
OS.gtk_tree_model_get (modelHandle, item.handle, modelIndex + Table.CELL_BACKGROUND, ptr, -1);
}
- if (ptr [0] != 0) {
- drawState |= SWT.BACKGROUND;
- OS.gdk_color_free (ptr [0]);
- }
+ if (ptr [0] != 0) drawState |= SWT.BACKGROUND;
if ((flags & OS.GTK_CELL_RENDERER_SELECTED) != 0) drawState |= SWT.SELECTED;
if ((flags & OS.GTK_CELL_RENDERER_FOCUSED) != 0) drawState |= SWT.FOCUSED;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TableItem.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TableItem.java
index 7119af4343..3307d505eb 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TableItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TableItem.java
@@ -132,7 +132,6 @@ Color _getBackground () {
if (ptr [0] == 0) return parent.getBackground ();
GdkColor gdkColor = new GdkColor ();
OS.memmove (gdkColor, ptr [0], GdkColor.sizeof);
- OS.gdk_color_free (ptr [0]);
return Color.gtk_new (display, gdkColor);
}
@@ -145,7 +144,6 @@ Color _getBackground (int index) {
if (ptr [0] == 0) return _getBackground ();
GdkColor gdkColor = new GdkColor ();
OS.memmove (gdkColor, ptr [0], GdkColor.sizeof);
- OS.gdk_color_free (ptr [0]);
return Color.gtk_new (display, gdkColor);
}
@@ -161,7 +159,6 @@ Color _getForeground () {
if (ptr [0] == 0) return parent.getForeground ();
GdkColor gdkColor = new GdkColor ();
OS.memmove (gdkColor, ptr [0], GdkColor.sizeof);
- OS.gdk_color_free (ptr [0]);
return Color.gtk_new (display, gdkColor);
}
@@ -174,7 +171,6 @@ Color _getForeground (int index) {
if (ptr [0] == 0) return _getForeground ();
GdkColor gdkColor = new GdkColor ();
OS.memmove (gdkColor, ptr [0], GdkColor.sizeof);
- OS.gdk_color_free (ptr [0]);
return Color.gtk_new (display, gdkColor);
}
@@ -187,7 +183,6 @@ Image _getImage (int index) {
if (ptr [0] == 0) return null;
ImageList imageList = parent.imageList;
int imageIndex = imageList.indexOf (ptr [0]);
- OS.g_object_unref (ptr [0]);
if (imageIndex == -1) return null;
return imageList.get (imageIndex);
}
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 0e630d385c..7715436e4e 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
@@ -274,7 +274,6 @@ int /*long*/ cellDataProc (int /*long*/ tree_column, int /*long*/ cell, int /*lo
ptr [0] = 0;
OS.gtk_tree_model_get (tree_model, iter, modelIndex + CELL_PIXBUF, ptr, -1);
OS.g_object_set (cell, OS.pixbuf, ptr[0], 0);
- OS.g_object_unref (ptr [0]);
} else {
ptr [0] = 0;
OS.gtk_tree_model_get (tree_model, iter, modelIndex + CELL_TEXT, ptr, -1);
@@ -295,7 +294,6 @@ int /*long*/ cellDataProc (int /*long*/ tree_column, int /*long*/ cell, int /*lo
OS.gtk_tree_model_get (tree_model, iter, modelIndex + CELL_BACKGROUND, ptr, -1);
if (ptr [0] != 0) {
OS.g_object_set (cell, OS.cell_background_gdk, ptr[0], 0);
- OS.gdk_color_free (ptr [0]);
}
}
}
@@ -304,13 +302,11 @@ int /*long*/ cellDataProc (int /*long*/ tree_column, int /*long*/ cell, int /*lo
OS.gtk_tree_model_get (tree_model, iter, modelIndex + CELL_FOREGROUND, ptr, -1);
if (ptr [0] != 0) {
OS.g_object_set (cell, OS.foreground_gdk, ptr[0], 0);
- OS.gdk_color_free (ptr [0]);
}
ptr [0] = 0;
OS.gtk_tree_model_get (tree_model, iter, modelIndex + CELL_FONT, ptr, -1);
if (ptr [0] != 0) {
OS.g_object_set (cell, OS.font_desc, ptr[0], 0);
- OS.pango_font_description_free (ptr [0]);
}
}
}
@@ -593,32 +589,12 @@ void copyModel (int /*long*/ oldModel, int oldStart, int /*long*/ newModel, int
for (int j = 0; j < FIRST_COLUMN; j++) {
OS.gtk_tree_model_get (oldModel, oldItem, j, ptr, -1);
OS.gtk_tree_store_set (newModel, newItem, j, ptr [0], -1);
- if (types[j] == OS.G_TYPE_STRING()) {
- OS.g_free((ptr[0]));
- } else if (ptr[0] != 0) {
- if (types[j] == OS.GDK_TYPE_COLOR()) {
- OS.gdk_color_free(ptr[0]);
- } else if (types[j] == OS.GDK_TYPE_PIXBUF()) {
- OS.g_object_unref(ptr[0]);
- } else if (types[j] == OS.PANGO_TYPE_FONT_DESCRIPTION()) {
- OS.pango_font_description_free(ptr[0]);
- }
- }
+ if (types [j] == OS.G_TYPE_STRING ()) OS.g_free ((ptr [0]));
}
for (int j= 0; j<modelLength - FIRST_COLUMN; j++) {
OS.gtk_tree_model_get (oldModel, oldItem, oldStart + j, ptr, -1);
OS.gtk_tree_store_set (newModel, newItem, newStart + j, ptr [0], -1);
- if (types[j] == OS.G_TYPE_STRING()) {
- OS.g_free((ptr[0]));
- } else if (ptr[0] != 0) {
- if (types[j] == OS.GDK_TYPE_COLOR()) {
- OS.gdk_color_free(ptr[0]);
- } else if (types[j] == OS.GDK_TYPE_PIXBUF()) {
- OS.g_object_unref(ptr[0]);
- } else if (types[j] == OS.PANGO_TYPE_FONT_DESCRIPTION()) {
- OS.pango_font_description_free(ptr[0]);
- }
- }
+ if (types [j] == OS.G_TYPE_STRING ()) OS.g_free ((ptr [0]));
}
}
} else {
@@ -2670,10 +2646,7 @@ int /*long*/ rendererRenderProc (int /*long*/ cell, int /*long*/ window, int /*l
int modelIndex = columnCount == 0 ? Tree.FIRST_COLUMN : columns [columnIndex].modelIndex;
OS.gtk_tree_model_get (modelHandle, item.handle, modelIndex + Tree.CELL_BACKGROUND, ptr, -1);
}
- if (ptr[0] != 0) {
- drawState |= SWT.BACKGROUND;
- OS.gdk_color_free(ptr[0]);
- }
+ if (ptr [0] != 0) drawState |= SWT.BACKGROUND;
if ((flags & OS.GTK_CELL_RENDERER_SELECTED) != 0) drawState |= SWT.SELECTED;
if ((flags & OS.GTK_CELL_RENDERER_FOCUSED) != 0) drawState |= SWT.FOCUSED;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TreeItem.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TreeItem.java
index 68d8a81a5f..c40dea482d 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TreeItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TreeItem.java
@@ -217,7 +217,6 @@ Color _getBackground () {
if (ptr [0] == 0) return parent.getBackground ();
GdkColor gdkColor = new GdkColor ();
OS.memmove (gdkColor, ptr [0], GdkColor.sizeof);
- OS.gdk_color_free (ptr [0]);
return Color.gtk_new (display, gdkColor);
}
@@ -230,7 +229,6 @@ Color _getBackground (int index) {
if (ptr [0] == 0) return _getBackground ();
GdkColor gdkColor = new GdkColor ();
OS.memmove (gdkColor, ptr [0], GdkColor.sizeof);
- OS.gdk_color_free (ptr [0]);
return Color.gtk_new (display, gdkColor);
}
@@ -246,7 +244,6 @@ Color _getForeground () {
if (ptr [0] == 0) return parent.getForeground ();
GdkColor gdkColor = new GdkColor ();
OS.memmove (gdkColor, ptr [0], GdkColor.sizeof);
- OS.gdk_color_free (ptr [0]);
return Color.gtk_new (display, gdkColor);
}
@@ -259,7 +256,6 @@ Color _getForeground (int index) {
if (ptr [0] == 0) return _getForeground ();
GdkColor gdkColor = new GdkColor ();
OS.memmove (gdkColor, ptr [0], GdkColor.sizeof);
- OS.gdk_color_free (ptr [0]);
return Color.gtk_new (display, gdkColor);
}
@@ -272,7 +268,6 @@ Image _getImage (int index) {
if (ptr [0] == 0) return null;
ImageList imageList = parent.imageList;
int imageIndex = imageList.indexOf (ptr [0]);
- OS.g_object_unref (ptr [0]);
if (imageIndex == -1) return null;
return imageList.get (imageIndex);
}