Bug 234286

Summary: automatically change directory if directory doesn't exist anymore
Product: [Applications] amarok Reporter: p <peter.mueller_1955>
Component: File BrowserAssignee: Amarok Developers <amarok-bugs-dist>
Status: RESOLVED FIXED    
Severity: wishlist    
Priority: NOR    
Version: 2.3.0   
Target Milestone: ---   
Platform: openSUSE   
OS: Unspecified   
Latest Commit: Version Fixed In: 2.3.2

Description p 2010-04-13 21:27:22 UTC
Version:           2.3.0 (using KDE 4.4.2)
Installed from:    openSUSE RPMs

1. Use the directory browser to browse to some directory.
2. Exit Amarok
3. Remove the directory from 1 on OS level
4. Start Amarok -> Error directory from 1 not found

The error comes up again and again, it took some time to find out why because I haven't used the directory browser since then. If that happens switch automatically to the users home directory and then the user can use the browser if he wants to again. So the error doesn't show up without the need for the user to do anything.
Comment 1 Rick W. Chen 2010-06-13 19:20:25 UTC
commit add8a99a1814d48cbf7148b863ec4e6efa992c99
Author: Rick W. Chen <stuffcorpse@archlinux.us>
Date:   Fri Jun 11 16:26:54 2010 +1200

    Fall back to home path if stored dir in settings has since disappeared
    
    BUG:234286

diff --git a/ChangeLog b/ChangeLog
index 83acf49..a5094e2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -28,6 +28,8 @@ VERSION 2.3.2-Beta 1
       Patch by Richard Longland <rlongland@hotmail.com>.
 
   BUGFIXES:
+    * Fixed error dialog popup if the stored directory is no longer accessible
+      when using the file browser. (BR 234286)
     * Fixed resizing and eliding issues with the file browser breadcrumbs.
       (BR 231366 comment #5)
     * Drop file icons in file browser breadcrumbs. (BR 231366)
diff --git a/src/browsers/filebrowser/FileBrowser.cpp b/src/browsers/filebrowser/FileBrowser.cpp
index d1f6197..59c9815 100644
--- a/src/browsers/filebrowser/FileBrowser.cpp
+++ b/src/browsers/filebrowser/FileBrowser.cpp
@@ -236,10 +236,13 @@ FileBrowser::readConfig()
 {
     DEBUG_BLOCK
 
-    KConfigGroup config = Amarok::config( "File Browser" );
-
-    KUrl currentDirectory = config.readEntry( "Current Directory", QDir::homePath() );
-    m_kdirModel->dirLister()->openUrl( currentDirectory );
+    debug() << "home path: " <<  QDir::homePath();
+    QDir currentDirectory = Amarok::config( "File Browser" ).readEntry( "Current Directory",
+                                                                        QDir::homePath() );
+    // fall back to $HOME if config dir has since disappeared
+    if( !currentDirectory.exists()  )
+        currentDirectory = QDir::homePath();
+    m_kdirModel->dirLister()->openUrl( KUrl( currentDirectory.path() ) );
     m_currentPath = currentDirectory.path();
 
     QFile file( Amarok::saveLocation() + "file_browser_layout" );