diff --git a/docs/changes.txt b/docs/changes.txt index 56733f93a9..e01e2cfe40 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -34,6 +34,10 @@ Changes in behaviour not resulting in compilation errors - wxOSX/Carbon port doesn't exist any more, wxOSX/Cocoa will be silently used instead even if configure --with-osx_carbon option is used. +- The pure virtual function wxAppTrait::GetToolkitVersion() now has a parameter + for getting the micro version. If you override GetToolkitVersion() you need + to add this new third parameter. + Changes in behaviour which may result in build errors ----------------------------------------------------- @@ -100,6 +104,8 @@ All: - Fix wxStringTokenizer copy ctor and assignment operator. - Added wxASSERT_MSG_AT() and wxFAIL_MSG_AT() macros. - Accept replacement character in wxString::ToAscii() (Stefano D. Mtangoo). +- Add parameter to get the micro version to OS and toolkit version + functions. See wxGetOsVersion(), wxPlatformInfo, and wxAppTraits. Unix: diff --git a/include/wx/apptrait.h b/include/wx/apptrait.h index f459bbe908..d69a7b964c 100644 --- a/include/wx/apptrait.h +++ b/include/wx/apptrait.h @@ -130,7 +130,9 @@ public: // runtime (not compile-time) version. // returns wxPORT_BASE for console applications and one of the remaining // wxPORT_* values for GUI applications. - virtual wxPortId GetToolkitVersion(int *majVer = NULL, int *minVer = NULL) const = 0; + virtual wxPortId GetToolkitVersion(int *majVer = NULL, + int *minVer = NULL, + int *microVer = NULL) const = 0; // return true if the port is using wxUniversal for the GUI, false if not virtual bool IsUsingUniversalWidgets() const = 0; @@ -209,13 +211,16 @@ public: virtual bool HasStderr() wxOVERRIDE; // the GetToolkitVersion for console application is always the same - virtual wxPortId GetToolkitVersion(int *verMaj = NULL, int *verMin = NULL) const wxOVERRIDE + wxPortId GetToolkitVersion(int *verMaj = NULL, + int *verMin = NULL, + int *verMicro = NULL) const wxOVERRIDE { // no toolkits (wxBase is for console applications without GUI support) // NB: zero means "no toolkit", -1 means "not initialized yet" // so we must use zero here! if (verMaj) *verMaj = 0; if (verMin) *verMin = 0; + if (verMicro) *verMicro = 0; return wxPORT_BASE; } diff --git a/include/wx/msw/apptrait.h b/include/wx/msw/apptrait.h index 6a968fe1ab..d7466482a6 100644 --- a/include/wx/msw/apptrait.h +++ b/include/wx/msw/apptrait.h @@ -49,7 +49,9 @@ public: virtual bool DoMessageFromThreadWait(); virtual WXDWORD WaitForThread(WXHANDLE hThread, int flags); #endif // wxUSE_THREADS - virtual wxPortId GetToolkitVersion(int *majVer = NULL, int *minVer = NULL) const; + wxPortId GetToolkitVersion(int *majVer = NULL, + int *minVer = NULL, + int *microVer = NULL) const wxOVERRIDE; virtual bool CanUseStderr(); virtual bool WriteToStderr(const wxString& text); @@ -77,7 +79,9 @@ public: virtual WXDWORD WaitForThread(WXHANDLE hThread, int WXUNUSED(flags)) { return DoSimpleWaitForThread(hThread); } #endif // wxUSE_THREADS - virtual wxPortId GetToolkitVersion(int *majVer = NULL, int *minVer = NULL) const; + virtual wxPortId GetToolkitVersion(int *majVer = NULL, + int *minVer = NULL, + int *microVer = NULL) const; virtual bool CanUseStderr() { return false; } virtual bool WriteToStderr(const wxString& WXUNUSED(text)) { return false; } diff --git a/include/wx/platinfo.h b/include/wx/platinfo.h index 9802f19018..cc13959567 100644 --- a/include/wx/platinfo.h +++ b/include/wx/platinfo.h @@ -188,21 +188,27 @@ public: { return m_osVersionMajor; } int GetOSMinorVersion() const { return m_osVersionMinor; } + int GetOSMicroVersion() const + { return m_osVersionMicro; } // return true if the OS version >= major.minor - bool CheckOSVersion(int major, int minor) const; + bool CheckOSVersion(int major, int minor, int micro = 0) const; int GetToolkitMajorVersion() const { return m_tkVersionMajor; } int GetToolkitMinorVersion() const { return m_tkVersionMinor; } + int GetToolkitMicroVersion() const + { return m_tkVersionMicro; } - bool CheckToolkitVersion(int major, int minor) const + bool CheckToolkitVersion(int major, int minor, int micro = 0) const { return DoCheckVersion(GetToolkitMajorVersion(), GetToolkitMinorVersion(), + GetToolkitMicroVersion(), major, - minor); + minor, + micro); } bool IsUsingUniversalWidgets() const @@ -249,10 +255,19 @@ public: // setters // ----------------- - void SetOSVersion(int major, int minor) - { m_osVersionMajor=major; m_osVersionMinor=minor; } - void SetToolkitVersion(int major, int minor) - { m_tkVersionMajor=major; m_tkVersionMinor=minor; } + void SetOSVersion(int major, int minor, int micro = 0) + { + m_osVersionMajor = major; + m_osVersionMinor = minor; + m_osVersionMicro = micro; + } + + void SetToolkitVersion(int major, int minor, int micro = 0) + { + m_tkVersionMajor = major; + m_tkVersionMinor = minor; + m_tkVersionMicro = micro; + } void SetOperatingSystemId(wxOperatingSystemId n) { m_os = n; } @@ -277,9 +292,11 @@ public: bool IsOk() const { return m_osVersionMajor != -1 && m_osVersionMinor != -1 && + m_osVersionMicro != -1 && m_os != wxOS_UNKNOWN && !m_osDesc.IsEmpty() && m_tkVersionMajor != -1 && m_tkVersionMinor != -1 && + m_tkVersionMicro != -1 && m_port != wxPORT_UNKNOWN && m_arch != wxARCH_INVALID && m_endian != wxENDIAN_INVALID; @@ -289,9 +306,12 @@ public: protected: - static bool DoCheckVersion(int majorCur, int minorCur, int major, int minor) + static bool DoCheckVersion(int majorCur, int minorCur, int microCur, + int major, int minor, int micro) { - return majorCur > major || (majorCur == major && minorCur >= minor); + return majorCur > major + || (majorCur == major && minorCur > minor) + || (majorCur == major && minorCur == minor && microCur >= micro); } bool m_initializedForCurrentPlatform; @@ -305,7 +325,8 @@ protected: // Version of the OS; valid if m_os != wxOS_UNKNOWN // (-1 means not initialized yet). int m_osVersionMajor, - m_osVersionMinor; + m_osVersionMinor, + m_osVersionMicro; // Operating system ID. wxOperatingSystemId m_os; @@ -326,7 +347,7 @@ protected: // Version of the underlying toolkit // (-1 means not initialized yet; zero means no toolkit). - int m_tkVersionMajor, m_tkVersionMinor; + int m_tkVersionMajor, m_tkVersionMinor, m_tkVersionMicro; // name of the wxWidgets port wxPortId m_port; diff --git a/include/wx/unix/apptrait.h b/include/wx/unix/apptrait.h index 509007c51b..dc96980526 100644 --- a/include/wx/unix/apptrait.h +++ b/include/wx/unix/apptrait.h @@ -61,7 +61,9 @@ public: #if defined(__WXMAC__) && wxUSE_STDPATHS virtual wxStandardPaths& GetStandardPaths() wxOVERRIDE; #endif - virtual wxPortId GetToolkitVersion(int *majVer = NULL, int *minVer = NULL) const wxOVERRIDE; + wxPortId GetToolkitVersion(int *majVer = NULL, + int *minVer = NULL, + int *microVer = NULL) const wxOVERRIDE; #ifdef __WXGTK20__ virtual wxString GetDesktopEnvironment() const wxOVERRIDE; diff --git a/include/wx/utils.h b/include/wx/utils.h index e29c131697..eda281cb8d 100644 --- a/include/wx/utils.h +++ b/include/wx/utils.h @@ -140,11 +140,12 @@ WXDLLIMPEXP_CORE wxVersionInfo wxGetLibraryVersionInfo(); WXDLLIMPEXP_BASE wxString wxGetOsDescription(); // Get OS version -WXDLLIMPEXP_BASE wxOperatingSystemId wxGetOsVersion(int *majorVsn = NULL, - int *minorVsn = NULL); +WXDLLIMPEXP_BASE wxOperatingSystemId wxGetOsVersion(int *verMaj = 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); +WXDLLIMPEXP_BASE bool wxCheckOsVersion(int majorVsn, int minorVsn = 0, int microVsn = 0); // Get platform endianness WXDLLIMPEXP_BASE bool wxIsPlatformLittleEndian(); diff --git a/interface/wx/apptrait.h b/interface/wx/apptrait.h index d4f8ff10d3..9eff45d838 100644 --- a/interface/wx/apptrait.h +++ b/interface/wx/apptrait.h @@ -100,8 +100,8 @@ public: /** Returns the wxWidgets port ID used by the running program and eventually - fills the given pointers with the values of the major and minor digits - of the native toolkit currently used. + fills the given pointers with the values of the major, minor, and micro + digits of the native toolkit currently used. The version numbers returned are thus detected at run-time and not compile-time (except when this is not possible e.g. wxMotif). @@ -109,8 +109,12 @@ public: E.g. if your program is using wxGTK port this function will return wxPORT_GTK and put in given pointers the versions of the GTK library in use. See wxPlatformInfo for more details. + + If a micro version is not available it will have a value of 0. */ - virtual wxPortId GetToolkitVersion(int* major = NULL, int* minor = NULL) const = 0; + virtual wxPortId GetToolkitVersion(int* major = NULL, + int* minor = NULL, + int* micro = NULL) const = 0; /** Returns @true if @c fprintf(stderr) goes somewhere, @false otherwise. diff --git a/interface/wx/platinfo.h b/interface/wx/platinfo.h index 44b112fb90..601b145524 100644 --- a/interface/wx/platinfo.h +++ b/interface/wx/platinfo.h @@ -12,11 +12,11 @@ The values of the constants are chosen so that they can be combined as flags; this allows to check for operating system families like e.g. @c wxOS_MAC and @c wxOS_UNIX. - + Note that you can obtain more detailed information about the current OS - version in use by checking the major and minor version numbers returned - by ::wxGetOsVersion() or by wxPlatformInfo::GetOSMajorVersion(), - wxPlatformInfo::GetOSMinorVersion(). + version in use by checking the major, minor, and micro version numbers + returned by ::wxGetOsVersion() or by wxPlatformInfo::GetOSMajorVersion(), + wxPlatformInfo::GetOSMinorVersion(), and wxPlatformInfo::GetOSMicroVersion(). */ enum wxOperatingSystemId { @@ -177,21 +177,20 @@ public: /** - Returns @true if the OS version is at least @c major.minor. + Returns @true if the OS version is at least @c major.minor.micro. - @see GetOSMajorVersion(), GetOSMinorVersion(), + @see GetOSMajorVersion(), GetOSMinorVersion(), GetOSMicroVersion(), CheckToolkitVersion() */ - bool CheckOSVersion(int major, int minor) const; + bool CheckOSVersion(int major, int minor, int micro = 0) const; /** - Returns @true if the toolkit version is at least @c major.minor. + Returns @true if the toolkit version is at least @c major.minor.micro. - @see GetToolkitMajorVersion(), - GetToolkitMinorVersion(), CheckOSVersion() + @see GetToolkitMajorVersion(), GetToolkitMinorVersion(), + GetToolkitMicroVersion(), CheckOSVersion() */ - bool CheckToolkitVersion(int major, int minor) const; - + bool CheckToolkitVersion(int major, int minor, int micro = 0) const; /** Returns @true if this instance is fully initialized with valid values. @@ -348,6 +347,16 @@ public: */ int GetOSMinorVersion() const; + /** + Returns the run-time micro version of the OS associated with this + wxPlatformInfo instance. + + @see ::wxGetOsVersion(), CheckOSVersion() + + @since 3.1.1 + */ + int GetOSMicroVersion() const; + /** Returns the operating system ID of this wxPlatformInfo instance. @@ -406,7 +415,22 @@ public: @see CheckToolkitVersion() */ int GetToolkitMinorVersion() const; - + + /** + Returns the run-time micro version of the toolkit associated with this + wxPlatformInfo instance. + + Note that if GetPortId() returns @c wxPORT_BASE, then this value is zero + (unless externally modified with SetToolkitVersion()); that is, no native + toolkit is in use. + See wxAppTraits::GetToolkitVersion() for more info. + + @see CheckToolkitVersion() + + @since 3.1.1 + */ + int GetToolkitMicroVersion() const; + //@} @@ -472,7 +496,7 @@ public: Sets the version of the operating system associated with this wxPlatformInfo instance. */ - void SetOSVersion(int major, int minor); + void SetOSVersion(int major, int minor, int micro = 0); /** Sets the operating system associated with this wxPlatformInfo instance. @@ -487,7 +511,7 @@ public: /** Sets the version of the toolkit associated with this wxPlatformInfo instance. */ - void SetToolkitVersion(int major, int minor); + void SetToolkitVersion(int major, int minor, int micro = 0); /** Sets the operating system description associated with this wxPlatformInfo instance. diff --git a/interface/wx/utils.h b/interface/wx/utils.h index 9b48602183..4b640351dc 100644 --- a/interface/wx/utils.h +++ b/interface/wx/utils.h @@ -842,16 +842,23 @@ 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. - - 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. + 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, minor, and micro version + integers will contain the kernel's major, minor, and micro version + numbers (as returned by the 'uname -r' command); e.g. "4", "1", and "4" 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 +885,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 @@ -890,7 +897,7 @@ wxOperatingSystemId wxGetOsVersion(int* major = NULL, int* minor = NULL); @header{wx/utils.h} */ -bool wxCheckOsVersion(int majorVsn, int minorVsn = 0); +bool wxCheckOsVersion(int majorVsn, int minorVsn = 0, int microVsn = 0); /** Returns @true if the operating system the program is running under is 64 diff --git a/src/common/platinfo.cpp b/src/common/platinfo.cpp index 41fd0c23db..f9d9b93aef 100644 --- a/src/common/platinfo.cpp +++ b/src/common/platinfo.cpp @@ -139,12 +139,14 @@ wxPlatformInfo::wxPlatformInfo(wxPortId pid, int tkMajor, int tkMinor, m_tkVersionMajor = tkMajor; m_tkVersionMinor = tkMinor; + m_tkVersionMicro = -1; m_port = pid; m_usingUniversal = usingUniversal; m_os = id; m_osVersionMajor = osMajor; m_osVersionMinor = osMinor; + m_osVersionMicro = -1; m_endian = endian; m_arch = arch; @@ -154,8 +156,10 @@ bool wxPlatformInfo::operator==(const wxPlatformInfo &t) const { return m_tkVersionMajor == t.m_tkVersionMajor && m_tkVersionMinor == t.m_tkVersionMinor && + m_tkVersionMicro == t.m_tkVersionMicro && m_osVersionMajor == t.m_osVersionMajor && m_osVersionMinor == t.m_osVersionMinor && + m_osVersionMicro == t.m_osVersionMicro && m_os == t.m_os && m_osDesc == t.m_osDesc && m_ldi == t.m_ldi && @@ -179,16 +183,18 @@ void wxPlatformInfo::InitForCurrentPlatform() m_port = wxPORT_UNKNOWN; m_usingUniversal = false; m_tkVersionMajor = - m_tkVersionMinor = 0; + m_tkVersionMinor = + m_tkVersionMicro = 0; } else { - m_port = traits->GetToolkitVersion(&m_tkVersionMajor, &m_tkVersionMinor); + m_port = traits->GetToolkitVersion(&m_tkVersionMajor, &m_tkVersionMinor, + &m_tkVersionMicro); m_usingUniversal = traits->IsUsingUniversalWidgets(); m_desktopEnv = traits->GetDesktopEnvironment(); } - m_os = wxGetOsVersion(&m_osVersionMajor, &m_osVersionMinor); + m_os = wxGetOsVersion(&m_osVersionMajor, &m_osVersionMinor, &m_osVersionMicro); m_osDesc = wxGetOsDescription(); m_endian = wxIsPlatformLittleEndian() ? wxENDIAN_LITTLE : wxENDIAN_BIG; m_arch = wxIsPlatform64Bit() ? wxARCH_64 : wxARCH_32; @@ -298,18 +304,20 @@ wxString wxPlatformInfo::GetEndiannessName(wxEndianness end) return wxEndiannessNames[end]; } -bool wxPlatformInfo::CheckOSVersion(int major, int minor) const +bool wxPlatformInfo::CheckOSVersion(int major, int minor, int micro) const { // If this instance of wxPlatformInfo has been initialized by InitForCurrentPlatform() // this check gets forwarded to the wxCheckOsVersion which might do more than a simple // number check if supported by the platform if (m_initializedForCurrentPlatform) - return wxCheckOsVersion(major, minor); + return wxCheckOsVersion(major, minor, micro); else return DoCheckVersion(GetOSMajorVersion(), GetOSMinorVersion(), + GetOSMicroVersion(), major, - minor); + minor, + micro); } // ---------------------------------------------------------------------------- diff --git a/src/dfb/utils.cpp b/src/dfb/utils.cpp index 4c9c853275..57e9a3d1a1 100644 --- a/src/dfb/utils.cpp +++ b/src/dfb/utils.cpp @@ -30,10 +30,13 @@ // toolkit info // ---------------------------------------------------------------------------- -wxPortId wxGUIAppTraits::GetToolkitVersion(int *verMaj, int *verMin) const +wxPortId wxGUIAppTraits::GetToolkitVersion(int *verMaj, + int *verMin, + int *verMicro) const { if ( verMaj ) *verMaj = DIRECTFB_MAJOR_VERSION; if ( verMin ) *verMaj = DIRECTFB_MINOR_VERSION; + if ( verMicro ) *verMicro = DIRECTFB_MICRO_VERSION; return wxPORT_DFB; } diff --git a/src/gtk/utilsgtk.cpp b/src/gtk/utilsgtk.cpp index 36c5013722..a4e3895ffb 100644 --- a/src/gtk/utilsgtk.cpp +++ b/src/gtk/utilsgtk.cpp @@ -183,12 +183,16 @@ const gchar *wx_pango_version_check (int major, int minor, int micro) // wxPlatformInfo-related // ---------------------------------------------------------------------------- -wxPortId wxGUIAppTraits::GetToolkitVersion(int *verMaj, int *verMin) const +wxPortId wxGUIAppTraits::GetToolkitVersion(int *verMaj, + int *verMin, + int *verMicro) const { if ( verMaj ) *verMaj = gtk_major_version; if ( verMin ) *verMin = gtk_minor_version; + if ( verMicro ) + *verMicro = gtk_micro_version; return wxPORT_GTK; } diff --git a/src/gtk1/utilsgtk.cpp b/src/gtk1/utilsgtk.cpp index 4b1b170f74..c912fc9a9a 100644 --- a/src/gtk1/utilsgtk.cpp +++ b/src/gtk1/utilsgtk.cpp @@ -136,12 +136,16 @@ wxTimerImpl* wxGUIAppTraits::CreateTimerImpl(wxTimer *timer) // wxPlatformInfo-related // ---------------------------------------------------------------------------- -wxPortId wxGUIAppTraits::GetToolkitVersion(int *verMaj, int *verMin) const +wxPortId wxGUIAppTraits::GetToolkitVersion(int *verMaj, + int *verMin, + int *verMicro) const { if ( verMaj ) *verMaj = gtk_major_version; if ( verMin ) *verMin = gtk_minor_version; + if ( verMicro ) + *verMicro = gtk_micro_version; return wxPORT_GTK; } diff --git a/src/motif/utils.cpp b/src/motif/utils.cpp index 4700c3c329..d440bb0887 100644 --- a/src/motif/utils.cpp +++ b/src/motif/utils.cpp @@ -176,13 +176,17 @@ void wxBell() XBell (wxGlobalDisplay(), 0); } -wxPortId wxGUIAppTraits::GetToolkitVersion(int *verMaj, int *verMin) const +wxPortId wxGUIAppTraits::GetToolkitVersion(int *verMaj, + int *verMin, + int *verMicro) const { // XmVERSION and XmREVISION are defined in Xm/Xm.h if ( verMaj ) *verMaj = XmVERSION; if ( verMin ) *verMin = XmREVISION; + if ( verMicro ) + *verMicro = 0; return wxPORT_MOTIF; } diff --git a/src/msw/app.cpp b/src/msw/app.cpp index 860bde87e3..e808d98e97 100644 --- a/src/msw/app.cpp +++ b/src/msw/app.cpp @@ -238,11 +238,13 @@ WXDWORD wxGUIAppTraits::WaitForThread(WXHANDLE hThread, int flags) } #endif // wxUSE_THREADS -wxPortId wxGUIAppTraits::GetToolkitVersion(int *majVer, int *minVer) const +wxPortId wxGUIAppTraits::GetToolkitVersion(int *majVer, + int *minVer, + int *microVer) const { // on Windows, the toolkit version is the same of the OS version // as Windows integrates the OS kernel with the GUI toolkit. - wxGetOsVersion(majVer, minVer); + wxGetOsVersion(majVer, minVer, microVer); return wxPORT_MSW; } diff --git a/src/msw/utils.cpp b/src/msw/utils.cpp index 59873f6708..95506b9097 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 { @@ -1244,7 +1244,8 @@ wxOperatingSystemId wxGetOsVersion(int *verMaj, int *verMin) wxOperatingSystemId os; int verMaj, - verMin; + verMin, + verMicro; } s_version; // query the OS info only once as it's not supposed to change @@ -1267,32 +1268,39 @@ wxOperatingSystemId wxGetOsVersion(int *verMaj, int *verMin) s_version.verMaj = info.dwMajorVersion; s_version.verMin = info.dwMinorVersion; + s_version.verMicro = info.dwBuildNumber; } if ( verMaj ) *verMaj = s_version.verMaj; if ( verMin ) *verMin = s_version.verMin; + if ( verMicro ) + *verMicro = s_version.verMicro; return s_version.os; } -bool wxCheckOsVersion(int majorVsn, int minorVsn) +bool wxCheckOsVersion(int majorVsn, int minorVsn, int microVsn) { OSVERSIONINFOEX osvi; wxZeroMemory(osvi); osvi.dwOSVersionInfoSize = sizeof(osvi); DWORDLONG const dwlConditionMask = + ::VerSetConditionMask( ::VerSetConditionMask( ::VerSetConditionMask( 0, VER_MAJORVERSION, VER_GREATER_EQUAL), - VER_MINORVERSION, VER_GREATER_EQUAL); + VER_MINORVERSION, VER_GREATER_EQUAL), + VER_BUILDNUMBER, VER_GREATER_EQUAL); osvi.dwMajorVersion = majorVsn; osvi.dwMinorVersion = minorVsn; + osvi.dwBuildNumber = microVsn; - return ::VerifyVersionInfo(&osvi, VER_MAJORVERSION | VER_MINORVERSION, dwlConditionMask) != FALSE; + return ::VerifyVersionInfo(&osvi, + VER_MAJORVERSION | VER_MINORVERSION | VER_BUILDNUMBER, dwlConditionMask) != FALSE; } wxWinVersion wxGetWinVersion() diff --git a/src/osx/cocoa/utils_base.mm b/src/osx/cocoa/utils_base.mm index d59ef76416..d1a660ab1b 100644 --- a/src/osx/cocoa/utils_base.mm +++ b/src/osx/cocoa/utils_base.mm @@ -28,18 +28,21 @@ #endif // our OS version is the same in non GUI and GUI cases -wxOperatingSystemId wxGetOsVersion(int *majorVsn, int *minorVsn) +wxOperatingSystemId wxGetOsVersion(int *verMaj, int *verMin, int *verMicro) { #ifdef wxHAS_NSPROCESSINFO if ([NSProcessInfo instancesRespondToSelector:@selector(operatingSystemVersion)]) { NSOperatingSystemVersion osVer = [NSProcessInfo processInfo].operatingSystemVersion; - if ( majorVsn != NULL ) - *majorVsn = osVer.majorVersion; + if ( verMaj != NULL ) + *verMaj = osVer.majorVersion; - if ( minorVsn != NULL ) - *minorVsn = osVer.minorVersion; + if ( verMin != NULL ) + *verMin = osVer.minorVersion; + + if ( verMicro != NULL ) + *verMicro = osVer.patchVersion; } else #endif @@ -47,27 +50,32 @@ wxOperatingSystemId wxGetOsVersion(int *majorVsn, int *minorVsn) // 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() - if ( majorVsn != NULL ) - *majorVsn = maj; + if ( verMaj != NULL ) + *verMaj = maj; - if ( minorVsn != NULL ) - *minorVsn = min; + if ( verMin != NULL ) + *verMin = min; + + if ( verMicro != NULL ) + *verMicro = micro; } return wxOS_MAC_OSX_DARWIN; } -bool wxCheckOsVersion(int majorVsn, int minorVsn) +bool wxCheckOsVersion(int majorVsn, int minorVsn, int microVsn) { #ifdef wxHAS_NSPROCESSINFO if ([NSProcessInfo instancesRespondToSelector:@selector(isOperatingSystemAtLeastVersion:)]) @@ -75,17 +83,19 @@ bool wxCheckOsVersion(int majorVsn, int minorVsn) NSOperatingSystemVersion osVer; osVer.majorVersion = majorVsn; osVer.minorVersion = minorVsn; - osVer.patchVersion = 0; + osVer.patchVersion = microVsn; return [[NSProcessInfo processInfo] isOperatingSystemAtLeastVersion:osVer] != NO; } else #endif { - int majorCur, minorCur; - wxGetOsVersion(&majorCur, &minorCur); + int majorCur, minorCur, microCur; + wxGetOsVersion(&majorCur, &minorCur, µCur); - return majorCur > majorVsn || (majorCur == majorVsn && minorCur >= minorVsn); + return majorCur > majorVsn + || (majorCur == majorVsn && minorCur >= minorVsn) + || (majorCur == majorVsn && minorCur == minorVsn && microCur >= microVsn); } } diff --git a/src/osx/utils_osx.cpp b/src/osx/utils_osx.cpp index 70e2c66096..d71457c676 100644 --- a/src/osx/utils_osx.cpp +++ b/src/osx/utils_osx.cpp @@ -169,10 +169,12 @@ void wxDisplaySizeMM(int *width, int *height) } -wxPortId wxGUIAppTraits::GetToolkitVersion(int *verMaj, int *verMin) const +wxPortId wxGUIAppTraits::GetToolkitVersion(int *verMaj, + int *verMin, + int *verMicro) const { // We suppose that toolkit version is the same as OS version under Mac - wxGetOsVersion(verMaj, verMin); + wxGetOsVersion(verMaj, verMin, verMicro); return wxPORT_OSX; } diff --git a/src/qt/apptraits.cpp b/src/qt/apptraits.cpp index 1c9dfdd55d..2f747d7fb9 100644 --- a/src/qt/apptraits.cpp +++ b/src/qt/apptraits.cpp @@ -39,12 +39,16 @@ wxTimerImpl *wxGUIAppTraits::CreateTimerImpl(wxTimer *timer) // #endif -wxPortId wxGUIAppTraits::GetToolkitVersion(int *majVer, int *minVer) const +wxPortId wxGUIAppTraits::GetToolkitVersion(int *majVer, + int *minVer, + int *microVer) const { if ( majVer ) *majVer = QT_VERSION >> 16; if ( minVer ) *minVer = (QT_VERSION >> 8) & 0xFF; + if ( microVer ) + *microVer = QT_VERSION & 0xFF; return wxPORT_QT; } diff --git a/src/unix/utilsunx.cpp b/src/unix/utilsunx.cpp index a0db944983..fdaa04b17a 100644 --- a/src/unix/utilsunx.cpp +++ b/src/unix/utilsunx.cpp @@ -1114,23 +1114,30 @@ 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; + int major = -1, minor = -1, micro = -1; wxString release = wxGetCommandOutput(wxT("uname -r")); - if ( release.empty() || - wxSscanf(release.c_str(), wxT("%d.%d"), &major, &minor) != 2 ) + if ( !release.empty() ) { - // failed to get version string or unrecognized format - major = - minor = -1; + if ( wxSscanf(release.c_str(), wxT("%d.%d.%d"), &major, &minor, µ ) != 3 ) + { + micro = 0; + if ( wxSscanf(release.c_str(), wxT("%d.%d"), &major, &minor ) != 2 ) + { + // failed to get version string or unrecognized format + major = minor = micro = -1; + } + } } if ( verMaj ) *verMaj = major; if ( verMin ) *verMin = minor; + if ( verMicro ) + *verMicro = micro; // try to understand which OS are we running wxString kernel = wxGetCommandOutput(wxT("uname -s")); @@ -1148,12 +1155,14 @@ wxString wxGetOsDescription() return wxGetCommandOutput(wxT("uname -s -r -m")); } -bool wxCheckOsVersion(int majorVsn, int minorVsn) +bool wxCheckOsVersion(int majorVsn, int minorVsn, int microVsn) { - int majorCur, minorCur; - wxGetOsVersion(&majorCur, &minorCur); + int majorCur, minorCur, microCur; + wxGetOsVersion(&majorCur, &minorCur, µCur); - return majorCur > majorVsn || (majorCur == majorVsn && minorCur >= minorVsn); + return majorCur > majorVsn + || (majorCur == majorVsn && minorCur >= minorVsn) + || (majorCur == majorVsn && minorCur == minorVsn && microCur >= microVsn); } #endif // !__DARWIN__ diff --git a/src/x11/utils.cpp b/src/x11/utils.cpp index 6bbb103242..bd80ba5769 100644 --- a/src/x11/utils.cpp +++ b/src/x11/utils.cpp @@ -100,7 +100,9 @@ void wxBell() XBell ((Display*) wxGetDisplay(), 0); } -wxPortId wxGUIAppTraits::GetToolkitVersion(int *verMaj, int *verMin) const +wxPortId wxGUIAppTraits::GetToolkitVersion(int *verMaj, + int *verMin, + int *verMicro) const { // get X protocol version Display *display = wxGlobalDisplay(); @@ -110,6 +112,8 @@ wxPortId wxGUIAppTraits::GetToolkitVersion(int *verMaj, int *verMin) const *verMaj = ProtocolVersion (display); if ( verMin ) *verMin = ProtocolRevision (display); + if ( verMicro ) + *verMicro = 0; } return wxPORT_X11;