From 1c5631c97a352bac78555f35c8c654e3c2885cf2 Mon Sep 17 00:00:00 2001 From: Charlie Fenton Date: Fri, 8 Jun 2018 02:37:58 -0700 Subject: [PATCH] Mac: Patch wxWidgets 3.1.0 to fix BOINC Manager crash on OS 10.6. --- mac_build/buildWxMac.sh | 53 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 51 insertions(+), 2 deletions(-) diff --git a/mac_build/buildWxMac.sh b/mac_build/buildWxMac.sh index d0a9e584c2..cca59fa79f 100644 --- a/mac_build/buildWxMac.sh +++ b/mac_build/buildWxMac.sh @@ -2,7 +2,7 @@ # This file is part of BOINC. # http://boinc.berkeley.edu -# Copyright (C) 2017 University of California +# Copyright (C) 2018 University of California # # BOINC is free software; you can redistribute it and/or modify it # under the terms of the GNU Lesser General Public License @@ -36,6 +36,7 @@ # Update for wxCocoa 3.1.0 10/25/17 # Build only 64-bit library 1/25/18 # Fix wxWidgets 3.1.0 bug when wxStaticBox has no label 3/20/18 +# Fix wxWidgets 3.1.0 to not use backingScaleFactor API on OS 10.6 6/8/18 # ## This script requires OS 10.6 or later ## @@ -133,7 +134,7 @@ else echo "build/osx/setup/cocoa/include/wx/setup.h already patched" fi -# Patch src/osx/window_osx.cpp window_osx_patched.cpp > window_osx_cpp_diff +# Patch src/osx/window_osx.cpp if [ ! -f src/osx/window_osx.cpp.orig ]; then cat >> /tmp/window_osx_cpp_diff << ENDOFFILE --- window_osx.cpp 2016-02-28 13:33:37.000000000 -0800 @@ -155,6 +156,54 @@ else echo "src/osx/window_osx.cpp already patched" fi +# Patch src/osx/carbon/utilscocoa.mm +if [ ! -f src/osx/carbon/utilscocoa.mm.orig ]; then + cat >> /tmp/utilscocoa_mm_diff << ENDOFFILE +--- utilscocoa.mm 2016-02-28 13:33:37.000000000 -0800 ++++ utilscocoa-patched.mm 2018-06-03 01:31:43.000000000 -0700 +@@ -476,7 +476,10 @@ + + double wxOSXGetMainScreenContentScaleFactor() + { +- return [[NSScreen mainScreen] backingScaleFactor]; ++ if ([[NSScreen mainScreen] respondsToSelector:@selector(backingScaleFactor)]) ++ return [[NSScreen mainScreen] backingScaleFactor]; ++ else ++ return 1.0; + } + + CGImageRef wxOSXCreateCGImageFromNSImage( WX_NSImage nsimage, double *scaleptr ) +ENDOFFILE + patch -bfi /tmp/utilscocoa_mm_diff src/osx/carbon/utilscocoa.mm + rm -f /tmp/utilscocoa_mm_diff +else + echo "src/osx/carbon/utilscocoa.mm already patched" +fi + +# Patch src/osx/cocoa/window.mm +if [ ! -f src/osx/cocoa/window.mm.orig ]; then + cat >> /tmp/window_mm_diff << ENDOFFILE +--- window.mm 2016-02-28 13:33:37.000000000 -0800 ++++ window-patched.mm 2018-06-08 01:28:01.000000000 -0700 +@@ -1869,7 +1869,10 @@ + double wxWidgetCocoaImpl::GetContentScaleFactor() const + { + NSWindow* tlw = [m_osxView window]; +- return [tlw backingScaleFactor]; ++ if ([tlw respondsToSelector:@selector(backingScaleFactor)]) ++ return [tlw backingScaleFactor]; ++ else ++ return 1.0; + } + + // ---------------------------------------------------------------------------- +ENDOFFILE + patch -bfi /tmp/window_mm_diff src/osx/cocoa/window.mm + rm -f /tmp/window_mm_diff +else + echo "src/osx/cocoa/window.mm already patched" +fi + echo ""