From 89e9775adff982b626f05e6cafef9495701a8c3a Mon Sep 17 00:00:00 2001 From: Alexander Kurtakov Date: Wed, 2 Apr 2014 16:10:23 +0300 Subject: Bug 431789 - PrintDialog.open crashes with GTK 3.10 Ensure that GtkPrinterOptionWidget GType is initialized to prevent the crash. Change-Id: Ib25a24fc0849a1939f04884bb1c369598015817f Signed-off-by: Alexander Kurtakov --- .../org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c | 20 ++++++++++++++++++++ .../Eclipse SWT PI/gtk/library/os_custom.c | 17 +++++++++++++++++ .../Eclipse SWT PI/gtk/library/os_custom.h | 1 + .../Eclipse SWT PI/gtk/library/os_stats.c | 4 +++- .../Eclipse SWT PI/gtk/library/os_stats.h | 4 +++- .../gtk/org/eclipse/swt/internal/gtk/OS.java | 12 ++++++++++++ .../gtk/org/eclipse/swt/widgets/Display.java | 9 +++++++++ 7 files changed, 65 insertions(+), 2 deletions(-) diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c index c788238341..b3d2c152e7 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c @@ -13224,6 +13224,26 @@ JNIEXPORT jboolean JNICALL OS_NATIVE(_1gtk_1printer_1is_1default) } #endif +#ifndef NO__1gtk_1printer_1option_1widget_1get_1type +JNIEXPORT jintLong JNICALL OS_NATIVE(_1gtk_1printer_1option_1widget_1get_1type) + (JNIEnv *env, jclass that) +{ + jintLong rc = 0; + OS_NATIVE_ENTER(env, that, _1gtk_1printer_1option_1widget_1get_1type_FUNC); +/* + rc = (jintLong)gtk_printer_option_widget_get_type(); +*/ + { + OS_LOAD_FUNCTION(fp, gtk_printer_option_widget_get_type) + if (fp) { + rc = (jintLong)((jintLong (CALLING_CONVENTION*)())fp)(); + } + } + OS_NATIVE_EXIT(env, that, _1gtk_1printer_1option_1widget_1get_1type_FUNC); + return rc; +} +#endif + #ifndef NO__1gtk_1progress_1bar_1new JNIEXPORT jintLong JNICALL OS_NATIVE(_1gtk_1progress_1bar_1new) (JNIEnv *env, jclass that) diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_custom.c b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_custom.c index 5b49b4c185..a17f47fbb0 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_custom.c +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_custom.c @@ -152,6 +152,23 @@ JNIEXPORT jintLong JNICALL OS_NATIVE(pangoFontFaceNewProc_1CALLBACK) return rc; } #endif +#ifndef NO_printerOptionWidgetNewProc_1CALLBACK +static jintLong superPrinterOptionWidgetNewProc; +static GType * printerOptionWidgetNewProc (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties) { + GType* printerOptionWidget = ((GType * (*)(GType, guint, GObjectConstructParam *))superPrinterOptionWidgetNewProc)(type, n_construct_properties, construct_properties); + return printerOptionWidget; +} +JNIEXPORT jintLong JNICALL OS_NATIVE(printerOptionWidgetNewProc_1CALLBACK) + (JNIEnv *env, jclass that, jintLong arg0) +{ + jintLong rc = 0; + OS_NATIVE_ENTER(env, that, printerOptionWidgetNewProc_1CALLBACK_FUNC); + superPrinterOptionWidgetNewProc = arg0; + rc = (jintLong)printerOptionWidgetNewProc; + OS_NATIVE_EXIT(env, that, printerOptionWidgetNewProc_1CALLBACK_FUNC); + return rc; +} +#endif #ifndef NO__1gtk_1file_1chooser_1dialog_1new diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_custom.h b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_custom.h index a30af52702..6938ad905b 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_custom.h +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_custom.h @@ -411,6 +411,7 @@ #define gtk_paint_shadow_gap_LIB LIB_GTK #define gtk_paint_option_LIB LIB_GTK #define gtk_paint_layout_LIB LIB_GTK +#define gtk_printer_option_widget_get_type_LIB LIB_GTK #define gtk_print_unix_dialog_set_embed_page_setup_LIB LIB_GTK #define gtk_render_check_LIB LIB_GTK #define gtk_render_extension_LIB LIB_GTK diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c index a63de53d55..60bc96653a 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2013 IBM Corporation and others. All rights reserved. + * Copyright (c) 2000, 2014 IBM Corporation and others. All rights reserved. * The contents of this file are made available under the terms * of the GNU Lesser General Public License (LGPL) Version 2.1 that * accompanies this distribution (lgpl-v21.txt). The LGPL is also @@ -979,6 +979,7 @@ char * OS_nativeFunctionNames[] = { "_1gtk_1printer_1get_1backend", "_1gtk_1printer_1get_1name", "_1gtk_1printer_1is_1default", + "_1gtk_1printer_1option_1widget_1get_1type", "_1gtk_1progress_1bar_1new", "_1gtk_1progress_1bar_1pulse", "_1gtk_1progress_1bar_1set_1fraction", @@ -1821,6 +1822,7 @@ char * OS_nativeFunctionNames[] = { "pangoFontFaceNewProc_1CALLBACK", "pangoFontFamilyNewProc_1CALLBACK", "pangoLayoutNewProc_1CALLBACK", + "printerOptionWidgetNewProc_1CALLBACK", "realpath", "strcmp", }; diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h index 75b74fa9fb..423f5d9c13 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2013 IBM Corporation and others. All rights reserved. + * Copyright (c) 2000, 2014 IBM Corporation and others. All rights reserved. * The contents of this file are made available under the terms * of the GNU Lesser General Public License (LGPL) Version 2.1 that * accompanies this distribution (lgpl-v21.txt). The LGPL is also @@ -989,6 +989,7 @@ typedef enum { _1gtk_1printer_1get_1backend_FUNC, _1gtk_1printer_1get_1name_FUNC, _1gtk_1printer_1is_1default_FUNC, + _1gtk_1printer_1option_1widget_1get_1type_FUNC, _1gtk_1progress_1bar_1new_FUNC, _1gtk_1progress_1bar_1pulse_FUNC, _1gtk_1progress_1bar_1set_1fraction_FUNC, @@ -1831,6 +1832,7 @@ typedef enum { pangoFontFaceNewProc_1CALLBACK_FUNC, pangoFontFamilyNewProc_1CALLBACK_FUNC, pangoLayoutNewProc_1CALLBACK_FUNC, + printerOptionWidgetNewProc_1CALLBACK_FUNC, realpath_FUNC, strcmp_FUNC, } OS_FUNCS; diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java index d9f1dda196..cc81dd154e 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java @@ -1466,6 +1466,8 @@ public static final native long /*int*/ pangoFontFamilyNewProc_CALLBACK(long /*i /** @method flags=no_gen */ public static final native long /*int*/ pangoFontFaceNewProc_CALLBACK(long /*int*/ func); /** @method flags=no_gen */ +public static final native long /*int*/ printerOptionWidgetNewProc_CALLBACK(long /*int*/ func); +/** @method flags=no_gen */ public static final native long /*int*/ imContextNewProc_CALLBACK(long /*int*/ func); /** @method flags=no_gen */ public static final native long /*int*/ imContextLast(); @@ -1901,6 +1903,16 @@ public static final long /*int*/ PANGO_TYPE_FONT_FACE() { lock.unlock(); } } +/** @method flags=dynamic */ +public static final native long /*int*/ _gtk_printer_option_widget_get_type(); +public static final long /*int*/ gtk_printer_option_widget_get_type() { + lock.lock(); + try { + return _gtk_printer_option_widget_get_type(); + } finally { + lock.unlock(); + } +} /** @method flags=const */ public static final native long /*int*/ _PANGO_TYPE_LAYOUT(); public static final long /*int*/ PANGO_TYPE_LAYOUT() { diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java index 5b0660a032..629ff083e0 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java @@ -296,6 +296,9 @@ public class Display extends Device { /* IM Context constructor */ long /*int*/ imContextNewProc; + /* GtkPrinterOptionWidget constructor */ + long /*int*/ printerOptionWidgetNewProc; + /* Custom Resize */ double resizeLocationX, resizeLocationY; int resizeBoundsX, resizeBoundsY, resizeBoundsWidth, resizeBoundsHeight; @@ -2824,6 +2827,12 @@ void initializeSubclasses () { pangoFontFaceNewProc = OS.G_OBJECT_CLASS_CONSTRUCTOR (pangoFontFaceClass); OS.G_OBJECT_CLASS_SET_CONSTRUCTOR (pangoFontFaceClass, OS.pangoFontFaceNewProc_CALLBACK(pangoFontFaceNewProc)); OS.g_type_class_unref (pangoFontFaceClass); + + long /*int*/ printerOptionWidgetType = OS.gtk_printer_option_widget_get_type(); + long /*int*/ printerOptionWidgetClass = OS.g_type_class_ref (printerOptionWidgetType); + printerOptionWidgetNewProc = OS.G_OBJECT_CLASS_CONSTRUCTOR (printerOptionWidgetClass); + OS.G_OBJECT_CLASS_SET_CONSTRUCTOR (printerOptionWidgetClass, OS.printerOptionWidgetNewProc_CALLBACK(printerOptionWidgetNewProc)); + OS.g_type_class_unref (printerOptionWidgetClass); } } -- cgit v1.2.3