[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kfm-devel
Subject:    Strange comparison in konqueror/src/konqpixmapprovider.cpp
From:       Jonathan Marten <jjm2 () keelhaul ! demon ! co ! uk>
Date:       2009-02-06 12:33:23
Message-ID: ovd4dv219o.fsf () keelhaul ! local
[Download RAW message or body]

Spotted something that looks odd here while looking at another favicon
problem (bug 124482).  The fix looks reasonably simple, but since this
is in the depths of Konqueror's code I though that maybe some else had
better look at it first...

In KonqPixmapProvider::notifyChange(), when a new favicon arrives the
iconMap should be updated to reflect that.  In the case where isHost
is false, the hostOrURL parameter is the full URL of the page
including the protocol.  This means that the 3rd line of the comparison

        if ( url.protocol().startsWith("http") &&
            ( ( isHost && url.host() == hostOrURL ) ||
                ( url.host() + url.path() == hostOrURL ) ) )

can never be satisfied - url.host()+url.path() will be something like
"www.kde.org/index.html" which can never match hostOrURL in the form
"http://www.kde.org/index.html".

The following patch fixes the comparison.  Any comments?

Regards, Jonathan

------------------------------------------------------------------------
--- konqpixmapprovider.cpp      (revision 920187)
+++ konqpixmapprovider.cpp      (working copy)
@@ -131,14 +131,17 @@
 void KonqPixmapProvider::notifyChange( bool isHost, const QString& hostOrURL,
     const QString& iconName )
 {
+    KUrl u;
+    if ( !isHost ) u = KUrl(hostOrURL);
+
     for ( QMap<KUrl,QString>::iterator it = iconMap.begin();
           it != iconMap.end();
           ++it )
     {
         KUrl url( it.key() );
-        if ( url.protocol().startsWith("http") &&
-            ( ( isHost && url.host() == hostOrURL ) ||
-                ( url.host() + url.path() == hostOrURL ) ) )
+        if ( !url.protocol().startsWith("http")) continue;
+        if ( ( isHost && url.host() == hostOrURL ) ||
+             ( !isHost && url.host() == u.host() && url.path() == u.path() ) )
         {
             // For host default-icons still query the favicon manager to get
             // the correct icon for pages that have an own one.
------------------------------------------------------------------------

-- 
Jonathan Marten                         http://www.keelhaul.demon.co.uk
Twickenham, UK                          jjm2@keelhaul.demon.co.uk
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic