summaryrefslogtreecommitdiff
path: root/libcaja-private
diff options
context:
space:
mode:
authorScott Balneaves <[email protected]>2013-04-10 13:12:43 -0500
committerScott Balneaves <[email protected]>2013-04-10 13:12:43 -0500
commit801f2e3855eb627666dda712802e93d77aafdb89 (patch)
treee882a0c9528a9ca01c8041248bce9b278f645be7 /libcaja-private
parentbbc91f27ad719774e51c54c8aba2015e67c63115 (diff)
downloadcaja-801f2e3855eb627666dda712802e93d77aafdb89.tar.bz2
caja-801f2e3855eb627666dda712802e93d77aafdb89.tar.xz
Fix for issue #93
Diffstat (limited to 'libcaja-private')
-rw-r--r--libcaja-private/caja-file-changes-queue.c30
-rw-r--r--libcaja-private/caja-undostack-manager.c69
2 files changed, 97 insertions, 2 deletions
diff --git a/libcaja-private/caja-file-changes-queue.c b/libcaja-private/caja-file-changes-queue.c
index 43495c93..d300ce07 100644
--- a/libcaja-private/caja-file-changes-queue.c
+++ b/libcaja-private/caja-file-changes-queue.c
@@ -60,7 +60,11 @@ typedef struct
GList *head;
GList *tail;
#ifdef G_THREADS_ENABLED
+# if GLIB_CHECK_VERSION(3, 32, 0)
+ GMutex mutex;
+# else
GMutex *mutex;
+# endif
#endif
} CajaFileChangesQueue;
@@ -72,7 +76,11 @@ caja_file_changes_queue_new (void)
result = g_new0 (CajaFileChangesQueue, 1);
#ifdef G_THREADS_ENABLED
+# if GLIB_CHECK_VERSION(3, 32, 0)
+ g_mutex_init (&result->mutex);
+# else
result->mutex = g_mutex_new ();
+# endif
#endif
return result;
}
@@ -127,7 +135,11 @@ caja_file_changes_queue_free (CajaFileChangesQueue *queue)
g_list_free (queue->head);
#ifdef G_THREADS_ENABLED
+# if GLIB_CHECK_VERSION(3, 32, 0)
+ g_mutex_clear (&queue->mutex);
+# else
g_mutex_free (queue->mutex);
+# endif
#endif
g_free (queue);
}
@@ -139,13 +151,21 @@ caja_file_changes_queue_add_common (CajaFileChangesQueue *queue,
CajaFileChange *new_item)
{
/* enqueue the new queue item while locking down the list */
+#if GLIB_CHECK_VERSION(3, 32, 0)
+ MUTEX_LOCK (&queue->mutex);
+#else
MUTEX_LOCK (queue->mutex);
+#endif
queue->head = g_list_prepend (queue->head, new_item);
if (queue->tail == NULL)
queue->tail = queue->head;
- MUTEX_UNLOCK (queue->mutex);
+#if GLIB_CHECK_VERSION(3, 32, 0)
+ MUTEX_UNLOCK (&queue->mutex);
+#else
+ MUTEX_UNLOCK (&queue->mutex);
+#endif
}
void
@@ -247,7 +267,11 @@ caja_file_changes_queue_get_change (CajaFileChangesQueue *queue)
g_assert (queue != NULL);
/* dequeue the tail item while locking down the list */
+#if GLIB_CHECK_VERSION (3, 32, 0)
+ MUTEX_LOCK (&queue->mutex);
+#else
MUTEX_LOCK (queue->mutex);
+#endif
if (queue->tail == NULL)
{
@@ -263,7 +287,11 @@ caja_file_changes_queue_get_change (CajaFileChangesQueue *queue)
queue->tail = new_tail;
}
+#if GLIB_CHECK_VERSION (3, 32, 0)
+ MUTEX_UNLOCK (&queue->mutex);
+#else
MUTEX_UNLOCK (queue->mutex);
+#endif
return result;
}
diff --git a/libcaja-private/caja-undostack-manager.c b/libcaja-private/caja-undostack-manager.c
index 08dd827e..8c26c55b 100644
--- a/libcaja-private/caja-undostack-manager.c
+++ b/libcaja-private/caja-undostack-manager.c
@@ -100,7 +100,11 @@ struct _CajaUndoStackManagerPrivate
GQueue *stack;
guint undo_levels;
guint index;
+#if GLIB_CHECK_VERSION(3, 32, 0)
+ GMutex mutex; /* Used to protect access to stack (because of async file ops) */
+#else
GMutex *mutex; /* Used to protect access to stack (because of async file ops) */
+#endif
gboolean dispose_has_run;
gboolean undo_redo_flag;
gboolean confirm_delete;
@@ -269,7 +273,11 @@ caja_undostack_manager_init (CajaUndoStackManager * self)
/* Initialize private fields */
priv->stack = g_queue_new ();
+#if GLIB_CHECK_VERSION(3, 32, 0)
+ g_mutex_init (&priv->mutex);
+#else
priv->mutex = g_mutex_new ();
+#endif
priv->index = 0;
priv->dispose_has_run = FALSE;
priv->undo_redo_flag = FALSE;
@@ -285,14 +293,22 @@ caja_undostack_manager_dispose (GObject * object)
if (priv->dispose_has_run)
return;
+#if GLIB_CHECK_VERSION(3, 32, 0)
+ g_mutex_lock (&priv->mutex);
+#else
g_mutex_lock (priv->mutex);
+#endif
/* Free each undoable action in the stack and the stack itself */
undostack_dispose_all (priv->stack);
g_queue_free (priv->stack);
+#if GLIB_CHECK_VERSION(3, 32, 0)
+ g_mutex_unlock (&priv->mutex);
+ g_mutex_clear (&priv->mutex);
+#else
g_mutex_unlock (priv->mutex);
-
g_mutex_free (priv->mutex);
+#endif
priv->dispose_has_run = TRUE;
@@ -323,9 +339,17 @@ caja_undostack_manager_set_property (GObject * object, guint prop_id,
new_undo_levels = g_value_get_uint (value);
if (new_undo_levels > 0 && (priv->undo_levels != new_undo_levels)) {
priv->undo_levels = new_undo_levels;
+#if GLIB_CHECK_VERSION(3, 32, 0)
+ g_mutex_lock (&priv->mutex);
+#else
g_mutex_lock (priv->mutex);
+#endif
stack_fix_size (priv);
+#if GLIB_CHECK_VERSION(3, 32, 0)
+ g_mutex_unlock (&priv->mutex);
+#else
g_mutex_unlock (priv->mutex);
+#endif
do_menu_update (manager);
}
break;
@@ -412,7 +436,12 @@ caja_undostack_manager_redo (CajaUndoStackManager * manager,
char *puri;
CajaUndoStackManagerPrivate *priv = manager->priv;
+#if GLIB_CHECK_VERSION(3, 32, 0)
+ g_mutex_lock (&priv->mutex);
+#else
g_mutex_lock (priv->mutex);
+#endif
+
CajaUndoStackActionData *action = stack_scroll_left (priv);
@@ -421,7 +450,12 @@ caja_undostack_manager_redo (CajaUndoStackManager * manager,
action->locked = TRUE;
}
+#if GLIB_CHECK_VERSION(3, 32, 0)
+ g_mutex_unlock (&priv->mutex);
+#else
g_mutex_unlock (priv->mutex);
+#endif
+
do_menu_update (manager);
@@ -551,7 +585,11 @@ caja_undostack_manager_undo (CajaUndoStackManager * manager,
char *new_name;
CajaUndoStackManagerPrivate *priv = manager->priv;
+#if GLIB_CHECK_VERSION(3, 32, 0)
+ g_mutex_lock (&priv->mutex);
+#else
g_mutex_lock (priv->mutex);
+#endif
CajaUndoStackActionData *action = stack_scroll_right (priv);
@@ -559,7 +597,11 @@ caja_undostack_manager_undo (CajaUndoStackManager * manager,
action->locked = TRUE;
}
+#if GLIB_CHECK_VERSION(3, 32, 0)
+ g_mutex_unlock (&priv->mutex);
+#else
g_mutex_unlock (priv->mutex);
+#endif
do_menu_update (manager);
@@ -715,11 +757,19 @@ caja_undostack_manager_add_action (CajaUndoStackManager * manager,
action->manager = manager;
+#if GLIB_CHECK_VERSION(3, 32, 0)
+ g_mutex_lock (&priv->mutex);
+#else
g_mutex_lock (priv->mutex);
+#endif
stack_push_action (priv, action);
+#if GLIB_CHECK_VERSION(3, 32, 0)
+ g_mutex_unlock (&priv->mutex);
+#else
g_mutex_unlock (priv->mutex);
+#endif
do_menu_update (manager);
@@ -775,7 +825,12 @@ caja_undostack_manager_trash_has_emptied (CajaUndoStackManager *
/* Clear actions from the oldest to the newest move to trash */
+#if GLIB_CHECK_VERSION(3, 32, 0)
+ g_mutex_lock (&priv->mutex);
+#else
g_mutex_lock (priv->mutex);
+#endif
+
clear_redo_actions (priv);
CajaUndoStackActionData *action = NULL;
@@ -800,7 +855,11 @@ caja_undostack_manager_trash_has_emptied (CajaUndoStackManager *
}
g_queue_free (tmp_stack);
+#if GLIB_CHECK_VERSION(3, 32, 0)
+ g_mutex_unlock (&priv->mutex);
+#else
g_mutex_unlock (priv->mutex);
+#endif
do_menu_update (manager);
}
@@ -1863,7 +1922,11 @@ do_menu_update (CajaUndoStackManager * manager)
CajaUndoStackManagerPrivate *priv = manager->priv;
CajaUndoStackMenuData *data = g_slice_new0 (CajaUndoStackMenuData);
+#if GLIB_CHECK_VERSION(3, 32, 0)
+ g_mutex_lock (&priv->mutex);
+#else
g_mutex_lock (priv->mutex);
+#endif
action = get_next_undo_action (priv);
data->undo_label = get_undo_label (action);
@@ -1874,7 +1937,11 @@ do_menu_update (CajaUndoStackManager * manager)
data->redo_label = get_redo_label (action);
data->redo_description = get_redo_description (action);
+#if GLIB_CHECK_VERSION(3, 32, 0)
+ g_mutex_unlock (&priv->mutex);
+#else
g_mutex_unlock (priv->mutex);
+#endif
/* Update menus */
g_signal_emit_by_name (manager, "request-menu-update", data);