X-Git-Url: http://git.maemo.org/git/?a=blobdiff_plain;f=src%2Fmodest-singletons.c;h=e756b114950f812e83d45f399dbfa02ced8590c7;hb=c914d3bc38581e163a1fa3e970add2bfea33fc41;hp=9c0ede2bbc6f365f7915492c15ca82e6845edf4d;hpb=9a8935f8511b016430e8a96ed50f87558a304b99;p=modest diff --git a/src/modest-singletons.c b/src/modest-singletons.c index 9c0ede2..e756b11 100644 --- a/src/modest-singletons.c +++ b/src/modest-singletons.c @@ -39,6 +39,7 @@ typedef struct _ModestSingletonsPrivate ModestSingletonsPrivate; struct _ModestSingletonsPrivate { ModestConf *conf; ModestAccountMgr *account_mgr; + ModestEmailClipboard *email_clipboard; ModestTnyAccountStore *account_store; ModestCacheMgr *cache_mgr; ModestMailOperationQueue *mail_op_queue; @@ -94,14 +95,15 @@ modest_singletons_init (ModestSingletons *obj) ModestSingletonsPrivate *priv; priv = MODEST_SINGLETONS_GET_PRIVATE(obj); - priv->conf = NULL; - priv->account_mgr = NULL; - priv->account_store = NULL; - priv->cache_mgr = NULL; - priv->mail_op_queue = NULL; - priv->platform_fact = NULL; - priv->device = NULL; - priv->window_mgr = NULL; + priv->conf = NULL; + priv->account_mgr = NULL; + priv->email_clipboard = NULL; + priv->account_store = NULL; + priv->cache_mgr = NULL; + priv->mail_op_queue = NULL; + priv->platform_fact = NULL; + priv->device = NULL; + priv->window_mgr = NULL; priv->conf = modest_conf_new (); if (!priv->conf) { @@ -115,6 +117,12 @@ modest_singletons_init (ModestSingletons *obj) return; } + priv->email_clipboard = modest_email_clipboard_new (); + if (!priv->email_clipboard) { + g_printerr ("modest: cannot create modest email clipboard instance\n"); + return; + } + priv->platform_fact = modest_tny_platform_factory_get_instance (); if (!priv->platform_fact) { g_printerr ("modest: cannot create platform factory instance\n"); @@ -158,23 +166,23 @@ modest_singletons_finalize (GObject *obj) ModestSingletonsPrivate *priv; priv = MODEST_SINGLETONS_GET_PRIVATE(obj); - + + if (priv->window_mgr) { + modest_runtime_verify_object_last_ref(priv->window_mgr,""); + g_object_unref (G_OBJECT(priv->window_mgr)); + priv->window_mgr = NULL; + } + if (priv->account_store) { modest_runtime_verify_object_last_ref(priv->account_store,""); g_object_unref (G_OBJECT(priv->account_store)); priv->account_store = NULL; } - if (priv->account_mgr) { - modest_runtime_verify_object_last_ref(priv->account_mgr,""); - g_object_unref (G_OBJECT(priv->account_mgr)); - priv->account_mgr = NULL; - } - - if (priv->conf) { - modest_runtime_verify_object_last_ref(priv->conf,""); - g_object_unref (G_OBJECT(priv->conf)); - priv->conf = NULL; + if (priv->email_clipboard) { + modest_runtime_verify_object_last_ref(priv->email_clipboard,""); + g_object_unref (G_OBJECT(priv->email_clipboard)); + priv->email_clipboard = NULL; } if (priv->cache_mgr) { @@ -200,13 +208,23 @@ modest_singletons_finalize (GObject *obj) g_object_unref (G_OBJECT(priv->mail_op_queue)); priv->mail_op_queue = NULL; } + + /* It is important that the account manager is uninitialized after + * the mail op queue is uninitialized because the mail op queue + * cancells any mail operations which in turn access the account + * manager (see modest_mail_operation_notify_end()). */ + if (priv->account_mgr) { + modest_runtime_verify_object_last_ref(priv->account_mgr,""); + g_object_unref (G_OBJECT(priv->account_mgr)); + priv->account_mgr = NULL; + } - if (priv->window_mgr) { - modest_runtime_verify_object_last_ref(priv->window_mgr,""); - g_object_unref (G_OBJECT(priv->window_mgr)); - priv->window_mgr = NULL; + if (priv->conf) { + modest_runtime_verify_object_last_ref(priv->conf,""); + g_object_unref (G_OBJECT(priv->conf)); + priv->conf = NULL; } - + G_OBJECT_CLASS(parent_class)->finalize (obj); } @@ -227,7 +245,7 @@ modest_singletons_new (void) priv = MODEST_SINGLETONS_GET_PRIVATE(self); /* widget_factory will still be NULL, as it is initialized lazily */ - if (!(priv->conf && priv->account_mgr && priv->account_store && + if (!(priv->conf && priv->account_mgr && priv->email_clipboard && priv->account_store && priv->cache_mgr && priv->mail_op_queue && priv->device && priv->platform_fact)) { g_printerr ("modest: failed to create singletons object\n"); g_object_unref (G_OBJECT(self)); @@ -253,6 +271,13 @@ modest_singletons_get_account_mgr (ModestSingletons *self) return MODEST_SINGLETONS_GET_PRIVATE(self)->account_mgr; } +ModestEmailClipboard* +modest_singletons_get_email_clipboard (ModestSingletons *self) +{ + g_return_val_if_fail (self, NULL); + return MODEST_SINGLETONS_GET_PRIVATE(self)->email_clipboard; +} + ModestTnyAccountStore* modest_singletons_get_account_store (ModestSingletons *self) { @@ -274,8 +299,6 @@ modest_singletons_get_mail_operation_queue (ModestSingletons *self) return MODEST_SINGLETONS_GET_PRIVATE(self)->mail_op_queue; } - - TnyDevice* modest_singletons_get_device (ModestSingletons *self) { @@ -284,7 +307,6 @@ modest_singletons_get_device (ModestSingletons *self) } - TnyPlatformFactory* modest_singletons_get_platform_factory (ModestSingletons *self) {