diff options
author | Peter Williams <peterw@ximian.com> | 2001-08-23 23:12:28 +0800 |
---|---|---|
committer | Peter Williams <peterw@src.gnome.org> | 2001-08-23 23:12:28 +0800 |
commit | 17a89d643ab695f5d9f55524d1feaf18dcfd1502 (patch) | |
tree | 50659f26684c510d03a9e04ffac817fa072868a3 /mail/mail-folder-cache.c | |
parent | 94479f8a9b372b3790592a1cb14f7f72a52826d9 (diff) | |
download | gsoc2013-evolution-17a89d643ab695f5d9f55524d1feaf18dcfd1502.tar.gz gsoc2013-evolution-17a89d643ab695f5d9f55524d1feaf18dcfd1502.tar.zst gsoc2013-evolution-17a89d643ab695f5d9f55524d1feaf18dcfd1502.zip |
Record the timeout_id so we can cancel it if the mail_folder_info is later
2001-08-23 Peter Williams <peterw@ximian.com>
* mail-folder-cache.c (maybe_update): Record the timeout_id so we
can cancel it if the mail_folder_info is later freed. Also obviates
the use of the _UPDATE_QUEUED flag.
(mail_folder_cache_remove_folder): Cancel the timeout if we need to.
Lock around the hash table operations. Free mfi itself. Add debugging
spew.
(get_folder_info): Initialiae the timeout_id to 0.
svn path=/trunk/; revision=12417
Diffstat (limited to 'mail/mail-folder-cache.c')
-rw-r--r-- | mail/mail-folder-cache.c | 44 |
1 files changed, 29 insertions, 15 deletions
diff --git a/mail/mail-folder-cache.c b/mail/mail-folder-cache.c index 46f595c6ed..799feaa25f 100644 --- a/mail/mail-folder-cache.c +++ b/mail/mail-folder-cache.c @@ -49,7 +49,6 @@ typedef enum mail_folder_info_flags { MAIL_FIF_NEED_UPDATE = (1 << 4), MAIL_FIF_PATH_VALID = (1 << 5), MAIL_FIF_NAME_VALID = (1 << 6), - MAIL_FIF_UPDATE_QUEUED = (1 << 7), MAIL_FIF_FB_VALID = (1 << 8), MAIL_FIF_SELECTED_VALID = (1 << 9) } mfif; @@ -78,6 +77,8 @@ typedef struct _mail_folder_info { FolderBrowser *fb; + int timeout_id; + mfium update_mode; mfiui update_info; } mail_folder_info; @@ -122,6 +123,7 @@ get_folder_info (const gchar *uri) mfi->flags = 0; mfi->update_mode = MAIL_FIUM_UNKNOWN; mfi->update_info.es = NULL; + mfi->timeout_id = 0; g_hash_table_insert (folders, mfi->uri, mfi); } else @@ -192,7 +194,7 @@ update_idle (gpointer user_data) d(g_message("update_idle called")); - mfi->flags &= (~MAIL_FIF_UPDATE_QUEUED); + mfi->timeout_id = 0; /* Check if this makes sense */ @@ -297,11 +299,10 @@ update_idle (gpointer user_data) static void maybe_update (mail_folder_info *mfi) { - if (mfi->flags & MAIL_FIF_UPDATE_QUEUED) + if (mfi->timeout_id) return; - mfi->flags |= MAIL_FIF_UPDATE_QUEUED; - g_timeout_add (100, update_idle, mfi); + mfi->timeout_id = g_timeout_add (100, update_idle, mfi); } static void @@ -601,19 +602,32 @@ mail_folder_cache_set_update_lstorage (const gchar *uri, void mail_folder_cache_remove_folder (const gchar *uri) { - if (uri && *uri) { - mail_folder_info *mfi; - - mfi = g_hash_table_lookup (folders, uri); + mail_folder_info *mfi; - /* Free everything we've allocated for this folder info */ - g_free (mfi->uri); - g_free (mfi->path); - g_free (mfi->name); + g_return_if_fail (uri); - /* Remove it from the hash */ - g_hash_table_remove (folders, uri); + LOCK_FOLDERS (); + + mfi = g_hash_table_lookup (folders, uri); + if (!mfi) { + UNLOCK_FOLDERS (); + g_warning ("folder cache: trying to remove uri \"%s\": not found in the cache", + uri); + return; } + g_hash_table_remove (folders, uri); + + if (mfi->timeout_id) + g_source_remove (mfi->timeout_id); + + UNLOCK_FOLDERS (); + + d(g_message ("folder cache: removing uri \"%s\".", uri)); + + g_free (mfi->uri); + g_free (mfi->path); + g_free (mfi->name); + g_free (mfi); } void |