OS X 10.10: LSSharedFileListItemResolve() is deprecated #5477

pull paveljanik wants to merge 1 commits into bitcoin:master from paveljanik:deprecate_LSSharedFileListItemResolve changing 1 files +12 −1
  1. paveljanik commented at 2:01 PM on December 15, 2014: 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.

  2. jonasschnelli commented at 3:19 PM on December 15, 2014: 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.

  3. paveljanik commented at 3:36 PM on December 15, 2014: contributor

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

  4. jonasschnelli commented at 3:49 PM on December 15, 2014: 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.

  5. jonasschnelli commented at 6:57 PM on December 15, 2014: contributor

    Tested on OSX 10.9 and 10.10.

    ACK.

  6. theuni commented at 8:43 PM on December 15, 2014: member

    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
    
  7. jonasschnelli commented at 5:10 AM on December 16, 2014: contributor

    Uh. Thanks cfields! You totally right.

  8. laanwj commented at 7:19 AM on December 16, 2014: member

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

  9. paveljanik commented at 7:27 AM on December 16, 2014: contributor

    @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.

  10. paveljanik commented at 7:27 AM on December 16, 2014: contributor

    But it is not fun, I agree ;-)

  11. fanquake commented at 7:33 AM on December 16, 2014: member

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

  12. wumpus commented at 8:58 AM on December 16, 2014: none

    Not the right wumpus!

  13. jonasschnelli commented at 9:01 AM on December 16, 2014: contributor

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

  14. laanwj commented at 9:18 AM on December 16, 2014: member

    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 :)

  15. jonasschnelli commented at 9:25 AM on December 16, 2014: contributor

    @laanwj Yes. Sorry. IRC/Github mix.

  16. paveljanik force-pushed on Dec 16, 2014
  17. paveljanik commented at 6:50 PM on December 16, 2014: contributor

    OK, @cfields's version used.

  18. paveljanik commented at 8:16 PM on December 16, 2014: contributor

    Travis OK. OS X 10.10 OK.

  19. paveljanik commented at 11:45 PM on December 16, 2014: contributor

    OS X 10.9 OK too.

  20. laanwj added the label Priority Low on Jan 8, 2015
  21. laanwj added the label Mac on Jan 8, 2015
  22. fanquake commented at 3:06 AM on January 21, 2015: 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);
    
  23. theuni commented at 3:47 AM on January 21, 2015: member

    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
    
  24. paveljanik force-pushed on Jan 21, 2015
  25. paveljanik commented at 6:51 AM on January 21, 2015: contributor

    Updated.

  26. LSSharedFileListItemResolve() was deprecated in Mac OS X 10.10, use LSSharedFileListItemCopyResolvedURL() instead 6bbca99baa
  27. paveljanik force-pushed on Jan 21, 2015
  28. paveljanik commented at 6:08 PM on January 21, 2015: contributor

    fixed the wrong assignment, waiting for Travis.

  29. paveljanik commented at 6:49 PM on January 21, 2015: contributor

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

  30. laanwj merged this on Jan 29, 2015
  31. laanwj closed this on Jan 29, 2015

  32. laanwj referenced this in commit 5f04d1d0d7 on Jan 29, 2015
  33. paveljanik deleted the branch on Jan 29, 2015
  34. DrahtBot locked this on Sep 8, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-15 15:15 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me