diff --git a/include/wx/utils.h b/include/wx/utils.h index 5581eadb3d..48b8842924 100644 --- a/include/wx/utils.h +++ b/include/wx/utils.h @@ -141,7 +141,8 @@ WXDLLIMPEXP_BASE wxString wxGetOsDescription(); // Get OS version WXDLLIMPEXP_BASE wxOperatingSystemId wxGetOsVersion(int *verMaj = NULL, - int *verMin = NULL); + int *verMin = NULL, + int *verMicro = NULL); // Check is OS version is at least the specified major and minor version WXDLLIMPEXP_BASE bool wxCheckOsVersion(int majorVsn, int minorVsn = 0); diff --git a/interface/wx/utils.h b/interface/wx/utils.h index 9b48602183..373ea8e090 100644 --- a/interface/wx/utils.h +++ b/interface/wx/utils.h @@ -842,16 +842,22 @@ wxString wxGetOsDescription(); /** Gets the version and the operating system ID for currently running OS. The returned wxOperatingSystemId value can be used for a basic categorization - of the OS family; the major and minor version numbers allows to detect a specific - system. - + of the OS family; the major, minor, and micro version numbers allows to + detect a specific system. + + If on Unix-like systems the version can't be detected all three version + numbers will have a value of -1. + + On systems where only the micro version can't be detected or doesn't make + sense such as Windows, it will have a value of 0. + For Unix-like systems (@c wxOS_UNIX) the major and minor version integers will contain the kernel major and minor version numbers (as returned by the 'uname -r' command); e.g. "4" and "1" if the machine is using kernel 4.1.4. For OS X systems (@c wxOS_MAC) the major and minor version integers are the - natural version numbers associated with the OS; e.g. "10" and "11" if the machine - is using OS X El Capitan. + natural version numbers associated with the OS; e.g. "10", "11" and "2" if + the machine is using OS X El Capitan 10.11.2. For Windows-like systems (@c wxOS_WINDOWS) the major and minor version integers will contain the following values: @@ -878,7 +884,7 @@ wxString wxGetOsDescription(); @header{wx/utils.h} */ -wxOperatingSystemId wxGetOsVersion(int* major = NULL, int* minor = NULL); +wxOperatingSystemId wxGetOsVersion(int* major = NULL, int* minor = NULL, int* micro = NULL); /** Returns @true if the version of the operating system on which the program diff --git a/src/msw/utils.cpp b/src/msw/utils.cpp index 59873f6708..685ae3a5c2 100644 --- a/src/msw/utils.cpp +++ b/src/msw/utils.cpp @@ -1235,7 +1235,7 @@ bool wxIsPlatform64Bit() #endif // Win64/Win32 } -wxOperatingSystemId wxGetOsVersion(int *verMaj, int *verMin) +wxOperatingSystemId wxGetOsVersion(int *verMaj, int *verMin, int *verMicro) { static struct { @@ -1273,6 +1273,8 @@ wxOperatingSystemId wxGetOsVersion(int *verMaj, int *verMin) *verMaj = s_version.verMaj; if ( verMin ) *verMin = s_version.verMin; + if ( verMicro ) + *verMicro = 0; return s_version.os; } diff --git a/src/osx/cocoa/utils_base.mm b/src/osx/cocoa/utils_base.mm index bd96e3945a..e02137935f 100644 --- a/src/osx/cocoa/utils_base.mm +++ b/src/osx/cocoa/utils_base.mm @@ -28,7 +28,7 @@ #endif // our OS version is the same in non GUI and GUI cases -wxOperatingSystemId wxGetOsVersion(int *verMaj, int *verMin) +wxOperatingSystemId wxGetOsVersion(int *verMaj, int *verMin, int *verMicro) { #ifdef wxHAS_NSPROCESSINFO if ([NSProcessInfo instancesRespondToSelector:@selector(operatingSystemVersion)]) @@ -40,6 +40,9 @@ wxOperatingSystemId wxGetOsVersion(int *verMaj, int *verMin) if ( verMin != NULL ) *verMin = osVer.minorVersion; + + if ( verMicro != NULL ) + *verMicro = osVer.patchVersion; } else #endif @@ -47,13 +50,15 @@ wxOperatingSystemId wxGetOsVersion(int *verMaj, int *verMin) // On OS X versions prior to 10.10 NSProcessInfo does not provide the OS version // Deprecated Gestalt calls are required instead wxGCC_WARNING_SUPPRESS(deprecated-declarations) - SInt32 maj, min; + SInt32 maj, min, micro; #ifdef __WXOSX_IPHONE__ maj = 7; min = 0; + micro = 0; #else Gestalt(gestaltSystemVersionMajor, &maj); Gestalt(gestaltSystemVersionMinor, &min); + Gestalt(gestaltSystemVersionBugFix, µ); #endif wxGCC_WARNING_RESTORE() @@ -62,6 +67,9 @@ wxGCC_WARNING_RESTORE() if ( verMin != NULL ) *verMin = min; + + if ( verMicro != NULL ) + *verMicro = micro; } return wxOS_MAC_OSX_DARWIN; diff --git a/src/unix/utilsunx.cpp b/src/unix/utilsunx.cpp index a0db944983..fdde571959 100644 --- a/src/unix/utilsunx.cpp +++ b/src/unix/utilsunx.cpp @@ -1114,7 +1114,7 @@ wxLinuxDistributionInfo wxGetLinuxDistributionInfo() // these functions are in src/osx/utilsexc_base.cpp for wxMac #ifndef __DARWIN__ -wxOperatingSystemId wxGetOsVersion(int *verMaj, int *verMin) +wxOperatingSystemId wxGetOsVersion(int *verMaj, int *verMin, int *verMicro) { // get OS version int major, minor; @@ -1131,6 +1131,8 @@ wxOperatingSystemId wxGetOsVersion(int *verMaj, int *verMin) *verMaj = major; if ( verMin ) *verMin = minor; + if ( verMicro ) + *verMicro = (major == -1) ? -1 : 0; // try to understand which OS are we running wxString kernel = wxGetCommandOutput(wxT("uname -s"));