The fix for bug#692526 prevents dragging feeds into / out of google reader to 
prevent a crash so the upstream patch for this bug is a complete fix when 
combined together with the fix for bug#692526.
 
Patch from upstream attached.  I've tested it and it works.
From 739a294f7c045c37e9dbce97455a71cb2357e068 Mon Sep 17 00:00:00 2001
From: Lars Windolf <lars.lind...@gmail.com>
Date: Fri, 5 Oct 2012 12:09:42 +0200
Subject: [PATCH] Fixes SF #3572660: crash in google_source_remove_node (reported by Yanko Kaneti)

---
 ChangeLog                       |    8 ++++++++
 src/fl_sources/default_source.c |    4 +++-
 src/fl_sources/google_source.c  |    3 ++-
 src/fl_sources/node_source.h    |   13 +++++++------
 src/fl_sources/ttrss_source.c   |    4 ++--
 src/node.c                      |   24 +++++++++++++++++++++++-
 src/node.h                      |   20 +++++++++++++++++++-
 src/ui/popup_menu.c             |   14 ++++++++------
 8 files changed, 72 insertions(+), 18 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 00b0ef5..abcb590 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+	To be released
+
+	* Fixes SF #3572660: crash in google_source_remove_node
+	  (reported by Yanko Kaneti)
+	* Prevents adding folders/search folders/newsbins to Google Reader
+	* Prevents sorting subscriptions in Google Reader
+
+
 2012-10-04  Lars Windolf <lars.lind...@gmail.com>
 
 	Version 1.8.9
diff --git a/src/fl_sources/default_source.c b/src/fl_sources/default_source.c
index d789dcc..2a24c5b 100644
--- a/src/fl_sources/default_source.c
+++ b/src/fl_sources/default_source.c
@@ -1,7 +1,7 @@
 /**
  * @file default_source.c  default static feed list source
  * 
- * Copyright (C) 2005-2010 Lars Lindner <lars.lind...@gmail.com>
+ * Copyright (C) 2005-2012 Lars Lindner <lars.lind...@gmail.com>
  * Copyright (C) 2005-2006 Nathan J. Conrad <t98...@users.sourceforge.net>
  *
  * This program is free software; you can redistribute it and/or modify
@@ -210,6 +210,8 @@ static struct nodeSourceType nst = {
 	.description		= "The default feed list source. Should never be added manually. If you see this then something went wrong!",
 	.capabilities		= NODE_SOURCE_CAPABILITY_IS_ROOT |
 				  NODE_SOURCE_CAPABILITY_HIERARCHIC_FEEDLIST |
+	                          NODE_SOURCE_CAPABILITY_ADD_FEED |
+	                          NODE_SOURCE_CAPABILITY_ADD_FOLDER |
 				  NODE_SOURCE_CAPABILITY_WRITABLE_FEEDLIST,
 	.source_type_init	= default_source_init,
 	.source_type_deinit	= default_source_deinit,
diff --git a/src/fl_sources/google_source.c b/src/fl_sources/google_source.c
index bc6babc..b6e63fa 100644
--- a/src/fl_sources/google_source.c
+++ b/src/fl_sources/google_source.c
@@ -373,9 +373,10 @@ static struct nodeSourceType nst = {
 	.id                  = "fl_google",
 	.name                = N_("Google Reader"),
 	.description         = N_("Integrate the feed list of your Google Reader account. Liferea will "
-	   "present your Google Reader subscriptions, and will synchronize your feed list and reading lists."),
+	                          "present your Google Reader subscriptions, and will synchronize your feed list and reading lists."),
 	.capabilities        = NODE_SOURCE_CAPABILITY_DYNAMIC_CREATION | 
 	                       NODE_SOURCE_CAPABILITY_WRITABLE_FEEDLIST |
+	                       NODE_SOURCE_CAPABILITY_ADD_FEED |
 	                       NODE_SOURCE_CAPABILITY_ITEM_STATE_SYNC,
 	.source_type_init    = google_source_init,
 	.source_type_deinit  = google_source_deinit,
diff --git a/src/fl_sources/node_source.h b/src/fl_sources/node_source.h
index 67e7a67..13f78cf 100644
--- a/src/fl_sources/node_source.h
+++ b/src/fl_sources/node_source.h
@@ -1,7 +1,7 @@
 /**
  * @file node_source.h  generic node source interface
  * 
- * Copyright (C) 2005-2010 Lars Lindner <lars.lind...@gmail.com>
+ * Copyright (C) 2005-2012 Lars Lindner <lars.lind...@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -50,11 +50,12 @@
 
 enum {
 	NODE_SOURCE_CAPABILITY_IS_ROOT			= (1<<0),	/**< flag only for default feed list source */
-	NODE_SOURCE_CAPABILITY_MULTI_INSTANCES		= (1<<1),	/**< allows multiple source instances */
-	NODE_SOURCE_CAPABILITY_DYNAMIC_CREATION		= (1<<2),	/**< feed list source is user created */
-	NODE_SOURCE_CAPABILITY_WRITABLE_FEEDLIST	= (1<<3),	/**< the feed list tree of the source can be changed */
-	NODE_SOURCE_CAPABILITY_HIERARCHIC_FEEDLIST	= (1<<4),	/**< the feed list tree of the source can have hierarchic folders */
-	NODE_SOURCE_CAPABILITY_ITEM_STATE_SYNC		= (1<<5)	/**< the item state can and should be sync'ed with remote */
+	NODE_SOURCE_CAPABILITY_DYNAMIC_CREATION		= (1<<1),	/**< feed list source is user created */
+	NODE_SOURCE_CAPABILITY_WRITABLE_FEEDLIST	= (1<<2),	/**< the feed list tree of the source can be changed */
+	NODE_SOURCE_CAPABILITY_ADD_FEED			= (1<<3),	/**< feeds can be added to the source */
+	NODE_SOURCE_CAPABILITY_ADD_FOLDER		= (1<<4),	/**< folders can be added to the source */
+	NODE_SOURCE_CAPABILITY_HIERARCHIC_FEEDLIST	= (1<<5),	/**< the feed list tree of the source can have hierarchic folders */
+	NODE_SOURCE_CAPABILITY_ITEM_STATE_SYNC		= (1<<6)	/**< the item state can and should be sync'ed with remote */
 };
 
 /** feed list node source type */
diff --git a/src/fl_sources/ttrss_source.c b/src/fl_sources/ttrss_source.c
index d513034..7567e53 100644
--- a/src/fl_sources/ttrss_source.c
+++ b/src/fl_sources/ttrss_source.c
@@ -1,7 +1,7 @@
 /**
  * @file ttrss_source.c  tt-rss feed list source support
  * 
- * Copyright (C) 2010-2011 Lars Lindner <lars.lind...@gmail.com>
+ * Copyright (C) 2010-2012 Lars Lindner <lars.lind...@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -364,7 +364,7 @@ static struct nodeSourceType nst = {
 	.name                = N_("Tiny Tiny RSS"),
 	.description         = N_("Integrate the feed list of your Tiny Tiny RSS 1.5+ account. Liferea will "
 	   "present your tt-rss subscriptions, and will synchronize your feed list and reading lists."),
-	.capabilities        = NODE_SOURCE_CAPABILITY_DYNAMIC_CREATION | 
+	.capabilities        = NODE_SOURCE_CAPABILITY_DYNAMIC_CREATION |
 	                       NODE_SOURCE_CAPABILITY_ITEM_STATE_SYNC,
 	.source_type_init    = ttrss_source_init,
 	.source_type_deinit  = ttrss_source_deinit,
diff --git a/src/node.c b/src/node.c
index 789a9a4..4612716 100644
--- a/src/node.c
+++ b/src/node.c
@@ -1,7 +1,7 @@
 /**
  * @file node.c  hierarchic feed list node handling
  * 
- * Copyright (C) 2003-2011 Lars Lindner <lars.lind...@gmail.com>
+ * Copyright (C) 2003-2012 Lars Lindner <lars.lind...@gmail.com>
  * Copyright (C) 2004-2006 Nathan J. Conrad <t98...@users.sourceforge.net>
  *
  * This program is free software; you can redistribute it and/or modify
@@ -494,6 +494,28 @@ node_get_base_url(nodePtr node)
 	return baseUrl;
 }
 
+gboolean
+node_can_add_child_feed (nodePtr node)
+{
+	g_assert (node->source->root);
+
+	if (!(NODE_TYPE (node->source->root)->capabilities & NODE_CAPABILITY_ADD_CHILDS))
+		return FALSE;
+
+	return (NODE_SOURCE_TYPE (node)->capabilities & NODE_SOURCE_CAPABILITY_ADD_FEED);
+}
+
+gboolean
+node_can_add_child_folder (nodePtr node)
+{
+	g_assert (node->source->root);
+
+	if (!(NODE_TYPE (node->source->root)->capabilities & NODE_CAPABILITY_ADD_CHILDS))
+		return FALSE;
+
+	return (NODE_SOURCE_TYPE (node)->capabilities & NODE_SOURCE_CAPABILITY_ADD_FOLDER);
+}
+
 /* node children iterating interface */
 
 void
diff --git a/src/node.h b/src/node.h
index 28f4eb1..4ff0d3b 100644
--- a/src/node.h
+++ b/src/node.h
@@ -1,7 +1,7 @@
 /**
  * @file node.h  hierarchic feed list node interface
  * 
- * Copyright (C) 2003-2010 Lars Lindner <lars.lind...@gmail.com>
+ * Copyright (C) 2003-2012 Lars Lindner <lars.lind...@gmail.com>
  * Copyright (C) 2004-2006 Nathan J. Conrad <t98...@users.sourceforge.net>
  *
  * This program is free software; you can redistribute it and/or modify
@@ -355,6 +355,24 @@ nodeViewType node_get_view_mode(nodePtr node);
  */
 const gchar * node_get_base_url(nodePtr node);
 
+/**
+ * Query wether a feed be added to the given node.
+ *
+ * @param node	the node
+ *
+ * @returns TRUE if a feed can be added
+ */
+gboolean node_can_add_child_feed (nodePtr node);
+
+/**
+ * Query wether a folder be added to the given node.
+ *
+ * @param node	the node
+ *
+ * @returns TRUE if a folder can be added
+ */
+gboolean node_can_add_child_folder (nodePtr node);
+
 /* child nodes iterating interface */
 
 typedef void 	(*nodeActionFunc)	(nodePtr node);
diff --git a/src/ui/popup_menu.c b/src/ui/popup_menu.c
index f56cba3..32ea415 100644
--- a/src/ui/popup_menu.c
+++ b/src/ui/popup_menu.c
@@ -262,14 +262,15 @@ static void
 ui_popup_node_menu (nodePtr node, gboolean validSelection, guint button, guint32 activate_time)
 {
 	GtkWidget	*menu;
-	gboolean	writeableFeedlist, isRoot, isHierarchic;
+	gboolean	writeableFeedlist, isRoot, isHierarchic, addChildren;
 
 	menu = gtk_menu_new ();
 	
 	if (node->parent) {
 		writeableFeedlist = NODE_SOURCE_TYPE (node->parent->source->root)->capabilities & NODE_SOURCE_CAPABILITY_WRITABLE_FEEDLIST;
-		isRoot = NODE_SOURCE_TYPE (node->parent->source->root)->capabilities & NODE_SOURCE_CAPABILITY_IS_ROOT;
+		isRoot = NODE_SOURCE_TYPE (node->source->root)->capabilities & NODE_SOURCE_CAPABILITY_IS_ROOT;
 		isHierarchic = NODE_SOURCE_TYPE (node->parent->source->root)->capabilities & NODE_SOURCE_CAPABILITY_HIERARCHIC_FEEDLIST;
+		addChildren = NODE_TYPE (node->source->root)->capabilities & NODE_CAPABILITY_ADD_CHILDS;
 	} else {
 		/* if we have no parent then we have the root node... */
 		writeableFeedlist = TRUE;
@@ -287,7 +288,7 @@ ui_popup_node_menu (nodePtr node, gboolean validSelection, guint button, guint32
 	}
 
 	if (writeableFeedlist) {
-		if (NODE_TYPE (node->source->root)->capabilities & NODE_CAPABILITY_ADD_CHILDS) {
+		if (addChildren) {
 			GtkWidget	*item;
 			GtkWidget	*submenu;
 
@@ -295,9 +296,10 @@ ui_popup_node_menu (nodePtr node, gboolean validSelection, guint button, guint32
 
 			item = ui_popup_add_menuitem (menu, _("_New"), NULL, NULL, NULL, 0);
 
-			ui_popup_add_menuitem (submenu, _("New _Subscription..."), ui_popup_add_feed, NULL, NULL, 0);
+			if (node_can_add_child_feed (node))
+				ui_popup_add_menuitem (submenu, _("New _Subscription..."), ui_popup_add_feed, NULL, NULL, 0);
 			
-			if (isHierarchic)
+			if (node_can_add_child_folder (node))
 				ui_popup_add_menuitem (submenu, _("New _Folder..."), ui_popup_add_folder, NULL, NULL, 0);
 				
 			if (isRoot) {
@@ -309,7 +311,7 @@ ui_popup_node_menu (nodePtr node, gboolean validSelection, guint button, guint32
 			gtk_menu_item_set_submenu (GTK_MENU_ITEM(item), submenu);
 		}
 		
-		if (node->children) {
+		if (isRoot && node->children) {
 			gtk_menu_shell_append (GTK_MENU_SHELL(menu), gtk_separator_menu_item_new());
 			ui_popup_add_menuitem (menu, _("Sort Feeds"), ui_popup_sort_feeds, node, GTK_STOCK_SORT_ASCENDING, 0);
 		}
-- 
1.7.4.1

Reply via email to