Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul D'Pong2021-03-25 17:28:22 +0000
committerAlexander Kurtakov2021-03-28 06:27:24 +0000
commit8df01550c71271967ed99e2f22f7736ab0aad679 (patch)
tree567c2c483f8808145b4897f942df086931070e2a
parenta9fe827042460c1d25d191786b4a61e230772222 (diff)
downloadeclipse.platform.swt-8df01550c71271967ed99e2f22f7736ab0aad679.tar.gz
eclipse.platform.swt-8df01550c71271967ed99e2f22f7736ab0aad679.tar.xz
eclipse.platform.swt-8df01550c71271967ed99e2f22f7736ab0aad679.zip
Bug 572337 - [GTK4] Fix Button widget memory deallocation
- Release boxHandle properly - Sink groupHandle's reference properly in order to allow for release in releaseWidget Change-Id: Icdbfa071240848be0624b7cc9de40bb42bfc73dd Signed-off-by: Paul D'Pong <sdamrong@redhat.com>
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Button.java23
1 files changed, 13 insertions, 10 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Button.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Button.java
index bb296bcf7c..3971e55fb3 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Button.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Button.java
@@ -299,10 +299,6 @@ void createHandle (int index) {
if ((style & (SWT.PUSH | SWT.TOGGLE)) == 0) state |= THEME_BACKGROUND;
int bits = SWT.ARROW | SWT.TOGGLE | SWT.CHECK | SWT.RADIO | SWT.PUSH;
- fixedHandle = OS.g_object_new(display.gtk_fixed_get_type(), 0);
- if (fixedHandle == 0) error(SWT.ERROR_NO_HANDLES);
- if (!GTK.GTK4) GTK.gtk_widget_set_has_window(fixedHandle, true);
-
switch (style & bits) {
case SWT.ARROW:
byte arrowType [] = GTK.GTK_NAMED_ICON_GO_UP;
@@ -359,6 +355,7 @@ void createHandle (int index) {
if (GTK.GTK4) {
groupHandle = GTK.gtk_check_button_new();
if (groupHandle == 0) error(SWT.ERROR_NO_HANDLES);
+ OS.g_object_ref_sink(groupHandle);
handle = GTK.gtk_check_button_new();
if (handle == 0) error (SWT.ERROR_NO_HANDLES);
GTK4.gtk_check_button_set_group(handle, groupHandle);
@@ -417,10 +414,13 @@ void createHandle (int index) {
}
}
+ fixedHandle = OS.g_object_new(display.gtk_fixed_get_type(), 0);
+ if (fixedHandle == 0) error(SWT.ERROR_NO_HANDLES);
if (GTK.GTK4) {
OS.swt_fixed_add(fixedHandle, handle);
} else {
- GTK3.gtk_container_add (fixedHandle, handle);
+ GTK.gtk_widget_set_has_window(fixedHandle, true);
+ GTK3.gtk_container_add(fixedHandle, handle);
}
if ((style & SWT.ARROW) != 0) return;
@@ -726,14 +726,17 @@ void releaseHandle () {
}
@Override
-void releaseWidget () {
- super.releaseWidget ();
+void releaseWidget() {
+ super.releaseWidget();
- if (!GTK.GTK4) {
- if (groupHandle != 0) OS.g_object_unref (groupHandle);
- groupHandle = 0;
+ if (GTK.GTK4) {
+ if (boxHandle != 0) GTK.gtk_widget_unparent(boxHandle);
}
+ // Release reference to hidden GtkCheckButton that allows for SWT.RADIO behavior
+ if (groupHandle != 0) OS.g_object_unref(groupHandle);
+ groupHandle = 0;
+
image = null;
text = null;
}

Back to the top