[anjuta] file-manager: fix bug where we accessed the FileView even though it was freed
- From: Johannes Schmid <jhs src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [anjuta] file-manager: fix bug where we accessed the FileView even though it was freed
- Date: Thu, 24 Sep 2009 15:01:34 +0000 (UTC)
commit 7a3359c485c2f0c31a62890c46de8cdb02920c12
Author: Carl-Anton Ingmarsson <ca ingmarsson gmail com>
Date: Tue Sep 22 22:50:29 2009 +0200
file-manager: fix bug where we accessed the FileView even though it was freed
add new file_model_set_ivcs() function and use that to set the IAnjutaVcs. This
way we don't have to access the view from the model when we want to get the
IAnjutaVcs.
https://bugzilla.gnome.org/show_bug.cgi?id=596123
plugins/file-manager/file-model.c | 19 ++++++++++++++-----
plugins/file-manager/file-model.h | 5 +++++
plugins/file-manager/plugin.c | 14 +++++++++-----
plugins/file-manager/plugin.h | 1 +
4 files changed, 29 insertions(+), 10 deletions(-)
---
diff --git a/plugins/file-manager/file-model.c b/plugins/file-manager/file-model.c
index a830f09..cca2f29 100644
--- a/plugins/file-manager/file-model.c
+++ b/plugins/file-manager/file-model.c
@@ -28,7 +28,6 @@
#include <libanjuta/anjuta-debug.h>
#include <libanjuta/anjuta-plugin.h>
#include <libanjuta/anjuta-async-notify.h>
-#include <libanjuta/interfaces/ianjuta-vcs.h>
#include <gio/gio.h>
#include <gtk/gtk.h>
@@ -67,6 +66,8 @@ struct _FileModelPrivate
gboolean filter_unversioned;
GtkTreeView* view;
+
+ IAnjutaVcs *ivcs;
};
struct _FileModelAsyncData
@@ -293,8 +294,8 @@ file_model_get_vcs_status (FileModel* model,
GtkTreePath* path = gtk_tree_model_get_path (GTK_TREE_MODEL(model),
iter);
FileModelPrivate* priv = FILE_MODEL_GET_PRIVATE(model);
- IAnjutaVcs* ivcs = g_object_get_data (G_OBJECT(priv->view), "__ivcs");
- if (ivcs)
+
+ if (priv->ivcs)
{
VcsData* data = g_new0(VcsData, 1);
AnjutaAsyncNotify* notify = anjuta_async_notify_new();
@@ -305,7 +306,7 @@ file_model_get_vcs_status (FileModel* model,
g_signal_connect_swapped (G_OBJECT (notify), "finished",
G_CALLBACK (file_model_free_vcs_data), data);
- ianjuta_vcs_query_status(ivcs,
+ ianjuta_vcs_query_status(priv->ivcs,
file,
file_model_vcs_status_callback,
data,
@@ -618,7 +619,7 @@ file_model_row_collapsed (GtkTreeView* tree_view, GtkTreeIter* iter,
gtk_tree_model_get (GTK_TREE_MODEL (model), &real_iter,
COLUMN_FILE, &dir, -1);
-
+
cancel = g_object_get_data (G_OBJECT(dir), "_cancel");
g_cancellable_cancel (cancel);
g_object_unref (cancel);
@@ -823,3 +824,11 @@ file_model_get_filename (FileModel* model, GtkTreeIter* iter)
return filename;
}
+
+void
+file_model_set_ivcs (FileModel* model, IAnjutaVcs *ivcs)
+{
+ FileModelPrivate *priv = FILE_MODEL_GET_PRIVATE (model);
+
+ priv->ivcs = ivcs;
+}
diff --git a/plugins/file-manager/file-model.h b/plugins/file-manager/file-model.h
index eeadecb..9cf67c8 100644
--- a/plugins/file-manager/file-model.h
+++ b/plugins/file-manager/file-model.h
@@ -29,6 +29,8 @@
#include <gtk/gtk.h>
#include <gio/gio.h>
+#include <libanjuta/interfaces/ianjuta-vcs.h>
+
G_BEGIN_DECLS
#define FILE_TYPE_MODEL (file_model_get_type ())
@@ -80,6 +82,9 @@ file_model_get_file (FileModel* model, GtkTreeIter* iter);
gchar*
file_model_get_filename (FileModel* model, GtkTreeIter* iter);
+void
+file_model_set_ivcs (FileModel* model, IAnjutaVcs *ivcs);
+
G_END_DECLS
#endif /* _FILE_MODEL_H_ */
diff --git a/plugins/file-manager/plugin.c b/plugins/file-manager/plugin.c
index fa4ecfa..d948b9c 100644
--- a/plugins/file-manager/plugin.c
+++ b/plugins/file-manager/plugin.c
@@ -155,24 +155,28 @@ project_root_added (AnjutaPlugin *plugin, const gchar *name,
const GValue *value, gpointer user_data)
{
AnjutaFileManager* file_manager;
+ GtkTreeModelSort *tree_model;
+ FileModel *file_model;
const gchar *root_uri;
file_manager = (AnjutaFileManager*) plugin;
+ tree_model = GTK_TREE_MODEL_SORT (
+ gtk_tree_view_get_model (GTK_TREE_VIEW (file_manager->fv)));
+ file_model = FILE_MODEL (gtk_tree_model_sort_get_model (tree_model));
+
root_uri = g_value_get_string (value);
if (root_uri)
{
g_object_set (G_OBJECT(file_manager->fv), "base_uri", root_uri, NULL);
- g_object_set_data (G_OBJECT(file_manager->fv), "__ivcs",
- get_vcs_plugin (file_manager,
- root_uri));
+ file_model_set_ivcs (file_model, get_vcs_plugin (file_manager,
+ root_uri));
file_view_refresh (file_manager->fv);
file_manager->have_project = TRUE;
}
else
{
- g_object_set_data (G_OBJECT(file_manager->fv), "__ivcs",
- NULL);
+ file_model_set_ivcs(file_model, NULL);
file_manager_set_default_uri (file_manager);
file_view_refresh (file_manager->fv);
}
diff --git a/plugins/file-manager/plugin.h b/plugins/file-manager/plugin.h
index 76e3c37..de209ba 100644
--- a/plugins/file-manager/plugin.h
+++ b/plugins/file-manager/plugin.h
@@ -29,6 +29,7 @@
#include <libanjuta/anjuta-preferences.h>
#include "file-view.h"
+#include "file-model.h"
typedef struct _AnjutaFileManager AnjutaFileManager;
typedef struct _AnjutaFileManagerClass AnjutaFileManagerClass;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]