[gtk+] Suppress a warning from SetWindowLongPtr()
- From: Руслан Ижбулатов <ruslanizhb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] Suppress a warning from SetWindowLongPtr()
- Date: Mon, 4 Aug 2014 13:56:01 +0000 (UTC)
commit d43fb29c5abd53391816a4473affbb3afb53a2a0
Author: Руслан Ижбулатов <lrn1986 gmail com>
Date: Sat Aug 2 15:48:03 2014 +0000
Suppress a warning from SetWindowLongPtr()
https://bugzilla.gnome.org/show_bug.cgi?id=726224
gdk/win32/gdkwindow-win32.c | 20 ++++++++++++++++++--
1 files changed, 18 insertions(+), 2 deletions(-)
---
diff --git a/gdk/win32/gdkwindow-win32.c b/gdk/win32/gdkwindow-win32.c
index a8c7fc0..d9bb81e 100644
--- a/gdk/win32/gdkwindow-win32.c
+++ b/gdk/win32/gdkwindow-win32.c
@@ -1741,6 +1741,8 @@ gdk_win32_window_set_transient_for (GdkWindow *window,
GdkWindow *parent)
{
HWND window_id, parent_id;
+ LONG_PTR old_ptr;
+ DWORD w32_error;
GdkWindowImplWin32 *window_impl = GDK_WINDOW_IMPL_WIN32 (window->impl);
GdkWindowImplWin32 *parent_impl = NULL;
GSList *item;
@@ -1799,14 +1801,28 @@ gdk_win32_window_set_transient_for (GdkWindow *window,
g_object_ref (G_OBJECT (parent));
}
+ SetLastError (0);
+ old_ptr = GetWindowLongPtr (window_id, GWLP_HWNDPARENT);
+ w32_error = GetLastError ();
+
+ /* Don't re-set GWLP_HWNDPARENT to the same value */
+ if (old_ptr == parent_id && w32_error == NO_ERROR)
+ return;
+
+ /* Don't return if it failed, try SetWindowLongPtr() anyway */
+ if (old_ptr == 0 && w32_error != NO_ERROR)
+ WIN32_API_FAILED ("GetWindowLongPtr");
+
/* This changes the *owner* of the window, despite the misleading
* name. (Owner and parent are unrelated concepts.) At least that's
* what people who seem to know what they talk about say on
* USENET. Search on Google.
*/
SetLastError (0);
- if (SetWindowLongPtr (window_id, GWLP_HWNDPARENT, (LONG_PTR) parent_id) == 0 &&
- GetLastError () != 0)
+ old_ptr = SetWindowLongPtr (window_id, GWLP_HWNDPARENT, (LONG_PTR) parent_id);
+ w32_error = GetLastError ();
+
+ if (old_ptr == 0 && w32_error != NO_ERROR)
WIN32_API_FAILED ("SetWindowLongPtr");
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]