[maemo-commits] [maemo-commits] r16667 - in projects/haf/trunk/hildon-thumbnail: . daemon
From: subversion at stage.maemo.org subversion at stage.maemo.orgDate: Thu Nov 13 17:13:40 EET 2008
- Previous message: [maemo-commits] r16666 - projects/haf/branches/hildon-fm/fremantle/hildon-fm
- Next message: [maemo-commits] r16668 - in projects/haf/trunk/hildon-thumbnail: . daemon daemon/plugins
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Author: pvanhoof Date: 2008-11-13 17:13:38 +0200 (Thu, 13 Nov 2008) New Revision: 16667 Modified: projects/haf/trunk/hildon-thumbnail/ChangeLog projects/haf/trunk/hildon-thumbnail/daemon/hildon-thumbnail-daemon.c projects/haf/trunk/hildon-thumbnail/daemon/hildon-thumbnail-plugin.c projects/haf/trunk/hildon-thumbnail/daemon/hildon-thumbnail-plugin.h Log: 2008-11-13 Philip Van Hoof <philip at codeminded.be> * daemon/hildon-thumbnail-plugin.h * daemon/hildon-thumbnail-daemon.c * daemon/hildon-thumbnail-plugin.c: Bugfixes for loading and unloading plugins on GFileMonitor events Modified: projects/haf/trunk/hildon-thumbnail/ChangeLog =================================================================== --- projects/haf/trunk/hildon-thumbnail/ChangeLog 2008-11-13 15:02:14 UTC (rev 16666) +++ projects/haf/trunk/hildon-thumbnail/ChangeLog 2008-11-13 15:13:38 UTC (rev 16667) @@ -1,5 +1,12 @@ 2008-11-13 Philip Van Hoof <philip at codeminded.be> + * daemon/hildon-thumbnail-plugin.h + * daemon/hildon-thumbnail-daemon.c + * daemon/hildon-thumbnail-plugin.c: Bugfixes for loading and unloading + plugins on GFileMonitor + +2008-11-13 Philip Van Hoof <philip at codeminded.be> + * daemon/utils.c: No more difference between png and jpeg filename request for cropped * daemon/hildon-thumbnail-plugin.c: Making it possible to dynamically Modified: projects/haf/trunk/hildon-thumbnail/daemon/hildon-thumbnail-daemon.c =================================================================== --- projects/haf/trunk/hildon-thumbnail/daemon/hildon-thumbnail-daemon.c 2008-11-13 15:02:14 UTC (rev 16666) +++ projects/haf/trunk/hildon-thumbnail/daemon/hildon-thumbnail-daemon.c 2008-11-13 15:13:38 UTC (rev 16667) @@ -78,23 +78,31 @@ if (dir) { while ((plugin = g_dir_read_name (dir)) != NULL) { gboolean cropping; + gchar *full; if (!g_str_has_suffix (plugin, "." G_MODULE_SUFFIX)) { continue; } - - module = hildon_thumbnail_plugin_load (plugin); - hildon_thumbnail_plugin_do_init (module, &cropping, - (register_func) thumbnailer_register_plugin, - thumbnailer, - &error); + + full = g_build_filename (PLUGINS_DIR, plugin, NULL); + + module = hildon_thumbnail_plugin_load (full); + if (module) + hildon_thumbnail_plugin_do_init (module, &cropping, + (register_func) thumbnailer_register_plugin, + thumbnailer, + &error); if (error) { g_warning ("Can't load plugin [%s]: %s\n", plugin, error->message); g_error_free (error); - } else - g_hash_table_replace (regs, g_strdup (plugin), - module); + g_free (full); + if (module) + g_module_close (module); + } else if (module) + g_hash_table_replace (regs, full, module); + else + g_free (full); } g_dir_close (dir); } @@ -123,14 +131,15 @@ if (dir) { while ((plugin = g_dir_read_name (dir)) != NULL) { + gchar *full; if (!g_str_has_suffix (plugin, "." G_MODULE_SUFFIX)) { continue; } - module = hildon_thumbnail_outplugin_load (plugin); - g_hash_table_replace (regs, g_strdup (plugin), - module); + full = g_build_filename (OUTPUTPLUGINS_DIR, plugin, NULL); + module = hildon_thumbnail_outplugin_load (full); + g_hash_table_replace (regs, full, module); } g_dir_close (dir); } @@ -150,6 +159,7 @@ g_hash_table_iter_init (&iter, regs); while (g_hash_table_iter_next (&iter, &key, &value)) { + g_hash_table_iter_remove (&iter); thumbnailer_unregister_plugin (thumbnailer, value); hildon_thumbnail_plugin_do_stop (value); } @@ -163,7 +173,9 @@ g_hash_table_iter_init (&iter, regs); - while (g_hash_table_iter_next (&iter, &key, &value)) { + while (g_hash_table_iter_next (&iter, &key, &value)) { + g_hash_table_iter_remove (&iter); + hildon_thumbnail_outplugin_unload (value); } } @@ -171,17 +183,19 @@ on_plugin_changed (GFileMonitor *monitor, GFile *file, GFile *other_file, GFileMonitorEvent event_type, gpointer user_data) { Thumbnailer *thumbnailer = user_data; - gchar *path = g_file_get_path (other_file); + gchar *path = g_file_get_path (file); - if (path) { + if (path && g_str_has_suffix (path, "." G_MODULE_SUFFIX)) { switch (event_type) { case G_FILE_MONITOR_EVENT_DELETED: { GModule *module = g_hash_table_lookup (registrations, path); if (module) { + g_hash_table_remove (registrations, path); thumbnailer_unregister_plugin (thumbnailer, module); hildon_thumbnail_plugin_do_stop (module); } } + break; case G_FILE_MONITOR_EVENT_CREATED: { GModule *module = hildon_thumbnail_plugin_load (path); gboolean cropping = FALSE; @@ -217,19 +231,24 @@ on_outputplugin_changed (GFileMonitor *monitor, GFile *file, GFile *other_file, GFileMonitorEvent event_type, gpointer user_data) { Thumbnailer *thumbnailer = user_data; - gchar *path = g_file_get_path (other_file); + gchar *path = g_file_get_path (file); - if (path) { + if (path && g_str_has_suffix (path, "." G_MODULE_SUFFIX)) { switch (event_type) { case G_FILE_MONITOR_EVENT_DELETED: { GModule *module = g_hash_table_lookup (outregistrations, path); if (module) { + g_hash_table_remove (outregistrations, path); + hildon_thumbnail_outplugin_unload (module); } } + break; case G_FILE_MONITOR_EVENT_CREATED: { GModule *module = hildon_thumbnail_outplugin_load (path); - g_hash_table_replace (outregistrations, g_strdup (path), - module); + if (module) { + g_hash_table_replace (outregistrations, g_strdup (path), + module); + } } break; default: Modified: projects/haf/trunk/hildon-thumbnail/daemon/hildon-thumbnail-plugin.c =================================================================== --- projects/haf/trunk/hildon-thumbnail/daemon/hildon-thumbnail-plugin.c 2008-11-13 15:02:14 UTC (rev 16666) +++ projects/haf/trunk/hildon-thumbnail/daemon/hildon-thumbnail-plugin.c 2008-11-13 15:13:38 UTC (rev 16667) @@ -30,18 +30,22 @@ typedef gboolean (*IsActiveFunc) (void); +void +hildon_thumbnail_outplugin_unload (GModule *module) +{ + outplugs = g_list_remove (outplugs, module); + g_module_close (module); +} + GModule* hildon_thumbnail_outplugin_load (const gchar *module_name) { - gchar *path; GModule *module; g_return_val_if_fail (module_name != NULL, NULL); - path = g_build_filename (OUTPUTPLUGINS_DIR, module_name, NULL); + module = g_module_open (module_name, G_MODULE_BIND_LOCAL); - module = g_module_open (path, G_MODULE_BIND_LOCAL); - if (!module) { g_warning ("Could not load thumbnailer module '%s', %s\n", module_name, @@ -51,8 +55,6 @@ outplugs = g_list_prepend (outplugs, module); } - g_free (path); - return module; } @@ -116,15 +118,12 @@ GModule * hildon_thumbnail_plugin_load (const gchar *module_name) { - gchar *path; GModule *module; g_return_val_if_fail (module_name != NULL, NULL); - path = g_build_filename (PLUGINS_DIR, module_name, NULL); + module = g_module_open (module_name, G_MODULE_BIND_LOCAL); - module = g_module_open (path, G_MODULE_BIND_LOCAL); - if (!module) { g_warning ("Could not load thumbnailer module '%s', %s\n", module_name, @@ -133,8 +132,6 @@ g_module_make_resident (module); } - g_free (path); - return module; } @@ -187,4 +184,5 @@ if (g_module_symbol (module, "hildon_thumbnail_plugin_stop", (gpointer *) &func)) { (func) (); } + g_module_close (module); } Modified: projects/haf/trunk/hildon-thumbnail/daemon/hildon-thumbnail-plugin.h =================================================================== --- projects/haf/trunk/hildon-thumbnail/daemon/hildon-thumbnail-plugin.h 2008-11-13 15:02:14 UTC (rev 16666) +++ projects/haf/trunk/hildon-thumbnail/daemon/hildon-thumbnail-plugin.h 2008-11-13 15:13:38 UTC (rev 16667) @@ -57,6 +57,7 @@ GModule* hildon_thumbnail_outplugin_load (const gchar *module_name); +void hildon_thumbnail_outplugin_unload (GModule *module); void hildon_thumbnail_outplugins_do_out (const guchar *rgb8_pixmap, guint width, guint height, guint rowstride, guint bits_per_sample,
- Previous message: [maemo-commits] r16666 - projects/haf/branches/hildon-fm/fremantle/hildon-fm
- Next message: [maemo-commits] r16668 - in projects/haf/trunk/hildon-thumbnail: . daemon daemon/plugins
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]