[anjuta] project-manager: Avoid a crash if a project is closed while loading it
- From: Sebastien Granjoux <sgranjoux src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [anjuta] project-manager: Avoid a crash if a project is closed while loading it
- Date: Sun, 30 Jan 2011 16:08:22 +0000 (UTC)
commit 5f7c2375f575e31a27c41385f723227a16f835d1
Author: Sébastien Granjoux <seb sfo free fr>
Date: Sun Jan 30 16:19:16 2011 +0100
project-manager: Avoid a crash if a project is closed while loading it
plugins/am-project/ac-parser.y | 8 ++++++--
plugins/am-project/command-queue.c | 19 ++++++++++++++-----
plugins/project-manager/project-view.c | 17 +++++++++++++++++
3 files changed, 37 insertions(+), 7 deletions(-)
---
diff --git a/plugins/am-project/ac-parser.y b/plugins/am-project/ac-parser.y
index 0b3f400..39066c4 100644
--- a/plugins/am-project/ac-parser.y
+++ b/plugins/am-project/ac-parser.y
@@ -374,8 +374,12 @@ comment:
;
not_eol_list:
- /* empty */
- | not_eol_list not_eol_token
+ /* empty */ {
+ $$ = NULL;
+ }
+ | not_eol_list not_eol_token {
+ $$ = $2;
+ }
;
diff --git a/plugins/am-project/command-queue.c b/plugins/am-project/command-queue.c
index 4935798..d479c7d 100644
--- a/plugins/am-project/command-queue.c
+++ b/plugins/am-project/command-queue.c
@@ -189,8 +189,8 @@ pm_command_queue_start_thread (PmCommandQueue *queue, GError **error)
}
else
{
- queue->idle_func = g_idle_add ((GSourceFunc) pm_command_queue_idle, queue);
queue->stopping = FALSE;
+ queue->idle_func = g_idle_add ((GSourceFunc) pm_command_queue_idle, queue);
return TRUE;
}
@@ -203,10 +203,8 @@ pm_command_queue_stop_thread (PmCommandQueue *queue)
{
PmJob *job;
- queue->stopping = TRUE;
-
// Remove idle function
- g_idle_remove_by_data (queue);
+ queue->stopping = TRUE;
queue->idle_func = 0;
// Request to terminate thread
@@ -292,6 +290,9 @@ pm_command_queue_idle (PmCommandQueue *queue)
PmCommandFunc func;
PmJob *job;
+ /* Remove idle handler if queue is destroyed */
+ if (queue->stopping) return FALSE;
+
/* Get completed command */
job = (PmJob *)g_async_queue_try_pop (queue->done_queue);
if (job == NULL) break;
@@ -394,11 +395,19 @@ pm_command_queue_new (void)
return queue;
}
+static gboolean
+pm_command_queue_delayed_free (gpointer data)
+{
+ g_free (data);
+
+ return FALSE;
+}
+
void
pm_command_queue_free (PmCommandQueue *queue)
{
pm_command_queue_stop_thread (queue);
- g_free (queue);
+ g_idle_add (pm_command_queue_delayed_free, queue);
}
diff --git a/plugins/project-manager/project-view.c b/plugins/project-manager/project-view.c
index a331503..74c9e25 100644
--- a/plugins/project-manager/project-view.c
+++ b/plugins/project-manager/project-view.c
@@ -336,6 +336,8 @@ row_activated (GtkTreeView *tree_view,
g_free (uri);
}
+static void on_node_loaded (AnjutaPmProject *sender, AnjutaProjectNode *node, gboolean complete, GError *error, GbfProjectView *view);
+
static void
dispose (GObject *object)
{
@@ -350,6 +352,13 @@ dispose (GObject *object)
}
if (view->model)
{
+ AnjutaPmProject *old_project;
+
+ old_project = gbf_project_model_get_project (view->model);
+ if (old_project != NULL)
+ {
+ g_signal_handlers_disconnect_by_func (old_project, G_CALLBACK (on_node_loaded), view);
+ }
g_object_unref (G_OBJECT (view->model));
view->model = NULL;
}
@@ -1497,6 +1506,14 @@ on_node_loaded (AnjutaPmProject *sender, AnjutaProjectNode *node, gboolean compl
void
gbf_project_view_set_project (GbfProjectView *view, AnjutaPmProject *project)
{
+ AnjutaPmProject *old_project;
+
+ old_project = gbf_project_model_get_project (view->model);
+ if (old_project != NULL)
+ {
+ g_signal_handlers_disconnect_by_func (old_project, G_CALLBACK (on_node_loaded), view);
+ }
+
g_signal_connect (project, "loaded", G_CALLBACK (on_node_loaded), view);
gbf_project_model_set_project (view->model, project);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]