From af1ecc7733fa04087f1be13d0469ad71b1f6b7bf Mon Sep 17 00:00:00 2001 From: clobber Date: Sat, 4 Nov 2017 00:49:54 -0500 Subject: [PATCH] Remove deprecated core plugins earlier to hopefully prevent a Sparkle crash as it checks for updates for plugins that no longer exist. "This host [_.oecoreplugin] has no CFBundleVersion! This attribute is required." --- OpenEmu/AppDelegate.swift | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/OpenEmu/AppDelegate.swift b/OpenEmu/AppDelegate.swift index 210a18fe4c..c2ac558520 100644 --- a/OpenEmu/AppDelegate.swift +++ b/OpenEmu/AppDelegate.swift @@ -144,7 +144,10 @@ class AppDelegate: NSDocumentController { override init() { super.init() - + + // Needs to happen early to hopefully prevent a Sparkle crash. + removeDeprecatedPlugins() + // Load the XPC communicator framework. This used to be conditional on the existence of NSXPCConnection, but now OpenEmu's minimum supported version of macOS will always have NSXPCConnection. let xpcFrameworkPath = (Bundle.main.privateFrameworksPath! as NSString).appendingPathComponent("OpenEmuXPCCommunicator.framework") let xpcFrameworkBundle = Bundle(path: xpcFrameworkPath) @@ -512,7 +515,23 @@ class AppDelegate: NSDocumentController { } // MARK: - - + + fileprivate func removeDeprecatedPlugins() { + // Remove deprecated core plugins. + let corePlugins = [ + "NeoPop.oecoreplugin", + "TwoMbit.oecoreplugin", + "VisualBoyAdvance.oecoreplugin", + "Yabause.oecoreplugin" + ] + let supportDirectoryURL = FileManager.default.urls(for: .applicationSupportDirectory, in: .userDomainMask).last! + let coresDirectoryURL = supportDirectoryURL.appendingPathComponent("OpenEmu/Cores") + for plugin in corePlugins { + let coreBundleURL = coresDirectoryURL.appendingPathComponent(plugin, isDirectory: false) + try? FileManager.default.removeItem(at: coreBundleURL) + } + } + fileprivate func removeInvalidPlugins() { // Remove Higan WIP systems as defaults if found, since our core port does not support them. @@ -546,20 +565,6 @@ class AppDelegate: NSDocumentController { defaults.removeObject(forKey: "defaultCore.openemu.system.sms") } - // Remove deprecated core plugins. - let corePlugins = [ - "NeoPop.oecoreplugin", - "TwoMbit.oecoreplugin", - "VisualBoyAdvance.oecoreplugin", - "Yabause.oecoreplugin" - ] - let supportDirectoryURL = FileManager.default.urls(for: .applicationSupportDirectory, in: .userDomainMask).last! - let coresDirectoryURL = supportDirectoryURL.appendingPathComponent("OpenEmu/Cores") - for plugin in corePlugins { - let coreBundleURL = coresDirectoryURL.appendingPathComponent(plugin, isDirectory: false) - try? FileManager.default.removeItem(at: coreBundleURL) - } - // Remove beta-era core plug-ins. let betaPlugins = OECorePlugin.allPlugins.filter { ($0.infoDictionary["SUFeedURL"] as! String).contains("openemu.org/update") } for plugin in betaPlugins {