Changeset 2056
- Timestamp:
- 02/21/10 05:52:19 (5 months ago)
- Location:
- trunk/src
- Files:
-
- 6 modified
-
config/e2_option_tree.c (modified) (7 diffs)
-
dialogs/e2_config_dialog.c (modified) (5 diffs)
-
e2_filelist.c (modified) (13 diffs)
-
e2_main.c (modified) (4 diffs)
-
e2_task.c (modified) (6 diffs)
-
e2_toolbar.c (modified) (16 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/config/e2_option_tree.c
r1949 r2056 1 1 /* $Id$ 2 2 3 Copyright (C) 2003-20 09tooar <tooar@emelfm2.net>3 Copyright (C) 2003-2010 tooar <tooar@emelfm2.net> 4 4 5 5 This file is part of emelFM2. … … 781 781 typedef struct _E2_KeyBlock 782 782 { 783 g boolean blocked;783 gint blocked; //flag for preventing re-entrance 784 784 E2_KeyChangeData *data; 785 785 } E2_KeyBlock; 786 786 //static data used cuz only one config dialog can exist 787 787 //Otherwise need to send variable data to callback via each relevant button 788 E2_KeyBlock blocknow = { FALSE, NULL};788 E2_KeyBlock blocknow = {0, NULL}; 789 789 790 790 #define KEYCHANGEKEY "_e2-binding-key_" … … 807 807 printd (DEBUG, "_e2_option_tree_mnemonic_cb"); 808 808 // E2_KeyBlock *bdata = g_object_get_data (G_OBJECT(button), KEYCHANGEKEY); 809 if (bdata != NULL && bdata-> blocked && bdata->data != NULL)809 if (bdata != NULL && bdata->data != NULL && g_atomic_int_get (&bdata->blocked) != 0) 810 810 { 811 811 GList *child, *all = gtk_widget_list_mnemonic_labels (button); … … 823 823 e2_keybinding_unblock (config_dialog, NULL); 824 824 //unblock all button-mnemonics 825 bdata->blocked = FALSE;825 g_atomic_int_set (&bdata->blocked, 0); 826 826 bdata->data = NULL; //will have been cleared downstream 827 827 break; … … 832 832 } 833 833 else if (bdata != NULL) 834 return bdata->blocked;834 return (g_atomic_int_get (&bdata->blocked) != 0); 835 835 else 836 836 return FALSE; … … 872 872 { 873 873 // printd (DEBUG, "_e2_option_tree_unblock_mnemonics"); 874 blocknow.blocked = FALSE;874 g_atomic_int_set (&blocknow.blocked, 0); 875 875 if (blocknow.data != NULL) 876 876 { … … 914 914 e2_keybinding_block (config_dialog, NULL); 915 915 //or of any dialog-button mnemonic 916 blocknow.blocked = TRUE;916 g_atomic_int_set (&blocknow.blocked, 1); 917 917 blocknow.data = data; 918 918 /* if static data not viable -
trunk/src/dialogs/e2_config_dialog.c
r2018 r2056 1 1 /* $Id$ 2 2 3 Copyright (C) 2003-20 09tooar <tooar@emelfm2.net>3 Copyright (C) 2003-2010 tooar <tooar@emelfm2.net> 4 4 Portions copyright (C) 1999 Michael Clark 5 5 … … 819 819 } */ 820 820 821 //this flag is ok because only 1 config dialog, and only 1 edit, at any time822 static g boolean cancel_blocked = FALSE;821 //this static flag is ok because only 1 config dialog, and only 1 edit, at any time 822 static gint cancel_blocked = 0; 823 823 /** 824 824 @brief allow <Esc> press to cancel editing of the entry text without closing the dialog … … 833 833 E2_OptionSet *set) 834 834 { 835 if ( !cancel_blocked)835 if (g_atomic_int_get (&cancel_blocked) == 0) 836 836 { 837 837 g_signal_handlers_block_by_func (G_OBJECT (config_dialog), 838 838 e2_dialog_key_neg_cb, config_dialog); 839 cancel_blocked = TRUE;839 g_atomic_int_set (&cancel_blocked, 1); 840 840 } 841 841 else if (event->keyval == GDK_Escape … … 853 853 g_signal_handlers_unblock_by_func (G_OBJECT (config_dialog), 854 854 e2_dialog_key_neg_cb, config_dialog); 855 cancel_blocked = FALSE;855 g_atomic_int_set (&cancel_blocked, 0); 856 856 return (event->keyval == GDK_Escape); 857 857 } … … 872 872 gpointer data) 873 873 { 874 if ( cancel_blocked)874 if (g_atomic_int_get (&cancel_blocked) != 0) 875 875 { 876 876 g_signal_handlers_unblock_by_func (G_OBJECT (config_dialog), 877 877 e2_dialog_key_neg_cb, config_dialog); 878 cancel_blocked = FALSE;878 g_atomic_int_set (&cancel_blocked, 0); 879 879 } 880 880 return FALSE; -
trunk/src/e2_filelist.c
r2024 r2056 1 1 /* $Id$ 2 2 3 Copyright (C) 2004-20 09tooar <tooar@emelfm2.net>.3 Copyright (C) 2004-2010 tooar <tooar@emelfm2.net>. 4 4 5 5 This file is part of emelFM2. … … 49 49 50 50 //disable-refresh counter for both filelists 51 gint refresh_refcount;51 volatile gint refresh_refcount; 52 52 //disable-refresh counter for single filelists 53 static gint refresh_active_refcount;54 static gint refresh_inactive_refcount;53 static volatile gint refresh_active_refcount; 54 static volatile gint refresh_inactive_refcount; 55 55 //refresh deferral counters 56 56 static gint pane1repeats = 0; … … 95 95 if (_e2_filelist_check_active_pane (pane)) 96 96 { 97 refresh_active_refcount++; 98 if (refresh_active_refcount == 1) 97 if (g_atomic_int_exchange_and_add (&refresh_active_refcount, 1) == 0) 99 98 { 100 99 LISTS_LOCK … … 105 104 else 106 105 { 107 refresh_inactive_refcount++; 108 if (refresh_inactive_refcount == 1) 106 if (g_atomic_int_exchange_and_add (&refresh_inactive_refcount, 1) == 0) 109 107 { 110 108 LISTS_LOCK … … 125 123 if (_e2_filelist_check_active_pane (pane)) 126 124 { 127 refresh_active_refcount--;128 if (refresh_active_refcount == 0 && refresh_refcount== 0)125 if (g_atomic_int_exchange_and_add (&refresh_active_refcount, -1) == 1 126 && g_atomic_int_get (&refresh_refcount) == 0) 129 127 { 130 128 LISTS_LOCK … … 133 131 } 134 132 if (refresh_active_refcount < 0) 135 refresh_active_refcount = 0;133 g_atomic_int_set (&refresh_active_refcount, 0); 136 134 } 137 135 else 138 136 { 139 refresh_inactive_refcount--;140 if (refresh_inactive_refcount == 0 && refresh_refcount== 0)137 if (g_atomic_int_exchange_and_add (&refresh_inactive_refcount, -1) == 1 138 && g_atomic_int_get (&refresh_refcount) == 0) 141 139 { 142 140 LISTS_LOCK … … 145 143 } 146 144 if (refresh_inactive_refcount < 0) 147 refresh_inactive_refcount = 0;145 g_atomic_int_set (&refresh_inactive_refcount, 0); 148 146 } 149 147 } … … 181 179 void e2_filelist_reset_refresh (void) 182 180 { 183 if ( refresh_refcount!= 0)184 { 185 refresh_refcount = 1;181 if (g_atomic_int_get (&refresh_refcount) != 0) 182 { 183 g_atomic_int_set (&refresh_refcount, 1); 186 184 e2_filelist_enable_refresh (); 187 185 } … … 194 192 @brief disable refreshing of pane filelists and config data 195 193 196 Increase ref count, if ==1, stop the timer process which calls the refresh fns194 Increases the ref-count, then if 1, stop the timer process which calls the refresh fns 197 195 Why is config data check bundled here ? 198 196 Expects BGL open? … … 202 200 void e2_filelist_disable_refresh (void) 203 201 { 204 refresh_refcount++;202 gint preinc = g_atomic_int_exchange_and_add (&refresh_refcount, 1); 205 203 #ifdef E2_REFRESH_DEBUG 206 printd (DEBUG, "disable refresh, refresh ref now = %d", refresh_refcount);207 #endif 208 if ( refresh_refcount == 1)204 printd (DEBUG, "disable refresh, refresh ref now = %d", preinc + 1); 205 #endif 206 if (preinc == 0) 209 207 { 210 208 if (app.timers[REFRESHBEGIN_T] > 0) … … 242 240 @brief re-enable polling of pane filelists and config data 243 241 244 Decrease ref count, if ==0, re-enable/restart the processes which detect242 Decreases the ref-count, then if 0, re-enable/restart the processes which detect 245 243 changes of filelist content and/or config data 246 244 Config timer is bundled here because the same func refreshes the panes … … 251 249 void e2_filelist_enable_refresh (void) 252 250 { 253 refresh_refcount--;251 gint predec = g_atomic_int_exchange_and_add (&refresh_refcount, -1); 254 252 #ifdef E2_REFRESH_DEBUG 255 printd (DEBUG, "enable refresh, refresh ref now = %d", refresh_refcount); 256 #endif 257 if (refresh_refcount < 0) 258 { 259 printd (WARN, "The auto-refresh refresh count is < 0"); 260 gdk_threads_enter (); 261 e2_window_output_show (NULL, NULL); 262 e2_output_print_error ( 263 _("Something is wrong with the auto-refresh mechanism"), FALSE); 264 gdk_threads_leave (); 265 } 266 267 if (refresh_refcount == 0) 253 printd (DEBUG, "enable refresh, refresh ref now = %d", predec - 1); 254 #endif 255 if (predec == 1) 268 256 { 269 257 if (e2_option_bool_get ("auto-refresh")) … … 287 275 e2_window_enable_status_update (-1); 288 276 #endif 277 } 278 else if (predec < 1) 279 { 280 printd (WARN, "The auto-refresh refresh count is < 0"); 281 gdk_threads_enter (); 282 e2_window_output_show (NULL, NULL); 283 e2_output_print_error ( 284 _("Something is wrong with the auto-refresh mechanism"), FALSE); 285 gdk_threads_leave (); 289 286 } 290 287 } -
trunk/src/e2_main.c
r2041 r2056 1 1 /* $Id$ 2 2 3 Copyright (C) 2003-20 09tooar <tooar@emelfm2.net>3 Copyright (C) 2003-2010 tooar <tooar@emelfm2.net> 4 4 Portions copyright (C) 1999 Michael Clark. 5 5 … … 127 127 #define UPGRADE_PNAME "e2p_upgrade.so" 128 128 129 extern gint refresh_refcount;129 extern volatile gint refresh_refcount; 130 130 extern GList *open_history; 131 131 #ifdef USE_GLIB2_10 … … 472 472 pthread_cleanup_push ((gpointer)e2_filelist_reset_refresh, NULL); 473 473 //enable refresh 474 saverefcount = refresh_refcount;474 saverefcount = g_atomic_int_get (&refresh_refcount); 475 475 if (saverefcount > 0) 476 476 { … … 785 785 #endif 786 786 //set refresh counter to its real initial value 787 refresh_refcount = 0;787 g_atomic_int_set (&refresh_refcount, 0); 788 788 #ifdef E2_REFRESH_DEBUG 789 789 printd (DEBUG, "disable refresh, session start before filelists built"); -
trunk/src/e2_task.c
r2028 r2056 1 1 /* $Id$ 2 2 3 Copyright (C) 2003-20 09tooar <tooar@emelfm2.net>3 Copyright (C) 2003-2010 tooar <tooar@emelfm2.net> 4 4 5 5 This file is part of emelFM2. … … 39 39 40 40 GList *open_history = NULL; //history list for open-with dialog 41 extern gint refresh_refcount;41 extern volatile gint refresh_refcount; 42 42 43 43 pthread_mutex_t task_mutex = PTHREAD_MUTEX_INITIALIZER; //PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP not needed … … 231 231 E2_TaskRuntime *e2_task_set_data (glong pid, E2_TaskDataType mode, gchar *command) 232 232 { 233 static gboolean blocked = FALSE; 234 if (blocked) 233 static gint blocked = 0; 234 235 if (!g_atomic_int_compare_and_exchange (&blocked, 0, 1)) 235 236 return NULL; 236 else237 blocked = TRUE;238 237 239 238 E2_TaskRuntime *rt = e2_task_find_running_task (pid); … … 249 248 { 250 249 printd (WARN, "not enough memory for task history data"); 251 blocked = FALSE;250 g_atomic_int_set (&blocked, 0); 252 251 return GINT_TO_POINTER (1); 253 252 } … … 297 296 printd (WARN, "tried to register a process with bad mode flag"); 298 297 DEALLOCATE (E2_TaskRuntime, rt); 299 blocked = FALSE;298 g_atomic_int_set (&blocked, 0); 300 299 return GINT_TO_POINTER (1); 301 300 } … … 314 313 { //found an entry with matching pid 315 314 printd (DEBUG, "tried to re-register a process"); 316 blocked = FALSE; 317 return GINT_TO_POINTER (1); 318 } 319 320 blocked = FALSE; 315 rt = GINT_TO_POINTER (1); 316 } 317 318 g_atomic_int_set (&blocked, 0); 321 319 return rt; 322 320 } -
trunk/src/e2_toolbar.c
r2042 r2056 1 1 /* $Id$ 2 2 3 Copyright (C) 2003-20 09tooar <tooar@emelfm2.net>3 Copyright (C) 2003-2010 tooar <tooar@emelfm2.net> 4 4 5 5 This file is part of emelFM2. … … 90 90 static void _e2_toolbar_hide_cb (GtkMenuItem *menuitem, E2_ToolbarRuntime *rt) 91 91 { 92 if ( !rt->blocked) //bar's menu is not now being created92 if (g_atomic_int_get (&rt->blocked) == 0) //bar's menu is not now being created 93 93 { 94 94 e2_option_bool_toggle_direct (rt->show); //now FALSE … … 108 108 static void _e2_toolbar_toggle_tt_cb (GtkMenuItem *menuitem, E2_ToolbarRuntime *rt) 109 109 { 110 if ( !rt->blocked) //bar's menu is not now being created110 if (g_atomic_int_get (&rt->blocked) == 0) //bar's menu is not now being created 111 111 { 112 112 gtk_toolbar_set_tooltips (GTK_TOOLBAR (rt->toolbar), … … 128 128 static void _e2_toolbar_update_space_cb (GtkMenuItem *menuitem, E2_ToolbarRuntime *rt) 129 129 { 130 if ( !rt->blocked) //bar's menu is not now being created130 if (g_atomic_int_get (&rt->blocked) == 0) //bar's menu is not now being created 131 131 { 132 132 GSList *group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (menuitem)); … … 152 152 static void _e2_toolbar_toggle_hori_cb (GtkMenuItem *menuitem, E2_ToolbarRuntime *rt) 153 153 { 154 if ( !rt->blocked) //bar's menu is not now being created154 if (g_atomic_int_get (&rt->blocked) == 0) //bar's menu is not now being created 155 155 { 156 156 e2_option_bool_toggle_direct (rt->hori); … … 172 172 static void _e2_toolbar_update_type_cb (GtkMenuItem *menuitem, E2_ToolbarRuntime *rt) 173 173 { 174 if ( !rt->blocked) //bar's menu is not now being created174 if (g_atomic_int_get (&rt->blocked) == 0) //bar's menu is not now being created 175 175 { 176 176 GSList *group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (menuitem)); … … 196 196 static void _e2_toolbar_increase_priority_cb (GtkMenuItem *menuitem, E2_ToolbarRuntime *rt) 197 197 { 198 if ( !rt->blocked) //bar's menu is not now being created198 if (g_atomic_int_get (&rt->blocked) == 0) //bar's menu is not now being created 199 199 { 200 200 gint i = e2_option_int_get_direct (rt->priority); … … 217 217 static void _e2_toolbar_decrease_priority_cb (GtkMenuItem *menuitem, E2_ToolbarRuntime *rt) 218 218 { 219 if ( !rt->blocked) //bar's menu is not now being created219 if (g_atomic_int_get (&rt->blocked) == 0) //bar's menu is not now being created 220 220 { 221 221 gint i = e2_option_int_get_direct (rt->priority); … … 237 237 static void _e2_toolbar_reset_priority_cb (GtkMenuItem *menuitem, E2_ToolbarRuntime *rt) 238 238 { 239 if (!rt->blocked && (e2_option_int_get_direct (rt->priority) != 0)) 239 if (g_atomic_int_get (&rt->blocked) == 0 //bar's menu is not now being created 240 && (e2_option_int_get_direct (rt->priority) != 0)) 240 241 { 241 242 e2_option_int_set_direct (rt->priority, 0); … … 256 257 static void _e2_toolbar_toggle_relief_cb (GtkCheckMenuItem *menuitem, E2_ToolbarRuntime *rt) 257 258 { 258 if ( !rt->blocked) //bar's menu is not now being created259 if (g_atomic_int_get (&rt->blocked) == 0) //bar's menu is not now being created 259 260 { 260 261 e2_option_bool_toggle_direct (rt->relief); … … 275 276 static void _e2_toolbar_toggle_same_cb (GtkMenuItem *menuitem, E2_ToolbarRuntime *rt) 276 277 { 277 if ( !rt->blocked) //bar's menu is not now being created278 if (g_atomic_int_get (&rt->blocked) == 0) //bar's menu is not now being created 278 279 { 279 280 e2_option_bool_toggle_direct (rt->same); … … 296 297 static void _e2_toolbar_update_style_cb (GtkMenuItem *menuitem, E2_ToolbarRuntime *rt) 297 298 { 298 if ( !rt->blocked) //bar's menu is not now being created299 if (g_atomic_int_get (&rt->blocked) == 0) //bar's menu is not now being created 299 300 { 300 301 GSList *group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (menuitem)); … … 320 321 static void _e2_toolbar_update_isize_cb (GtkMenuItem *menuitem, E2_ToolbarRuntime *rt) 321 322 { 322 if ( !rt->blocked) //bar's menu is not now being created323 if (g_atomic_int_get (&rt->blocked) == 0) //bar's menu is not now being created 323 324 { 324 325 GSList *group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (menuitem)); … … 356 357 ) 357 358 { 359 GtkWidget *menu, *submenu; 358 360 //block local callbacks while the menu is being constructed 359 rt->blocked = TRUE;360 GtkWidget *menu, *submenu;361 if (!g_atomic_int_compare_and_exchange (&rt->blocked, 0, 1)) 362 return FALSE; 361 363 menu = gtk_menu_new (); 362 364 e2_menu_add_check (menu, _("Show _bar"), … … 444 446 445 447 e2_menu_popup (menu, 3, event->time); 446 rt->blocked = FALSE;448 g_atomic_int_set (&rt->blocked, 0); 447 449 return TRUE; 448 450 } … … 2680 2682 rt->name = barname; 2681 2683 // rt->public_name = app.bars[barnum]->public_name; 2682 rt->blocked = FALSE;2684 rt->blocked = 0; 2683 2685 rt->hidden = FALSE; 2684 2686 rt->has_toggle = FALSE;