SVN commit 827076 by dfaure: Fix infinite loop when KHTMLPart is requested to open a directory. konqueror saw the redirection from $URL to $URL as a jump to anchor, so it didn't re-evaluate the mimetype before asking khtmlpart to open the url again. Now khtmlpart flags the error, and konqueror tests for a loading error before assuming jump-to-anchor. BUG: 164495 M +3 -2 kdebase/apps/konqueror/src/konqmainwindow.cpp M +6 -0 kdebase/apps/konqueror/src/konqview.h M +11 -0 kdebase/apps/konqueror/src/tests/konqhtmltest.cpp M +1 -0 kdelibs/khtml/khtml_part.cpp --- trunk/KDE/kdebase/apps/konqueror/src/konqmainwindow.cpp #827075:827076 @@ -1004,8 +1004,9 @@ // Clicking on a link that points to the page itself (e.g. anchor) if ( !browserArgs.doPost() && !args.reload() && - childView && urlcmp( url.url(), childView->url().url(), - KUrl::CompareWithoutTrailingSlash | KUrl::CompareWithoutFragment ) ) + childView && !childView->aborted() && // #164495 + urlcmp( url.url(), childView->url().url(), + KUrl::CompareWithoutTrailingSlash | KUrl::CompareWithoutFragment ) ) { QString serviceType = args.mimeType(); if ( serviceType.isEmpty() ) --- trunk/KDE/kdebase/apps/konqueror/src/konqview.h #827075:827076 @@ -237,6 +237,12 @@ */ void partDeleted() { m_pPart = 0L; } + /** + * Return true if the loading in the view was aborted due to an error + * or to user cancellation + */ + bool aborted() const { return m_bAborted; } + KParts::BrowserExtension *browserExtension() const; KParts::StatusBarExtension *statusBarExtension() const; --- trunk/KDE/kdebase/apps/konqueror/src/tests/konqhtmltest.cpp #827075:827076 @@ -40,7 +40,18 @@ QVERIFY(view->part()); QVERIFY(QTest::kWaitForSignal(view, SIGNAL(viewCompleted(KonqView*)), 1000)); QCOMPARE(view->serviceType(), QString("text/html")); + //KHTMLPart* part = qobject_cast(view->part()); + //QVERIFY(part); + } + void loadDirectory() // #164495 + { + KonqMainWindow mainWindow; + mainWindow.openUrl(0, KUrl(QDir::homePath()), "text/html"); + KonqView* view = mainWindow.currentView(); + QVERIFY(QTest::kWaitForSignal(view, SIGNAL(viewCompleted(KonqView*)), 1000)); // error calls openUrlRequest + QVERIFY(QTest::kWaitForSignal(view, SIGNAL(viewCompleted(KonqView*)), 1000)); // which then opens the right part + QCOMPARE(view->serviceType(), QString("inode/directory")); } void rightClickClose() // #149736 --- trunk/KDE/kdelibs/khtml/khtml_part.cpp #827075:827076 @@ -1806,6 +1806,7 @@ // a directory... if (job->error() == KIO::ERR_IS_DIRECTORY) { + emit canceled( job->errorString() ); emit d->m_extension->openUrlRequest( d->m_workingURL ); } else