From: Luca Gugelmann Date: Sun, 25 Mar 2007 13:49:38 +0000 (+0000) Subject: * Fixed a bug that caused dolphin to crash when clicking on the "Root" button X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/commitdiff_plain/297e0582aa3f09171f7102afa5d4cf5066b70bd5?ds=inline * Fixed a bug that caused dolphin to crash when clicking on the "Root" button in the url navigation bar. * As a side effect this also prevents a small graphics glitch, where the path labels in the navigation bar would shift a few pixels to the left when clicked twice. svn path=/trunk/KDE/kdebase/apps/; revision=646362 --- diff --git a/src/urlnavigator.cpp b/src/urlnavigator.cpp index f1b39fb32..ee06f558a 100644 --- a/src/urlnavigator.cpp +++ b/src/urlnavigator.cpp @@ -150,15 +150,19 @@ const KUrl& UrlNavigator::url() const KUrl UrlNavigator::url(int index) const { assert(index >= 0); - QString path(url().pathOrUrl()); - path = path.section('/', 0, index); - - if ( path.length() >= 1 && path.at(path.length()-1) != '/') - { - path.append('/'); + // keep scheme, hostname etc. maybe we will need this in the future + // for e.g. browsing ftp repositories. + QString pre(((QUrl)url()).toString(QUrl::RemovePath)); + QString path(url().path()); + + if (!path.isEmpty()) { + if (index == 0) //prevent the last "/" from being stripped + path = "/"; //or we end up with an empty path + else + path = path.section('/', 0, index); } - return path; + return KUrl(pre + path); } const QLinkedList& UrlNavigator::history(int& index) const