[gtk+/master.fcw: 328/648] gdkcursor-win32.c: Simplify OS Version Check



commit c5d8bd219c3e8bd713004e471a03feedc700b5f4
Author: Chun-wei Fan <fanchunwei src gnome org>
Date:   Tue Dec 23 15:49:01 2014 +0800

    gdkcursor-win32.c: Simplify OS Version Check
    
    ... for _gdk_win32_pixbuf_to_hicon_supports_alpha(), as we just need to
    use the utility function added in GLib to check the OS version.
    
    Also use g_once_init_enter()/g_once_init_leave() to make sure that we cache
    results of whether we are using XP or later.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=741849

 gdk/win32/gdkcursor-win32.c |   17 +++++------------
 1 files changed, 5 insertions(+), 12 deletions(-)
---
diff --git a/gdk/win32/gdkcursor-win32.c b/gdk/win32/gdkcursor-win32.c
index 28b2745..f041d96 100644
--- a/gdk/win32/gdkcursor-win32.c
+++ b/gdk/win32/gdkcursor-win32.c
@@ -821,20 +821,13 @@ _gdk_win32_pixbuf_to_hcursor (GdkPixbuf *pixbuf,
 gboolean
 _gdk_win32_pixbuf_to_hicon_supports_alpha (void)
 {
-  static gboolean is_win_xp=FALSE, is_win_xp_checked=FALSE;
+  static gboolean is_win_xp=FALSE;
+  static gsize is_win_xp_checked;
 
-  if (!is_win_xp_checked)
+  if (g_once_init_enter (&is_win_xp_checked))
     {
-      OSVERSIONINFO version;
-
-      is_win_xp_checked = TRUE;
-
-      memset (&version, 0, sizeof (version));
-      version.dwOSVersionInfoSize = sizeof (version);
-      is_win_xp = GetVersionEx (&version)
-       && version.dwPlatformId == VER_PLATFORM_WIN32_NT
-       && (version.dwMajorVersion > 5
-           || (version.dwMajorVersion == 5 && version.dwMinorVersion >= 1));
+      is_win_xp = g_win32_windows_is_at_least (5, 1, 0, G_WIN32_OS_ANY);
+      g_once_init_leave (&is_win_xp_checked, 1);
     }
   return is_win_xp;
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]