Skip to content

Conversation

@paveljanik
Copy link
Contributor

LABEL: Mac
The current master emits this warning on OS X Yosemite Version 10.10:

qt/guiutil.cpp:699:9: warning: 'LSSharedFileListItemResolve' is deprecated: first deprecated in OS X 10.10 - Use LSSharedFileListItemCopyResolvedURL instead. [-Wdeprecated-declarations]
        LSSharedFileListItemResolve(item, resolutionFlags, &currentItemURL, __null);
        ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Headers/LSSharedFileList.h:943:1: note: 'LSSharedFileListItemResolve' has been explicitly marked deprecated here
LSSharedFileListItemResolve(
^
1 warning generated.

Change the code to use the new semantics on the 10.10 and higher systems.

@jonasschnelli
Copy link
Contributor

Check the travis build: it seems that the travis build jumps into the LSSharedFileListItemCopyResolvedURL which obvisouly is not available < OSX 10.10 (travis builds with 10.7).
You might check your if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_10.

Testes on OSX 10.10. Build works fine.
Manipulating Startup-Flag works on 10.10.

Will build and test on 10.9 after you made Travis happy.

@paveljanik
Copy link
Contributor Author

@jonasschnelli Can you please test on 10.9 even now? Maybe this is bug in how travis builds...

@jonasschnelli
Copy link
Contributor

Just built on a official OSX 10.9. Works fine. No more warning.
Maybe the source problem lies here: https://opensource.apple.com/source/CarbonHeaders/CarbonHeaders-18.1/AvailabilityMacros.h

It doesn't look that the open-source implementations where up to date up till 10.9,10.10.

@jonasschnelli
Copy link
Contributor

Tested on OSX 10.9 and 10.10.

ACK.

@theuni
Copy link
Member

theuni commented Dec 15, 2014

NACK. This needs to be a bit more complicated, I'm afraid.

There are a few things to keep in mind about the sdk versioning. Mainly, the SDK used for building, and the one used (by the user on a different machine) at runtime. To simplify, I'll expand on the two most extreme scenarios.

  1. Building against the 10.10 sdk with -mmacosx-version-min=10.6. This allows for 10.10 functions to be used when possible while retaining compatibility with 10.6. However, these features may not be available if the user is running <10.10, so they need to be checked before use.
  2. Building against the 10.6 sdk with no min version set. It doesn't know anything about 10.10 features, so support is never compiled in. It also has no idea what MAC_OS_X_VERSION_10_10 is.

We can build against 10.7 sdk (as we currently do for releases, with -mmacosx-version-min=10.6) such that old versions are still supported, and new features are used if they're detected at runtime. When we bump to newer SDKs or change mmacosx-version-min, everything continues to work as intended.

Something like this should cover all cases, I believe (untested, may need an AvailabilityMacros.h include):

#ifndef NSAppKitVersionNumber10_10
#define NSAppKitVersionNumber10_10 1343
#endif

#if defined(MAC_OS_X_VERSION_MAX_ALLOWED)
  #if MAC_OS_X_VERSION_MAX_ALLOWED < 10100
    // Built using < 10.10 sdk
    LSSharedFileListItemResolve(item, resolutionFlags, &currentItemURL, NULL);
  #else
    // Built using >= 10.10 sdk and detected >= 10.10 at runtime
    if (floor(NSAppKitVersionNumber) >= NSAppKitVersionNumber10_10)
        currentItemURL = LSSharedFileListItemCopyResolvedURL(item, resolutionFlags, NULL);
    #if MAC_OS_X_VERSION_MIN_REQUIRED < 10100
    else // Built using >= 10.10 sdk with back-compat and detected < 10.10 at runtime
        LSSharedFileListItemResolve(item, resolutionFlags, &currentItemURL, NULL);
    #endif
  #endif
#endif

@jonasschnelli
Copy link
Contributor

Uh. Thanks cfields! You totally right.

@laanwj
Copy link
Member

laanwj commented Dec 16, 2014

If you need all that crazyness just to work around a deprecation warning...

@paveljanik
Copy link
Contributor Author

@cfields Uff, yes.
There should be a #else branch for !defined MAC_OS_X_VERSION_MAX_ALLOWED.
So the question is how complicated we want this to be...
@wumpus right now, it is deprecation warning, but after a few months/years, our code won't run on all systems and we have to handle run time compatibility anyway.

@paveljanik
Copy link
Contributor Author

But it is not fun, I agree ;-)

@fanquake
Copy link
Member

I'm looking forward to when we can drop 10.6 compat, and just set 10.7 as the minimum osx.

@wumpus
Copy link

wumpus commented Dec 16, 2014

Not the right wumpus!

@jonasschnelli
Copy link
Contributor

@wumpus Greg Lindahl / could you please stop spamming. Thanks.
Incident has been reported to Github.

@laanwj
Copy link
Member

laanwj commented Dec 16, 2014

Huh, spamming? Mr wumpus was just replying because @paveljanik highlighted the wrong person. He's the one that should stand in the corner, if anyone :)

@jonasschnelli
Copy link
Contributor

@laanwj Yes. Sorry. IRC/Github mix.

@paveljanik paveljanik force-pushed the deprecate_LSSharedFileListItemResolve branch from 3a7b475 to 121f0d9 Compare December 16, 2014 18:49
@paveljanik
Copy link
Contributor Author

OK, @cfields's version used.

@paveljanik
Copy link
Contributor Author

Travis OK.
OS X 10.10 OK.

@paveljanik
Copy link
Contributor Author

OS X 10.9 OK too.

@fanquake
Copy link
Member

@paveljanik Following up from the recent SDK changes, cfields has suggested a new patch.

#if defined(MAC_OS_X_VERSION_MAX_ALLOWED) && MAC_OS_X_VERSION_MAX_ALLOWED >= 10100
  if(&LSSharedFileListItemCopyResolvedURL)
    currentItemURL = LSSharedFileListItemCopyResolvedURL(item, resolutionFlags, NULL);
  else
#endif
    currentItemURL = LSSharedFileListItemResolve(item, resolutionFlags, &currentItemURL, NULL);

@theuni
Copy link
Member

theuni commented Jan 21, 2015

After looking at that again, we'd still get the deprecation warning with the above code. One more try:

#if defined(MAC_OS_X_VERSION_MAX_ALLOWED) && MAC_OS_X_VERSION_MAX_ALLOWED >= 10100
  if(&LSSharedFileListItemCopyResolvedURL)
    currentItemURL = LSSharedFileListItemCopyResolvedURL(item, resolutionFlags, NULL);
  #if defined(MAC_OS_X_VERSION_MIN_REQUIRED) && MAC_OS_X_VERSION_MIN_REQUIRED < 10100
  else
    currentItemURL = LSSharedFileListItemResolve(item, resolutionFlags, &currentItemURL, NULL);
  #endif
#else
  currentItemURL = LSSharedFileListItemResolve(item, resolutionFlags, &currentItemURL, NULL);
#endif

@paveljanik paveljanik force-pushed the deprecate_LSSharedFileListItemResolve branch from 121f0d9 to 9100f97 Compare January 21, 2015 06:49
@paveljanik
Copy link
Contributor Author

Updated.

@paveljanik paveljanik force-pushed the deprecate_LSSharedFileListItemResolve branch from 9100f97 to 6bbca99 Compare January 21, 2015 18:07
@paveljanik
Copy link
Contributor Author

fixed the wrong assignment, waiting for Travis.

@paveljanik
Copy link
Contributor Author

Builds without warning now on Travis and native OS X 10.10.

@laanwj laanwj merged commit 6bbca99 into bitcoin:master Jan 29, 2015
laanwj added a commit that referenced this pull request Jan 29, 2015
6bbca99 LSSharedFileListItemResolve() was deprecated in Mac OS X 10.10, use LSSharedFileListItemCopyResolvedURL() instead (Cory Fields)
@paveljanik paveljanik deleted the deprecate_LSSharedFileListItemResolve branch January 29, 2015 12:32
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Sep 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants