private BackendStore ()
{
+ var debug = Debug.dup ();
+
/* Treat this as a library init function */
- Debug._set_flags (Environment.get_variable ("FOLKS_DEBUG"));
+ debug._set_flags (Environment.get_variable ("FOLKS_DEBUG"));
this.modules = new HashMap<string,unowned Module> (str_hash, str_equal);
this._backend_hash = new HashMap<string,Backend> (str_hash, str_equal);
*/
using GLib;
+using Gee;
-namespace Folks.Debug
+internal class Folks.Debug : Object
{
private enum Domains {
/* Zero is used for "no debug spew" */
KEY_FILE_BACKEND = 1 << 2
}
- internal static void _set_flags (string? debug_flags)
+ private static weak Debug _instance;
+
+ internal void _set_flags (string? debug_flags)
{
/* FIXME: we obviously shouldn't be hard-coding these. See bgo#638609 */
GLib.DebugKey keys[3] =
}
}
}
+
+ internal static Debug dup ()
+ {
+ if (_instance == null)
+ {
+ /* use an intermediate variable to force a strong reference */
+ var new_instance = new Debug ();
+ _instance = new_instance;
+
+ return new_instance;
+ }
+
+ return _instance;
+ }
+
+ ~Debug ()
+ {
+ /* manually clear the singleton _instance */
+ _instance = null;
+ }
}