From: Benjamin Otte Date: Mon, 17 Apr 2023 02:16:50 +0000 (+0200) Subject: win32: Abort on error X-Git-Tag: archive/raspbian/4.12.3+ds-1+rpi1~1^2^2^2~22^2~1^2~368^2~23 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=9ac31fe0a01c7dc93659bfc8cf7e29d212121711;p=gtk4.git win32: Abort on error Returning NULL from a function that must not return NULL is not a good idea. --- diff --git a/gdk/win32/gdksurface-win32.c b/gdk/win32/gdksurface-win32.c index c9970ec359..d18079d45b 100644 --- a/gdk/win32/gdksurface-win32.c +++ b/gdk/win32/gdksurface-win32.c @@ -448,7 +448,6 @@ gdk_win32_display_create_surface (GdkDisplay *display, GdkSurfaceType surface_type, GdkSurface *parent) { - HWND hwndNew; HANDLE owner; ATOM klass = 0; DWORD dwStyle = 0, dwExStyle; @@ -530,19 +529,23 @@ gdk_win32_display_create_surface (GdkDisplay *display, wtitle = g_utf8_to_utf16 (title, -1, NULL, NULL, NULL); - hwndNew = CreateWindowExW (dwExStyle, - MAKEINTRESOURCEW (klass), - wtitle, - dwStyle, - CW_USEDEFAULT, CW_USEDEFAULT, - CW_USEDEFAULT, CW_USEDEFAULT, - owner, - NULL, - _gdk_dll_hinstance, - surface); - impl->handle = hwndNew; - - GetWindowRect (hwndNew, &rect); + impl->handle = CreateWindowExW (dwExStyle, + MAKEINTRESOURCEW (klass), + wtitle, + dwStyle, + CW_USEDEFAULT, CW_USEDEFAULT, + CW_USEDEFAULT, CW_USEDEFAULT, + owner, + NULL, + _gdk_dll_hinstance, + surface); + if (impl->handle == NULL) + { + WIN32_API_FAILED ("CreateWindowExW"); + g_error ("Fatal error: CreateWindowExW failed."); + } + + GetWindowRect (impl->handle, &rect); impl->initial_x = rect.left; impl->initial_y = rect.top; @@ -559,13 +562,6 @@ gdk_win32_display_create_surface (GdkDisplay *display, g_free (wtitle); - if (impl->handle == NULL) - { - WIN32_API_FAILED ("CreateWindowExW"); - g_object_unref (impl); - return NULL; - } - gdk_surface_set_egl_native_window (surface, (void *) impl->handle); if (surface_type != GDK_SURFACE_DRAG)