[nautilus-actions] Menu plugin: test if log are enabled before installing the log handler
- From: Pierre Wieser <pwieser src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus-actions] Menu plugin: test if log are enabled before installing the log handler
- Date: Sat, 26 Feb 2011 15:38:21 +0000 (UTC)
commit 204d417107c31fdc9abc81d0483d3ecb8f8116b7
Author: Pierre Wieser <pwieser trychlos org>
Date: Sat Feb 26 16:35:03 2011 +0100
Menu plugin: test if log are enabled before installing the log handler
Fix #643359.
ChangeLog | 10 ++++++++
src/core/na-settings.c | 4 +-
src/core/na-settings.h | 2 +-
src/plugin-menu/nautilus-actions.c | 6 -----
src/plugin-menu/nautilus-actions.h | 2 -
src/plugin-menu/nautilus-module.c | 42 ++++++++++++++++++++++++------------
6 files changed, 41 insertions(+), 25 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 97d30a1..dafb340 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,15 @@
2011-02-26 Pierre Wieser <pwieser trychlos org>
+ * src/core/na-settings.c:
+ * src/core/na-settings.h: NA_IPREFS_PLUGIN_MENU_LOG user preference renamed.
+
+ * src/plugin-menu/nautilus-module.c (set_log_handler):
+ Test if log are enabled before installing the log handler.
+
+ * src/plugin-menu/nautilus-actions.c:
+ * src/plugin-menu/nautilus-actions.h (nautilus_action_is_log_enabled):
+ Removed function. Fix #643359.
+
* configure.ac: Post-release bump version.
2011-02-25 Pierre Wieser <pwieser trychlos org>
diff --git a/src/core/na-settings.c b/src/core/na-settings.c
index 889682f..57fe7f8 100644
--- a/src/core/na-settings.c
+++ b/src/core/na-settings.c
@@ -177,7 +177,7 @@ static const KeyDef st_def_keys[] = {
{ NA_IPREFS_MAIN_TOOLBAR_TOOLS_DISPLAY, GROUP_NACT, NA_DATA_TYPE_BOOLEAN, "false" },
{ NA_IPREFS_MAIN_WINDOW_WSP, GROUP_NACT, NA_DATA_TYPE_UINT_LIST, "" },
{ NA_IPREFS_PREFERENCES_WSP, GROUP_NACT, NA_DATA_TYPE_UINT_LIST, "" },
- { NA_IPREFS_PLUGIN_LOG, GROUP_RUNTIME, NA_DATA_TYPE_BOOLEAN, "false" },
+ { NA_IPREFS_PLUGIN_MENU_LOG, GROUP_RUNTIME, NA_DATA_TYPE_BOOLEAN, "false" },
{ NA_IPREFS_RELABEL_DUPLICATE_ACTION, GROUP_NACT, NA_DATA_TYPE_BOOLEAN, "false" },
{ NA_IPREFS_RELABEL_DUPLICATE_MENU, GROUP_NACT, NA_DATA_TYPE_BOOLEAN, "false" },
{ NA_IPREFS_RELABEL_DUPLICATE_PROFILE, GROUP_NACT, NA_DATA_TYPE_BOOLEAN, "false" },
@@ -404,7 +404,7 @@ instance_finalize( GObject *object )
/**
* na_settings_new:
*
- * Returns: a new #NASettings object which should be g_object_unref()
+ * Allocates a new #NASettings object which should be na_settings_free()
* by the caller.
*/
static void
diff --git a/src/core/na-settings.h b/src/core/na-settings.h
index d5e2176..18fbd69 100644
--- a/src/core/na-settings.h
+++ b/src/core/na-settings.h
@@ -118,7 +118,7 @@ G_BEGIN_DECLS
#define NA_IPREFS_MAIN_TOOLBAR_TOOLS_DISPLAY "main-toolbar-tools-display"
#define NA_IPREFS_MAIN_WINDOW_WSP "main-window-wsp"
#define NA_IPREFS_PREFERENCES_WSP "preferences-wsp"
-#define NA_IPREFS_PLUGIN_LOG "log-enabled"
+#define NA_IPREFS_PLUGIN_MENU_LOG "plugin-menu-log-enabled"
#define NA_IPREFS_RELABEL_DUPLICATE_ACTION "relabel-when-duplicate-action"
#define NA_IPREFS_RELABEL_DUPLICATE_MENU "relabel-when-duplicate-menu"
#define NA_IPREFS_RELABEL_DUPLICATE_PROFILE "relabel-when-duplicate-profile"
diff --git a/src/plugin-menu/nautilus-actions.c b/src/plugin-menu/nautilus-actions.c
index 5e8a365..188b78e 100644
--- a/src/plugin-menu/nautilus-actions.c
+++ b/src/plugin-menu/nautilus-actions.c
@@ -290,12 +290,6 @@ instance_finalize( GObject *object )
}
}
-gboolean
-nautilus_action_is_log_enabled( void )
-{
- return( na_settings_get_boolean( NA_IPREFS_PLUGIN_LOG, NULL, NULL ));
-}
-
static void
menu_provider_iface_init( NautilusMenuProviderIface *iface )
{
diff --git a/src/plugin-menu/nautilus-actions.h b/src/plugin-menu/nautilus-actions.h
index adfaede..78aa511 100644
--- a/src/plugin-menu/nautilus-actions.h
+++ b/src/plugin-menu/nautilus-actions.h
@@ -72,8 +72,6 @@ typedef struct {
GType nautilus_actions_get_type ( void );
void nautilus_actions_register_type( GTypeModule *module );
-gboolean nautilus_action_is_log_enabled( void );
-
G_END_DECLS
#endif /* __PLUGIN_MENU_NAUTILUS_ACTIONS_H__ */
diff --git a/src/plugin-menu/nautilus-module.c b/src/plugin-menu/nautilus-module.c
index cbda460..74cf1ab 100644
--- a/src/plugin-menu/nautilus-module.c
+++ b/src/plugin-menu/nautilus-module.c
@@ -39,6 +39,7 @@
#include <libnautilus-extension/nautilus-extension-types.h>
#include <core/na-gconf-migration.h>
+#include <core/na-settings.h>
#include "nautilus-actions.h"
@@ -117,11 +118,26 @@ nautilus_module_shutdown( void )
/*
* a log handler that we install when in development mode in order to be
* able to log plugin runtime
+ *
+ * enabling log in the plugin menu at runtime requires a Nautilus restart
+ * (because we need to run in the code, which embeds g_debug instructions,
+ * and we have to do so before the log handler be set, or we will run
+ * into a deep stack recursion)
*/
static void
set_log_handler( void )
{
- st_default_log_func = g_log_set_default_handler(( GLogFunc ) log_handler, NULL );
+ gboolean is_log_enabled;
+
+#ifdef NA_MAINTAINER_MODE
+ is_log_enabled = TRUE;
+#else
+ is_log_enabled =
+ g_getenv( NAUTILUS_ACTIONS_DEBUG ) ||
+ na_settings_get_boolean( NA_IPREFS_PLUGIN_MENU_LOG, NULL, NULL );
+#endif
+
+ st_default_log_func = g_log_set_default_handler(( GLogFunc ) log_handler, GUINT_TO_POINTER( is_log_enabled ));
}
/*
@@ -135,21 +151,19 @@ static void
log_handler( const gchar *log_domain, GLogLevelFlags log_level, const gchar *message, gpointer user_data )
{
gchar *tmp;
+ gboolean is_log_enabled;
- tmp = g_strdup( "" );
- if( log_domain && strlen( log_domain )){
- g_free( tmp );
- tmp = g_strdup_printf( "[%s] ", log_domain );
- }
+ is_log_enabled = ( gboolean ) GPOINTER_TO_UINT( user_data );
+
+ if( is_log_enabled ){
+ tmp = g_strdup( "" );
+
+ if( log_domain && strlen( log_domain )){
+ g_free( tmp );
+ tmp = g_strdup_printf( "[%s] ", log_domain );
+ }
-#ifdef NA_MAINTAINER_MODE
- /*( *st_default_log_func )( log_domain, log_level, message, user_data );*/
- syslog( LOG_USER | LOG_DEBUG, "%s%s", tmp, message );
-#else
- if( g_getenv( NAUTILUS_ACTIONS_DEBUG ) || nautilus_actions_is_log_enabled()){
syslog( LOG_USER | LOG_DEBUG, "%s%s", tmp, message );
+ g_free( tmp );
}
-#endif
-
- g_free( tmp );
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]