From d7da67b4dee7c32713f02b05aaf3ada9df34c5bc Mon Sep 17 00:00:00 2001 From: Sebastian Lackner Date: Sat, 22 Aug 2015 17:18:11 +0200 Subject: [PATCH] Updated GTK3 patchset to fix "division by zero" exception errors (fixes Wine Staging Bug #523). --- debian/changelog | 2 + patches/patchinstall.sh | 4 + ...-class-name-before-calling-vtable-fu.patch | 220 ++++++++++++++++++ ...-FPU-flags-before-calling-GTK3-funct.patch | 174 ++++++++++++++ patches/uxtheme-GTK_Theming/definition | 3 - 5 files changed, 400 insertions(+), 3 deletions(-) create mode 100644 patches/uxtheme-GTK_Theming/0005-uxthemegtk-Print-class-name-before-calling-vtable-fu.patch create mode 100644 patches/uxtheme-GTK_Theming/0006-uxthemegtk-Reset-FPU-flags-before-calling-GTK3-funct.patch diff --git a/debian/changelog b/debian/changelog index bce6e8fa..149bba16 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,6 @@ wine-staging (1.7.50) UNRELEASED; urgency=low + * Updated GTK3 patchset to fix "division by zero" exception errors (fixes Wine + Staging Bug #523). * Add patch to implement remaining OpenMP locking functions. * Added various patches for imagehlp cleanup (fixes Wine Staging Bug #502). * Added patch to fix implementation of ntdll.MapViewOfSection. diff --git a/patches/patchinstall.sh b/patches/patchinstall.sh index 5494b590..5279e496 100755 --- a/patches/patchinstall.sh +++ b/patches/patchinstall.sh @@ -5055,11 +5055,15 @@ if test "$enable_uxtheme_GTK_Theming" -eq 1; then patch_apply uxtheme-GTK_Theming/0002-uxthemegtk-Initial-implementation.patch patch_apply uxtheme-GTK_Theming/0003-uxthemegtk-Implement-enumeration-of-themes-color-and.patch patch_apply uxtheme-GTK_Theming/0004-uxthemegtk-Correctly-render-buttons-with-GTK-3.14.0.patch + patch_apply uxtheme-GTK_Theming/0005-uxthemegtk-Print-class-name-before-calling-vtable-fu.patch + patch_apply uxtheme-GTK_Theming/0006-uxthemegtk-Reset-FPU-flags-before-calling-GTK3-funct.patch ( echo '+ { "Michael Müller", "uxthemegtk: Add configure check and stub dll.", 1 },'; echo '+ { "Ivan Akulinchev", "uxthemegtk: Initial implementation.", 1 },'; echo '+ { "Michael Müller", "uxthemegtk: Implement enumeration of themes, color and sizes.", 1 },'; echo '+ { "Sebastian Lackner", "uxthemegtk: Correctly render buttons with GTK >= 3.14.0.", 1 },'; + echo '+ { "Michael Müller", "uxthemegtk: Print class name before calling vtable functions.", 1 },'; + echo '+ { "Michael Müller", "uxthemegtk: Reset FPU flags before calling GTK3 functions.", 1 },'; ) >> "$patchlist" fi diff --git a/patches/uxtheme-GTK_Theming/0005-uxthemegtk-Print-class-name-before-calling-vtable-fu.patch b/patches/uxtheme-GTK_Theming/0005-uxthemegtk-Print-class-name-before-calling-vtable-fu.patch new file mode 100644 index 00000000..a2c5d205 --- /dev/null +++ b/patches/uxtheme-GTK_Theming/0005-uxthemegtk-Print-class-name-before-calling-vtable-fu.patch @@ -0,0 +1,220 @@ +From 6670a2999420323cb4c63d7aaa47638a5abd98fa Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Michael=20M=C3=BCller?= +Date: Sat, 22 Aug 2015 05:08:42 +0200 +Subject: uxthemegtk: Print class name before calling vtable functions. + +--- + dlls/uxtheme-gtk/button.c | 1 + + dlls/uxtheme-gtk/combobox.c | 1 + + dlls/uxtheme-gtk/edit.c | 1 + + dlls/uxtheme-gtk/header.c | 4 +++- + dlls/uxtheme-gtk/listbox.c | 1 + + dlls/uxtheme-gtk/menu.c | 1 + + dlls/uxtheme-gtk/rebar.c | 1 + + dlls/uxtheme-gtk/status.c | 1 + + dlls/uxtheme-gtk/tab.c | 1 + + dlls/uxtheme-gtk/toolbar.c | 1 + + dlls/uxtheme-gtk/trackbar.c | 1 + + dlls/uxtheme-gtk/uxtheme.c | 4 ++++ + dlls/uxtheme-gtk/uxthemegtk.h | 1 + + dlls/uxtheme-gtk/window.c | 1 + + 14 files changed, 19 insertions(+), 1 deletion(-) + +diff --git a/dlls/uxtheme-gtk/button.c b/dlls/uxtheme-gtk/button.c +index b867448..3d8e6eb 100644 +--- a/dlls/uxtheme-gtk/button.c ++++ b/dlls/uxtheme-gtk/button.c +@@ -483,6 +483,7 @@ static BOOL is_part_defined(int part_id, int state_id) + + static const uxgtk_theme_vtable_t button_vtable = + { ++ "button", + get_color, + draw_background, + get_part_size, +diff --git a/dlls/uxtheme-gtk/combobox.c b/dlls/uxtheme-gtk/combobox.c +index 38abb82..66299a9 100644 +--- a/dlls/uxtheme-gtk/combobox.c ++++ b/dlls/uxtheme-gtk/combobox.c +@@ -191,6 +191,7 @@ static BOOL is_part_defined(int part_id, int state_id) + + static const uxgtk_theme_vtable_t combobox_vtable = + { ++ "combobox", + NULL, /* get_color */ + draw_background, + NULL, /* get_part_size */ +diff --git a/dlls/uxtheme-gtk/edit.c b/dlls/uxtheme-gtk/edit.c +index eb5f108..60b7b3f 100644 +--- a/dlls/uxtheme-gtk/edit.c ++++ b/dlls/uxtheme-gtk/edit.c +@@ -180,6 +180,7 @@ static BOOL is_part_defined(int part_id, int state_id) + + static const uxgtk_theme_vtable_t edit_vtable = + { ++ "edit", + get_color, + draw_background, + NULL, /* get_part_size */ +diff --git a/dlls/uxtheme-gtk/header.c b/dlls/uxtheme-gtk/header.c +index 11c0245..353c7ac 100644 +--- a/dlls/uxtheme-gtk/header.c ++++ b/dlls/uxtheme-gtk/header.c +@@ -92,7 +92,9 @@ static BOOL is_part_defined(int part_id, int state_id) + return (part_id == HP_HEADERITEM); + } + +-static const uxgtk_theme_vtable_t header_vtable = { ++static const uxgtk_theme_vtable_t header_vtable = ++{ ++ "header", + NULL, /* get_color */ + draw_background, + NULL, /* get_part_size */ +diff --git a/dlls/uxtheme-gtk/listbox.c b/dlls/uxtheme-gtk/listbox.c +index 53e1391..7450378 100644 +--- a/dlls/uxtheme-gtk/listbox.c ++++ b/dlls/uxtheme-gtk/listbox.c +@@ -88,6 +88,7 @@ static BOOL is_part_defined(int part_id, int state_id) + + static const uxgtk_theme_vtable_t listbox_vtable = + { ++ "listbox", + NULL, /* get_color */ + draw_background, + NULL, /* get_part_size */ +diff --git a/dlls/uxtheme-gtk/menu.c b/dlls/uxtheme-gtk/menu.c +index b24a085..d6cdeca 100644 +--- a/dlls/uxtheme-gtk/menu.c ++++ b/dlls/uxtheme-gtk/menu.c +@@ -154,6 +154,7 @@ static HRESULT get_color(uxgtk_theme_t *theme, int part_id, int state_id, + + static const uxgtk_theme_vtable_t menu_vtable = + { ++ "menu", + get_color, + NULL, /* draw_background */ + NULL, /* get_part_size */ +diff --git a/dlls/uxtheme-gtk/rebar.c b/dlls/uxtheme-gtk/rebar.c +index 03650ae..714a9e7 100644 +--- a/dlls/uxtheme-gtk/rebar.c ++++ b/dlls/uxtheme-gtk/rebar.c +@@ -71,6 +71,7 @@ static BOOL is_part_defined(int part_id, int state_id) + + static const uxgtk_theme_vtable_t rebar_vtable = + { ++ "rebar", + NULL, /* get_color */ + draw_background, + NULL, /* get_part_size */ +diff --git a/dlls/uxtheme-gtk/status.c b/dlls/uxtheme-gtk/status.c +index e2a937a..8398360 100644 +--- a/dlls/uxtheme-gtk/status.c ++++ b/dlls/uxtheme-gtk/status.c +@@ -122,6 +122,7 @@ static BOOL is_part_defined(int part_id, int state_id) + + static const uxgtk_theme_vtable_t status_vtable = + { ++ "status", + NULL, /* get_color */ + draw_background, + get_part_size, +diff --git a/dlls/uxtheme-gtk/tab.c b/dlls/uxtheme-gtk/tab.c +index 31bdc0e..6ad40bb 100644 +--- a/dlls/uxtheme-gtk/tab.c ++++ b/dlls/uxtheme-gtk/tab.c +@@ -166,6 +166,7 @@ static BOOL is_part_defined(int part_id, int state_id) + + static const uxgtk_theme_vtable_t tab_vtable = + { ++ "tab", + NULL, /* get_color */ + draw_background, + NULL, /* get_part_size */ +diff --git a/dlls/uxtheme-gtk/toolbar.c b/dlls/uxtheme-gtk/toolbar.c +index be8fbae..6158353 100644 +--- a/dlls/uxtheme-gtk/toolbar.c ++++ b/dlls/uxtheme-gtk/toolbar.c +@@ -138,6 +138,7 @@ static BOOL is_part_defined(int part_id, int state_id) + + static const uxgtk_theme_vtable_t toolbar_vtable = + { ++ "toolbar", + NULL, /* get_color */ + draw_background, + NULL, /* get_part_size */ +diff --git a/dlls/uxtheme-gtk/trackbar.c b/dlls/uxtheme-gtk/trackbar.c +index 58df246..f576fbe 100644 +--- a/dlls/uxtheme-gtk/trackbar.c ++++ b/dlls/uxtheme-gtk/trackbar.c +@@ -149,6 +149,7 @@ static BOOL is_part_defined(int part_id, int state_id) + + static const uxgtk_theme_vtable_t trackbar_vtable = + { ++ "trackbar", + NULL, /* get_color */ + draw_background, + NULL, /* get_part_size */ +diff --git a/dlls/uxtheme-gtk/uxtheme.c b/dlls/uxtheme-gtk/uxtheme.c +index 0050036..37af3bc 100644 +--- a/dlls/uxtheme-gtk/uxtheme.c ++++ b/dlls/uxtheme-gtk/uxtheme.c +@@ -576,6 +576,7 @@ HRESULT WINAPI GetThemeColor(HTHEME htheme, int part_id, int state_id, + if (color == NULL) + return E_INVALIDARG; + ++ TRACE("%s->get_color()\n", theme->vtable->classname); + hr = theme->vtable->get_color(theme, part_id, state_id, prop_id, &rgba); + + if (SUCCEEDED(hr) && rgba.alpha > 0) +@@ -879,6 +880,7 @@ HRESULT WINAPI DrawThemeBackgroundEx(HTHEME htheme, HDC hdc, int part_id, int st + surface = pcairo_image_surface_create(CAIRO_FORMAT_ARGB32, width, height); + cr = pcairo_create(surface); + ++ TRACE("%s->draw_background()\n", theme->vtable->classname); + hr = theme->vtable->draw_background(theme, cr, part_id, state_id, width, height); + if (SUCCEEDED(hr)) + paint_cairo_surface(surface, hdc, rect->left, rect->top, width, height); +@@ -1034,6 +1036,7 @@ HRESULT WINAPI GetThemePartSize(HTHEME htheme, HDC hdc, int part_id, int state_i + if (rect == NULL || size == NULL) + return E_INVALIDARG; + ++ TRACE("%s->get_part_size()\n", theme->vtable->classname); + return theme->vtable->get_part_size(theme, part_id, state_id, rect, size); + } + +@@ -1099,6 +1102,7 @@ BOOL WINAPI IsThemePartDefined(HTHEME htheme, int part_id, int state_id) + return FALSE; + } + ++ TRACE("%s->is_part_defined()\n", theme->vtable->classname); + return theme->vtable->is_part_defined(part_id, state_id); + } + +diff --git a/dlls/uxtheme-gtk/uxthemegtk.h b/dlls/uxtheme-gtk/uxthemegtk.h +index 17307f1..79037fb 100644 +--- a/dlls/uxtheme-gtk/uxthemegtk.h ++++ b/dlls/uxtheme-gtk/uxthemegtk.h +@@ -32,6 +32,7 @@ typedef struct _uxgtk_theme_vtable uxgtk_theme_vtable_t; + + struct _uxgtk_theme_vtable + { ++ const char *classname; + HRESULT (*get_color)(uxgtk_theme_t *theme, int part_id, int state_id, + int prop_id, GdkRGBA *rgba); + HRESULT (*draw_background)(uxgtk_theme_t *theme, cairo_t *cr, int part_id, int state_id, +diff --git a/dlls/uxtheme-gtk/window.c b/dlls/uxtheme-gtk/window.c +index cf617ef..8b1478c 100644 +--- a/dlls/uxtheme-gtk/window.c ++++ b/dlls/uxtheme-gtk/window.c +@@ -141,6 +141,7 @@ static BOOL is_part_defined(int part_id, int state_id) + + static const uxgtk_theme_vtable_t window_vtable = + { ++ "window", + get_color, + draw_background, + NULL, /* get_part_size */ +-- +2.5.0 + diff --git a/patches/uxtheme-GTK_Theming/0006-uxthemegtk-Reset-FPU-flags-before-calling-GTK3-funct.patch b/patches/uxtheme-GTK_Theming/0006-uxthemegtk-Reset-FPU-flags-before-calling-GTK3-funct.patch new file mode 100644 index 00000000..d63761fa --- /dev/null +++ b/patches/uxtheme-GTK_Theming/0006-uxthemegtk-Reset-FPU-flags-before-calling-GTK3-funct.patch @@ -0,0 +1,174 @@ +From fa7e6a770944d1e8663e6062ee83df778d6cf7af Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Michael=20M=C3=BCller?= +Date: Sat, 22 Aug 2015 15:41:15 +0200 +Subject: uxthemegtk: Reset FPU flags before calling GTK3 functions. + +--- + dlls/uxtheme-gtk/uxtheme.c | 57 ++++++++++++++++++++++++++++++++++++++++++++-- + 1 file changed, 55 insertions(+), 2 deletions(-) + +diff --git a/dlls/uxtheme-gtk/uxtheme.c b/dlls/uxtheme-gtk/uxtheme.c +index 37af3bc..22d3ffb 100644 +--- a/dlls/uxtheme-gtk/uxtheme.c ++++ b/dlls/uxtheme-gtk/uxtheme.c +@@ -139,6 +139,27 @@ static const WCHAR FAKE_THEME_COLOR[] = {'D','e','f','a','u','l','t',' ','C',' + static const WCHAR FAKE_THEME_SIZE[] = {'D','e','f','a','u','l','t',' ','S','i','z','e',0}; + static WCHAR fake_msstyles_file[MAX_PATH]; + ++static inline WORD reset_fpu_flags(void) ++{ ++#if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__)) ++ WORD default_cw = 0x37f, pre_cw; ++ __asm__ __volatile__( "fwait" ); ++ __asm__ __volatile__( "fnstcw %0" : "=m" (pre_cw) ); ++ __asm__ __volatile__( "fldcw %0" : : "m" (default_cw) ); ++ return pre_cw; ++#else ++ return 0; ++#endif ++} ++ ++static inline void set_fpu_flags(WORD flags) ++{ ++#if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__)) ++ __asm__ __volatile__( "fclex" ); ++ __asm__ __volatile__( "fldcw %0" : : "m" (flags) ); ++#endif ++} ++ + static void free_gtk3_libs(void) + { + if (libgtk3) wine_dlclose(libgtk3, NULL, 0); +@@ -384,6 +405,7 @@ static void paint_cairo_surface(cairo_surface_t *surface, HDC target_hdc, + HRESULT WINAPI CloseThemeData(HTHEME htheme) + { + uxgtk_theme_t *theme = (uxgtk_theme_t *)htheme; ++ WORD fpu_flags; + + TRACE("(%p)\n", htheme); + +@@ -394,7 +416,10 @@ HRESULT WINAPI CloseThemeData(HTHEME htheme) + return E_HANDLE; + + /* Destroy the toplevel widget */ ++ fpu_flags = reset_fpu_flags(); + pgtk_widget_destroy(theme->window); ++ set_fpu_flags(fpu_flags); ++ + HeapFree(GetProcessHeap(), 0, theme); + return S_OK; + } +@@ -480,6 +505,7 @@ HTHEME WINAPI OpenThemeData(HWND hwnd, LPCWSTR classlist) + { + WCHAR *start, *tok, buf[CLASSLIST_MAXLEN]; + uxgtk_theme_t *theme; ++ WORD fpu_flags; + int i; + + TRACE("(%p, %s)\n", hwnd, debugstr_w(classlist)); +@@ -526,7 +552,10 @@ found: + TRACE("Using %s for %s.\n", debugstr_w(classes[i].classname), + debugstr_w(classlist)); + ++ fpu_flags = reset_fpu_flags(); + theme = classes[i].create(); ++ set_fpu_flags(fpu_flags); ++ + if (theme && IsWindow(hwnd)) + SetPropW(hwnd, THEME_PROPERTY, theme); + +@@ -561,6 +590,7 @@ HRESULT WINAPI GetThemeColor(HTHEME htheme, int part_id, int state_id, + HRESULT hr; + GdkRGBA rgba = {0, 0, 0, 0}; + uxgtk_theme_t *theme = (uxgtk_theme_t *)htheme; ++ WORD fpu_flags; + + TRACE("(%p, %d, %d, %d, %p)\n", htheme, part_id, state_id, prop_id, color); + +@@ -577,7 +607,10 @@ HRESULT WINAPI GetThemeColor(HTHEME htheme, int part_id, int state_id, + return E_INVALIDARG; + + TRACE("%s->get_color()\n", theme->vtable->classname); ++ ++ fpu_flags = reset_fpu_flags(); + hr = theme->vtable->get_color(theme, part_id, state_id, prop_id, &rgba); ++ set_fpu_flags(fpu_flags); + + if (SUCCEEDED(hr) && rgba.alpha > 0) + { +@@ -860,6 +893,7 @@ HRESULT WINAPI DrawThemeBackgroundEx(HTHEME htheme, HDC hdc, int part_id, int st + uxgtk_theme_t *theme = (uxgtk_theme_t *)htheme; + cairo_surface_t *surface; + int width, height; ++ WORD fpu_flags; + cairo_t *cr; + HRESULT hr; + +@@ -877,6 +911,8 @@ HRESULT WINAPI DrawThemeBackgroundEx(HTHEME htheme, HDC hdc, int part_id, int st + width = rect->right - rect->left; + height = rect->bottom - rect->top; + ++ fpu_flags = reset_fpu_flags(); ++ + surface = pcairo_image_surface_create(CAIRO_FORMAT_ARGB32, width, height); + cr = pcairo_create(surface); + +@@ -887,6 +923,9 @@ HRESULT WINAPI DrawThemeBackgroundEx(HTHEME htheme, HDC hdc, int part_id, int st + + pcairo_destroy(cr); + pcairo_surface_destroy(surface); ++ ++ set_fpu_flags(fpu_flags); ++ + return hr; + } + +@@ -1021,6 +1060,8 @@ HRESULT WINAPI GetThemePartSize(HTHEME htheme, HDC hdc, int part_id, int state_i + RECT *rect, THEMESIZE type, SIZE *size) + { + uxgtk_theme_t *theme = (uxgtk_theme_t *)htheme; ++ HRESULT result; ++ WORD fpu_flags; + + TRACE("(%p, %p, %d, %d, %p, %d, %p)\n", htheme, hdc, part_id, state_id, rect, type, size); + +@@ -1037,7 +1078,12 @@ HRESULT WINAPI GetThemePartSize(HTHEME htheme, HDC hdc, int part_id, int state_i + return E_INVALIDARG; + + TRACE("%s->get_part_size()\n", theme->vtable->classname); +- return theme->vtable->get_part_size(theme, part_id, state_id, rect, size); ++ ++ fpu_flags = reset_fpu_flags(); ++ result = theme->vtable->get_part_size(theme, part_id, state_id, rect, size); ++ set_fpu_flags(fpu_flags); ++ ++ return result; + } + + HRESULT WINAPI GetThemeTextExtent(HTHEME htheme, HDC hdc, int part_id, int state_id, +@@ -1081,6 +1127,8 @@ BOOL WINAPI IsThemeBackgroundPartiallyTransparent(HTHEME htheme, int part_id, in + BOOL WINAPI IsThemePartDefined(HTHEME htheme, int part_id, int state_id) + { + uxgtk_theme_t *theme = (uxgtk_theme_t *)htheme; ++ WORD fpu_flags; ++ BOOL result; + + TRACE("(%p, %d, %d)\n", htheme, part_id, state_id); + +@@ -1103,7 +1151,12 @@ BOOL WINAPI IsThemePartDefined(HTHEME htheme, int part_id, int state_id) + } + + TRACE("%s->is_part_defined()\n", theme->vtable->classname); +- return theme->vtable->is_part_defined(part_id, state_id); ++ ++ fpu_flags = reset_fpu_flags(); ++ result = theme->vtable->is_part_defined(part_id, state_id); ++ set_fpu_flags(fpu_flags); ++ ++ return result; + } + + DWORD WINAPI QueryThemeServices(void) +-- +2.5.0 + diff --git a/patches/uxtheme-GTK_Theming/definition b/patches/uxtheme-GTK_Theming/definition index 9294d742..4c264752 100644 --- a/patches/uxtheme-GTK_Theming/definition +++ b/patches/uxtheme-GTK_Theming/definition @@ -3,6 +3,3 @@ Fixes: Add support for GTK3 theming Depends: ntdll-DllRedirects - -# Known issues: -# https://bugs.wine-staging.com/show_bug.cgi?id=504