]> git.lyx.org Git - features.git/commitdiff
fix file dialog bug
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Mon, 12 Nov 2001 16:12:48 +0000 (16:12 +0000)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Mon, 12 Nov 2001 16:12:48 +0000 (16:12 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3010 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/xforms/ChangeLog
src/frontends/xforms/FormFiledialog.C

index 0f48bdf447af9d1792502c6e49f2ef60dfbd32ca..b7f4fab130779aa0beee0403d4ada7b2b2f7e29d 100644 (file)
@@ -1,3 +1,8 @@
+2001-11-12  John Levon  <moz@compsoc.man.ac.uk>
+
+       * FormFiledialog.C: don't reset path if new dir
+         doesn't exist.
 2001-11-12  Jürgen Spitzmüller  <j.spitzmueller@gmx.de>
 
        * forms/form_document.fd: Renamed "Save as Class Defaults"
index 869b5759ca7fd4ae30016667d07cee2d6e54dc76..3dc62330087ecef9d7486019c590133e8e63bf50 100644 (file)
@@ -376,11 +376,24 @@ void FileDialog::Private::Reread()
 // SetDirectory: sets dialog current directory
 void FileDialog::Private::SetDirectory(string const & Path)
 {
+       string tmp;
        if (!pszDirectory.empty()) {
                string TempPath = ExpandPath(Path); // Expand ~/
                TempPath = MakeAbsPath(TempPath, pszDirectory);
-               pszDirectory = MakeAbsPath(TempPath);
-       } else pszDirectory = MakeAbsPath(Path);
+               tmp = MakeAbsPath(TempPath);
+       } else {
+               tmp = MakeAbsPath(Path);
+       }
+       // must check the directory exists
+       DIR * pDirectory = ::opendir(tmp.c_str());
+       if (!pDirectory) {
+               WriteFSAlert(_("Warning! Couldn't open directory."), tmp);
+       } else {
+               ::closedir(pDirectory);
+               pszDirectory = tmp;
+       }
 }