Blob Blame History Raw
From: Krzysztof Foltman <wdev@foltman.com>
Date: Fri, 9 Jul 2010 07:03:06 +0000 (+0100)
Subject: Attempt to fix the Rosegarden crash.
X-Git-Url: http://repo.or.cz/w/calf.git/commitdiff_plain/4e589965840bbd15c967991a4229e87dc262a101?hp=4fbb849c7f69d9e52c7ddd73e0bad0970f235891

Attempt to fix the Rosegarden crash.

Rosegarden seems to unload the plugins after discovery, which interferes with
the cleanup of local static objects (like one created in ladspa_wrapper::get).
This workaround causes the wrapper object to never be cleaned up, which causes
a memory leak, but fixes the crash. Obviously, if this works, I will have to
convert it into a proper fix using __attribute__((destructor)).
---

diff --git a/src/calf/ladspa_wrap.h b/src/calf/ladspa_wrap.h
index 250b556..85c27a6 100644
--- a/src/calf/ladspa_wrap.h
+++ b/src/calf/ladspa_wrap.h
@@ -506,8 +506,9 @@ struct ladspa_wrapper
     
     /// Get a wrapper singleton - used to prevent initialization order problems which were present in older versions
     static ladspa_wrapper &get() { 
-        static ladspa_wrapper instance;
-        return instance;
+        static ladspa_wrapper *instance = new ladspa_wrapper;
+        // never destroyed, but that's OK - otherwise it may run into problems with hosts that unload plugins after discovery
+        return *instance;
     }
 };