From 28cf9cfd15acad4c8eb2fd8a4d3df3a3905aa71e Mon Sep 17 00:00:00 2001 From: Mike Erwin Date: Sun, 21 Aug 2016 23:09:19 -0400 Subject: NDOF: fix crash on Mac with old drivers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit For best results use the latest 3Dconnexion driver. But latest is only supported on Mac OS 10.9+. We go all the way back to Mac OS 10.6 so have to deal with older driver versions. See the original dlclose line for my faulty assumption. Waiting to unload the driver later fixes the crash. Newer drivers don’t seem to have this issue. Also removed WITH_INPUT_NDOF guards as NDOFManager.h takes care of this. Follow-up to b10d005 a few days ago. --- intern/ghost/intern/GHOST_NDOFManagerCocoa.mm | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'intern/ghost') diff --git a/intern/ghost/intern/GHOST_NDOFManagerCocoa.mm b/intern/ghost/intern/GHOST_NDOFManagerCocoa.mm index b56757cd0fe..3cce6bf520b 100644 --- a/intern/ghost/intern/GHOST_NDOFManagerCocoa.mm +++ b/intern/ghost/intern/GHOST_NDOFManagerCocoa.mm @@ -21,8 +21,6 @@ * ***** END GPL LICENSE BLOCK ***** */ -#ifdef WITH_INPUT_NDOF - #define DEBUG_NDOF_DRIVER false #include "GHOST_NDOFManagerCocoa.h" @@ -115,13 +113,15 @@ static void* load_func(void* module, const char* func_name) #define LOAD_FUNC(name) name = (name##_ptr) load_func(module, #name) +static void* module; // handle to the whole driver + static bool load_driver_functions() { if (driver_loaded) { return true; } - void* module = dlopen("3DconnexionClient.framework/3DconnexionClient", RTLD_LAZY | RTLD_LOCAL); + module = dlopen("3DconnexionClient.framework/3DconnexionClient", RTLD_LAZY | RTLD_LOCAL); if (module) { LOAD_FUNC(SetConnexionHandlers); @@ -145,8 +145,6 @@ static bool load_driver_functions() has_old_driver = (SetConnexionClientButtonMask == NULL); } - - dlclose(module); // functions will remain loaded } #if DEBUG_NDOF_DRIVER else { @@ -161,6 +159,10 @@ static bool load_driver_functions() return driver_loaded; } +static void unload_driver() +{ + dlclose(module); +} static void DeviceAdded(uint32_t unused) { @@ -268,6 +270,7 @@ GHOST_NDOFManagerCocoa::~GHOST_NDOFManagerCocoa() if (driver_loaded) { UnregisterConnexionClient(clientID); CleanupConnexionHandlers(); + unload_driver(); ghost_system = NULL; ndof_manager = NULL; @@ -278,5 +281,3 @@ bool GHOST_NDOFManagerCocoa::available() { return driver_loaded; } - -#endif // WITH_INPUT_NDOF -- cgit v1.2.3