[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#602140: konqueror: Cookie policy editor's Delete button wipes out most of the policy entries



I have been bitten by the same bug, and I've tracked it down after
restoring the polcy file from backup.  Konqueror is saving only the
entries currently selected by the site policy search instead of all of
them.

Type something in the search like google, modify something in the
dialog so apply is enabled, click apply, look at kcookiejarrc and only
the current list is saved.  Clear the site policy search (as long as
you haven't exited the dialog all the entries are still there), press
apply and all the entries are saved.  

Here's a patch.

>From c1604cb669e16a8f08894a79935510351f68f47a Mon Sep 17 00:00:00 2001
From: David Fries <david@fries.net>
Date: Tue, 2 Nov 2010 23:48:59 -0500
Subject: [PATCH] kcookiespolicies, save all cookie polcy entries

Without this patch konqueror would only save the cookie polcy entries
that were visible (the first was always saved).  This is because
QTreeWidget->itemBelow() "Returns the item visually below the given item."
Hidden items are not visible, but clearly all items should be saved, so
get the item count and save all top level items.
---
 apps/konqueror/settings/kio/kcookiespolicies.cpp |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/apps/konqueror/settings/kio/kcookiespolicies.cpp b/apps/konqueror/settings/kio/kcookiespolicies.cpp
index 17dfe10..d314af4 100644
--- a/apps/konqueror/settings/kio/kcookiespolicies.cpp
+++ b/apps/konqueror/settings/kio/kcookiespolicies.cpp
@@ -397,10 +397,11 @@ void KCookiesPolicies::save()
   QStringList domainConfig;
   QTreeWidgetItem *at = dlg->lvDomainPolicy->topLevelItem(0);
 
-  while( at )
+  // QTreeWidget->itemBelow() skips hidden items, save all of them
+  for(int i=0, stop=dlg->lvDomainPolicy->topLevelItemCount(); i<stop; ++i)
   {
+    at = dlg->lvDomainPolicy->topLevelItem(i);
     domainConfig.append(QString::fromLatin1("%1:%2").arg(QString(tolerantToAce(at->text(0)))).arg(m_pDomainPolicy[at]));
-    at = dlg->lvDomainPolicy->itemBelow(at);
   }
 
   group.writeEntry("CookieDomainAdvice", domainConfig);
-- 
1.7.1




Reply to: