Avoid run-time warnings for OS X version checks under 10.10+.

Remove UMAGetSystemVersion() function calling which produced the following
warning on the console for every call:

WARNING: The Gestalt selector gestaltSystemVersion is returning 10.9.4 instead
of 10.10.4. Use NSProcessInfo's operatingSystemVersion property to get correct
system version number.*

Replace UMAGetSystemVersion with wxPlatformInfo::CheckOSVersion() which
internally uses wxGetOSVersion, which uses Gestalt calls not resulting in this
runtime warning.

Closes https://github.com/wxWidgets/wxWidgets/pull/55
This commit is contained in:
Tobias Taschner
2015-08-01 21:51:33 +02:00
committed by Vadim Zeitlin
parent 237739ba01
commit 658eca2896
5 changed files with 7 additions and 18 deletions

View File

@@ -54,8 +54,6 @@
// wxBase part of it).
#include <Carbon/Carbon.h>
WXDLLIMPEXP_BASE long UMAGetSystemVersion() ;
void WXDLLIMPEXP_CORE wxMacStringToPascal( const wxString&from , unsigned char * to );
wxString WXDLLIMPEXP_CORE wxMacMakeStringFromPascal( const unsigned char * from );

View File

@@ -15,6 +15,7 @@
#include "wx/power.h"
#include "wx/atomic.h"
#include "wx/platinfo.h"
#include "wx/osx/private.h"
#include <IOKit/pwr_mgt/IOPMLib.h>
@@ -37,7 +38,7 @@ bool UpdatePowerResourceUsage(wxPowerResourceKind kind, const wxString& reason)
cfreason = wxString("User Activity");
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_9
if ( UMAGetSystemVersion() >= 0x1090 )
if ( wxPlatformInfo::Get().CheckOSVersion(10, 9) )
{
// Use NSProcessInfo for 10.9 and newer
if ( !g_processInfoActivity )
@@ -82,7 +83,7 @@ bool UpdatePowerResourceUsage(wxPowerResourceKind kind, const wxString& reason)
{
// Release power assertion
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_9
if ( UMAGetSystemVersion() >= 0x1090 )
if ( wxPlatformInfo::Get().CheckOSVersion(10, 9) )
{
// Use NSProcessInfo for 10.9 and newer
if ( g_processInfoActivity )

View File

@@ -11,6 +11,7 @@
#include "wx/wxprec.h"
#include "wx/utils.h"
#include "wx/platinfo.h"
#ifndef WX_PRECOMP
#include "wx/intl.h"
@@ -346,7 +347,7 @@ void wxBell()
ProcessSerialNumber psn = { 0, kCurrentProcess };
TransformProcessType(&psn, kProcessTransformToForegroundApplication);
if ( UMAGetSystemVersion() >= 0x1090 )
if ( wxPlatformInfo::Get().CheckOSVersion(10, 9) )
{
[[NSRunningApplication currentApplication] activateWithOptions:
(NSApplicationActivateAllWindows | NSApplicationActivateIgnoringOtherApps)];

View File

@@ -55,18 +55,6 @@ wxSocketManager *wxOSXSocketManagerCF = NULL;
#if ( !wxUSE_GUI && !wxOSX_USE_IPHONE ) || wxOSX_USE_COCOA_OR_CARBON
// have a fast version for mac code that returns the version as a return value
long UMAGetSystemVersion()
{
static SInt32 sUMASystemVersion = 0 ;
if ( sUMASystemVersion == 0 )
{
verify_noerr(Gestalt(gestaltSystemVersion, &sUMASystemVersion));
}
return sUMASystemVersion ;
}
// our OS version is the same in non GUI and GUI cases
wxOperatingSystemId wxGetOsVersion(int *majorVsn, int *minorVsn)
{

View File

@@ -34,6 +34,7 @@
#include "wx/menuitem.h"
#include "wx/treectrl.h"
#include "wx/listctrl.h"
#include "wx/platinfo.h"
#endif
#include "wx/tooltip.h"
@@ -2215,7 +2216,7 @@ bool wxWindowMac::MacHasScrollBarCorner() const
if ( frame )
{
// starting from 10.7 there are no resize indicators anymore
if ( (frame->GetWindowStyleFlag() & wxRESIZE_BORDER) && UMAGetSystemVersion() < 0x1070)
if ( (frame->GetWindowStyleFlag() & wxRESIZE_BORDER) && !wxPlatformInfo::Get().CheckOSVersion(10, 7) )
{
// Parent frame has resize handle
wxPoint frameBottomRight = frame->GetScreenRect().GetBottomRight();