Skip to content

Commit 9440140

Browse files
ptzieglerakurtakov
authored andcommitted
[GTK4] Fix segmentation fault when creating multiple displays
Subclasses are not created in GTK4, leading to the assignment of NULL pointers when disposing the display. If a second display is created afterwards, this leads to a segmentation fault. Contributes to #1663
1 parent cc4c178 commit 9440140

File tree

1 file changed

+22
-20
lines changed
  • bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets

1 file changed

+22
-20
lines changed

bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java

+22-20
Original file line numberDiff line numberDiff line change
@@ -4817,26 +4817,28 @@ void releaseDisplay () {
48174817
keysChangedProc = 0;
48184818

48194819
/* Dispose subclass */
4820-
long pangoLayoutType = OS.PANGO_TYPE_LAYOUT ();
4821-
long pangoLayoutClass = OS.g_type_class_ref (pangoLayoutType);
4822-
OS.G_OBJECT_CLASS_SET_CONSTRUCTOR (pangoLayoutClass, pangoLayoutNewProc);
4823-
OS.g_type_class_unref (pangoLayoutClass);
4824-
pangoLayoutNewProc = 0;
4825-
long imContextType = GTK.GTK_TYPE_IM_MULTICONTEXT ();
4826-
long imContextClass = OS.g_type_class_ref (imContextType);
4827-
OS.G_OBJECT_CLASS_SET_CONSTRUCTOR (imContextClass, imContextNewProc);
4828-
OS.g_type_class_unref (imContextClass);
4829-
imContextNewProc = 0;
4830-
long pangoFontFamilyType = OS.PANGO_TYPE_FONT_FAMILY ();
4831-
long pangoFontFamilyClass = OS.g_type_class_ref (pangoFontFamilyType);
4832-
OS.G_OBJECT_CLASS_SET_CONSTRUCTOR (pangoFontFamilyClass, pangoFontFamilyNewProc);
4833-
OS.g_type_class_unref (pangoFontFamilyClass);
4834-
pangoFontFamilyNewProc = 0;
4835-
long pangoFontFaceType = OS.PANGO_TYPE_FONT_FACE ();
4836-
long pangoFontFaceClass = OS.g_type_class_ref (pangoFontFaceType);
4837-
OS.G_OBJECT_CLASS_SET_CONSTRUCTOR (pangoFontFaceClass, pangoFontFaceNewProc);
4838-
OS.g_type_class_unref (pangoFontFaceClass);
4839-
pangoFontFaceNewProc = 0;
4820+
if (!GTK.GTK4) {
4821+
long pangoLayoutType = OS.PANGO_TYPE_LAYOUT ();
4822+
long pangoLayoutClass = OS.g_type_class_ref (pangoLayoutType);
4823+
OS.G_OBJECT_CLASS_SET_CONSTRUCTOR (pangoLayoutClass, pangoLayoutNewProc);
4824+
OS.g_type_class_unref (pangoLayoutClass);
4825+
pangoLayoutNewProc = 0;
4826+
long imContextType = GTK.GTK_TYPE_IM_MULTICONTEXT ();
4827+
long imContextClass = OS.g_type_class_ref (imContextType);
4828+
OS.G_OBJECT_CLASS_SET_CONSTRUCTOR (imContextClass, imContextNewProc);
4829+
OS.g_type_class_unref (imContextClass);
4830+
imContextNewProc = 0;
4831+
long pangoFontFamilyType = OS.PANGO_TYPE_FONT_FAMILY ();
4832+
long pangoFontFamilyClass = OS.g_type_class_ref (pangoFontFamilyType);
4833+
OS.G_OBJECT_CLASS_SET_CONSTRUCTOR (pangoFontFamilyClass, pangoFontFamilyNewProc);
4834+
OS.g_type_class_unref (pangoFontFamilyClass);
4835+
pangoFontFamilyNewProc = 0;
4836+
long pangoFontFaceType = OS.PANGO_TYPE_FONT_FACE ();
4837+
long pangoFontFaceClass = OS.g_type_class_ref (pangoFontFaceType);
4838+
OS.G_OBJECT_CLASS_SET_CONSTRUCTOR (pangoFontFaceClass, pangoFontFaceNewProc);
4839+
OS.g_type_class_unref (pangoFontFaceClass);
4840+
pangoFontFaceNewProc = 0;
4841+
}
48404842

48414843
/* Release the sleep resources */
48424844
max_priority = timeout = null;

0 commit comments

Comments
 (0)