diff options
author | Simeon Andreev | 2021-05-07 14:13:43 +0000 |
---|---|---|
committer | Sravan Kumar Lakkimsetti | 2021-05-07 15:20:05 +0000 |
commit | c469e04cc1407f93b2827da2f3dbc0770c85dbc7 (patch) | |
tree | f61ad37e4371549c8ea9a46602dfcb6b18f9335f | |
parent | 661387b5e458947746c4a4efab049276a38ff6db (diff) | |
download | eclipse.platform.swt-c469e04cc1407f93b2827da2f3dbc0770c85dbc7.tar.gz eclipse.platform.swt-c469e04cc1407f93b2827da2f3dbc0770c85dbc7.tar.xz eclipse.platform.swt-c469e04cc1407f93b2827da2f3dbc0770c85dbc7.zip |
Bug 573432 - [GTK3] Text/Combo.eventWindow() and Shell.showWidget() leak
This change adjusts code in Combo.eventWindow(), Text.eventWindow() and
Shell.showWidget(), to ensure the handle returned by native methods
(gdk_window_get_children() and gtk_container_get_children()) is always
freed. This avoids native memory leaks.
Change-Id: Ifd68fc72df4ebab21f3c8f264c25ae56aa0ee140
Signed-off-by: Simeon Andreev <simeon.danailov.andreev@gmail.com>
Reviewed-on: https://git.eclipse.org/r/c/platform/eclipse.platform.swt/+/180362
Reviewed-by: Alexandr Miloslavskiy <alexandr.miloslavskiy@syntevo.com>
Tested-by: Platform Bot <platform-bot@eclipse.org>
3 files changed, 10 insertions, 7 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Combo.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Combo.java index c5dfb0ae93..1290655aef 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Combo.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Combo.java @@ -1057,9 +1057,10 @@ long eventWindow () { // Find the internal GDK_INPUT_ONLY window long children = GDK.gdk_window_get_children (window); if (children != 0) { + long childrenIterator = children; do { - window = OS.g_list_data (children); - } while ((children = OS.g_list_next (children)) != 0); + window = OS.g_list_data (childrenIterator); + } while ((childrenIterator = OS.g_list_next (childrenIterator)) != 0); } OS.g_list_free (children); diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java index 171106a002..3afd040cd7 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java @@ -3004,9 +3004,10 @@ void showWidget () { } } else { long list = GTK3.gtk_container_get_children (shellHandle); - while (list != 0) { - GTK3.gtk_container_remove (shellHandle, OS.g_list_data (list)); - list = OS.g_list_next(list); + long listIterator = list; + while (listIterator != 0) { + GTK3.gtk_container_remove (shellHandle, OS.g_list_data (listIterator)); + listIterator = OS.g_list_next(listIterator); } OS.g_list_free (list); } diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Text.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Text.java index d4a7f0d862..9df332a540 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Text.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Text.java @@ -829,6 +829,7 @@ long eventWindow () { long window = super.paintWindow (); long children = GDK.gdk_window_get_children (window); if (children != 0) { + long childrenIterator = children; /* * When search or cancel icons are added to Text, those * icon window(s) are added to the beginning of the list. @@ -836,8 +837,8 @@ long eventWindow () { * browse to the end of the list. */ do { - window = OS.g_list_data (children); - } while ((children = OS.g_list_next (children)) != 0); + window = OS.g_list_data (childrenIterator); + } while ((childrenIterator = OS.g_list_next (childrenIterator)) != 0); } OS.g_list_free (children); return window; |