【问题标题】:Call to `[[NSDocumentController sharedDocumentController] recentDocumentURLs]` hangs调用 `[[NSDocumentController sharedDocumentController] recentDocumentURLs]` 挂起
【发布时间】:2015-10-17 17:50:54
【问题描述】:

我有一个应用程序会定期调用[[NSDocumentController sharedDocumentController] recentDocumentURLs] 来重建最近打开的项目列表。这已经运行了一段时间,但我最近收到报告说它挂起了用户的系统:

11 -[NSDocumentController(NSPrivate) _recentDocumentURLsForKey:] + 271 (AppKit + 5903428) [0x7fff92ae5444] 1-11 11 -[__NSOperationInternal _waitUntilFinished:] + 131 (Foundation + 1060402) [0x7fff86a1ee32] 1-11 11 __psynch_cvwait + 10 (libsystem_kernel.dylib + 94046) [0x7fff8dec6f5e] 1-11 *11 psynch_cvcontinue + 0 (pthread + 30281) [0xffffff7f80e8d649] 1-11

对于报告错误的用户,这在升级到 El Capitan 后开始发生 - 他经常从网络共享加载文件,所以我猜系统正在阻止尝试定位文件的调用。环顾四周,这似乎是一个已经存在一段时间的问题:http://www.cocoabuilder.com/archive/cocoa/317137-thread-deadlock.htmlhttp://ticket.macromates.com/show?ticket_id=F3058D68

问题是,虽然多个应用程序报告该问题已修复,但我无法找到实际的修复方法。什么是解决这个问题的合适方法?将其卸载到后台线程是唯一合适的解决方案,还是我遗漏了什么?

【问题讨论】:

    标签: objective-c cocoa nsdocumentcontroller


    【解决方案1】:

    FWIW,我通过在应用程序启动时在单独的线程中调用 recentDocumentURLs 来解决此问题。列表可用后,我将 URL 放入 NSMutableArray,然后更新 NSDocumentControllerNSMutableArray

    为了使用数组复制NSDocumentController 的行为(仅保留唯一的 URL),我删除了与新 URL 匹配的所有 URL,然后在位置 0 处插入新的。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-05-19
      • 2017-04-26
      • 1970-01-01
      • 2012-08-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多