+============================================================================
+API breaks in 0.2.0
+============================================================================
+
+BackendStore is now a singleton.
+
+Vala:
+BackendStore default constructor removed. Use BackendStore.dup().
+
+C:
+folks_backend_store_new() removed. Use folks_backend_store_dup().
private HashMap<string,Backend> backend_hash;
private GLib.List<ModuleFinalizeFunc> finalize_funcs = null;
+ private static weak BackendStore instance;
/**
* Emitted when a backend has been added to the BackendStore.
/**
* Create a new BackendStore.
*/
- public BackendStore ()
+ public static BackendStore dup ()
+ {
+ if (instance == null)
+ {
+ /* use an intermediate variable to force a strong reference */
+ var new_instance = new BackendStore ();
+ instance = new_instance;
+
+ return new_instance;
+ }
+
+ return instance;
+ }
+
+ private BackendStore ()
{
this.backend_hash = new HashMap<string,Backend> (str_hash, str_equal);
}
/* Finalize all the loaded modules */
foreach (ModuleFinalizeFunc func in this.finalize_funcs)
func (this);
+
+ /* manually clear the singleton instance */
+ instance = null;
}
/**
this.linking_enabled = (disable_linking == null ||
disable_linking == "no" || disable_linking == "0");
- this.backend_store = new BackendStore ();
+ this.backend_store = BackendStore.dup ();
this.backend_store.backend_available.connect (this.backend_available_cb);
}
private static async bool import ()
{
- BackendStore backend_store = new BackendStore ();
+ BackendStore backend_store = BackendStore.dup ();
try
{