[gnome-todo] todo.txt-plugin: Handle user deletion of todo.txt while To Do is running
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-todo] todo.txt-plugin: Handle user deletion of todo.txt while To Do is running
- Date: Wed, 29 Mar 2017 21:43:29 +0000 (UTC)
commit b702c01311681615f23a7d7672728ee76058f577
Author: Rohit Kaushik <kaushikrohit325 gmail com>
Date: Fri Mar 24 01:55:52 2017 +0530
todo.txt-plugin: Handle user deletion of todo.txt while To Do is running
Deletion of todo.txt by user while To Do is running causes a
segmentation fault error.
The problem is G_FILE_MONITOR_EVENT_DELETED was not handled
separately in the gtd_plugin_todo_txt_monitor_source which
causes issue as source_file doesn't points to a valid file
as it has been deleted by user.
The fix is handled G_FILE_MONITOR_EVENT_DELETED handle
separately and create a new file at same path as earlier
and assign it to source_file.
https://bugzilla.gnome.org/show_bug.cgi?id=779979
plugins/todo-txt/gtd-plugin-todo-txt.c | 18 ++++++++++++++++++
plugins/todo-txt/gtd-provider-todo-txt.c | 2 +-
2 files changed, 19 insertions(+), 1 deletions(-)
---
diff --git a/plugins/todo-txt/gtd-plugin-todo-txt.c b/plugins/todo-txt/gtd-plugin-todo-txt.c
index 327da68..b4d0dc9 100644
--- a/plugins/todo-txt/gtd-plugin-todo-txt.c
+++ b/plugins/todo-txt/gtd-plugin-todo-txt.c
@@ -68,6 +68,7 @@ gtd_plugin_todo_txt_monitor_source (GFileMonitor *monitor,
{
GtdProviderTodoTxt *provider;
GtdPluginTodoTxt *self;
+ GError *error = NULL;
self = data;
@@ -78,6 +79,23 @@ gtd_plugin_todo_txt_monitor_source (GFileMonitor *monitor,
g_signal_emit_by_name (self, "provider-removed", provider);
+ if (event == G_FILE_MONITOR_EVENT_DELETED)
+ {
+ g_file_create (self->source_file,
+ G_FILE_CREATE_NONE,
+ NULL,
+ &error);
+
+ if (error)
+ {
+ gtd_manager_emit_error_message (gtd_manager_get_default (),
+ _("Cannot create Todo.txt file"),
+ error->message);
+
+ g_clear_error (&error);
+ return;
+ }
+ }
provider = gtd_provider_todo_txt_new (self->source_file);
self->providers = g_list_append (self->providers, provider);
diff --git a/plugins/todo-txt/gtd-provider-todo-txt.c b/plugins/todo-txt/gtd-provider-todo-txt.c
index 5fdb320..494787f 100644
--- a/plugins/todo-txt/gtd-provider-todo-txt.c
+++ b/plugins/todo-txt/gtd-provider-todo-txt.c
@@ -1044,7 +1044,7 @@ gtd_provider_todo_txt_finalize (GObject *object)
g_clear_pointer (&self->lists, g_hash_table_destroy);
g_clear_pointer (&self->root_tasks, g_hash_table_destroy);
g_clear_pointer (&self->tasklists, g_clear_object);
- g_clear_pointer (&self->source_file, g_free);
+ g_clear_object (&self->source_file);
g_clear_object (&self->icon);
G_OBJECT_CLASS (gtd_provider_todo_txt_parent_class)->finalize (object);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]