]> git.lyx.org Git - lyx.git/commitdiff
Make sure that all inputed filenames are in internal style, and avoid
authorEnrico Forestieri <forenr@lyx.org>
Fri, 12 Jan 2007 03:19:58 +0000 (03:19 +0000)
committerEnrico Forestieri <forenr@lyx.org>
Fri, 12 Jan 2007 03:19:58 +0000 (03:19 +0000)
a bug on Windows due to an unnecessary conversion to external style.

* src/insets/ExternalSupport.C
(subst_path): avoid a bug in the external material inset on Windows
by don't using external_path. The filename will be quoted and thus
there will be no problems with forward slashes.

* src/frontends/qt4/QGraphics.C
* src/frontends/qt4/QExternal.C
* src/frontends/qt4/QInclude.C:
(Qxxx::apply): On Windows, the user could input an absolute path in
native style by hand (without using the file dialog), so make sure
that no backslashes can slip in by this way.

* src/frontends/qt4/QPrefsDialog.C
(internal_path_list, external_path_list): new wrappers for the
corresponding functions in the os namespace.
(PrefPaths::apply): make sure that path_prefix is stored in the
internal style, i.e., without backslashes.
(PrefPaths::update): make sure that path_prefix is displayed to
the user in the native style.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@16659 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/qt4/QExternal.C
src/frontends/qt4/QGraphics.C
src/frontends/qt4/QInclude.C
src/frontends/qt4/QPrefsDialog.C
src/insets/ExternalSupport.C

index 48e01e8be38f8335eb14c135e0c5ae0de2e34784..8d7a131bf82760e0f0294e3826a024671291e3b5 100644 (file)
@@ -23,6 +23,7 @@
 
 #include "support/lstrings.h"
 #include "support/convert.h"
+#include "support/os.h"
 
 #include "QExternal.h"
 #include "QExternalDialog.h"
@@ -45,6 +46,8 @@ using lyx::support::isStrDbl;
 using lyx::support::token;
 using lyx::support::trim;
 
+using lyx::support::os::internal_path;
+
 using std::string;
 using std::vector;
 using std::find;
@@ -452,7 +455,7 @@ void QExternal::apply()
 {
        InsetExternalParams params = controller().params();
 
-       params.filename.set(fromqstr(dialog_->fileED->text()),
+       params.filename.set(internal_path(fromqstr(dialog_->fileED->text())),
                            kernel().bufferFilepath());
 
        params.settemplate(controller().getTemplate(
index 5de55f52b1ef79899773d39f19a9af21ef2c90e9..5c3c7c53b1789188f95005a9865ab03f5e702b75 100644 (file)
@@ -32,6 +32,7 @@
 #include "support/convert.h"
 #include "support/lstrings.h"
 #include "support/lyxlib.h"
+#include "support/os.h"
 
 #include <QLineEdit>
 #include <QPushButton>
@@ -43,6 +44,8 @@
 using lyx::support::float_equal;
 using lyx::support::token;
 
+using lyx::support::os::internal_path;
+
 #ifndef CXX_GLOBAL_CSTD
 using std::floor;
 #endif
@@ -267,7 +270,7 @@ void QGraphics::apply()
 {
        InsetGraphicsParams & igp = controller().params();
 
-       igp.filename.set(fromqstr(dialog_->filename->text()),
+       igp.filename.set(internal_path(fromqstr(dialog_->filename->text())),
                         kernel().bufferFilepath());
 
        // the bb section
index c34a0c55c2121fea1b64b5ff41e7f51b4a12330c..62a0fac90131ce31f3dd1e2122a331c96cc775ea 100644 (file)
@@ -10,6 +10,8 @@
 
 #include <config.h>
 
+#include "support/os.h"
+
 #include "QIncludeDialog.h"
 #include "QInclude.h"
 
@@ -28,6 +30,8 @@
 
 using std::string;
 
+using lyx::support::os::internal_path;
+
 namespace lyx {
 namespace frontend {
 
@@ -99,7 +103,7 @@ void QInclude::apply()
 {
        InsetCommandParams params = controller().params();
 
-       params["filename"] = qstring_to_ucs4(dialog_->filenameED->text());
+       params["filename"] = from_utf8(internal_path(fromqstr(dialog_->filenameED->text())));
        params.preview(dialog_->previewCB->isChecked());
 
        int const item = dialog_->typeCO->currentIndex();
index 0dafd89134da1ebf2ad135019ff602b1c2bf3baf..bb3610740d6da4d00218326c93995c6d19b7370c 100644 (file)
@@ -170,11 +170,23 @@ QString const external_path(string const & input)
 }
 
 
+QString const external_path_list(string const & input)
+{
+       return toqstr(lyx::support::os::external_path_list(input));
+}
+
+
 string const internal_path(QString const & input)
 {
        return lyx::support::os::internal_path(fromqstr(input));
 }
 
+
+string const internal_path_list(QString const & input)
+{
+       return lyx::support::os::internal_path_list(fromqstr(input));
+}
+
 } // end namespace anon
 
 
@@ -684,7 +696,7 @@ void PrefPaths::apply(LyXRC & rc) const
        rc.template_path = internal_path(templateDirED->text());
        rc.backupdir_path = internal_path(backupDirED->text());
        rc.tempdir_path = internal_path(tempDirED->text());
-       rc.path_prefix = fromqstr(pathPrefixED->text());
+       rc.path_prefix = internal_path_list(pathPrefixED->text());
        // FIXME: should be a checkbox only
        rc.lyxpipes = internal_path(lyxserverDirED->text());
 }
@@ -696,7 +708,7 @@ void PrefPaths::update(LyXRC const & rc)
        templateDirED->setText(external_path(rc.template_path));
        backupDirED->setText(external_path(rc.backupdir_path));
        tempDirED->setText(external_path(rc.tempdir_path));
-       pathPrefixED->setText(toqstr(rc.path_prefix));
+       pathPrefixED->setText(external_path_list(rc.path_prefix));
        // FIXME: should be a checkbox only
        lyxserverDirED->setText(external_path(rc.lyxpipes));
 }
index f724b85168cca335856e3de24d17f41a035e6e1e..7b769cd9565664d28ee323f6bb4de90308ac2ff0 100644 (file)
@@ -67,9 +67,11 @@ string const subst_path(string const & input,
 {
        if (input.find(placeholder) == string::npos)
                return input;
+       // Don't use external_path here when use_latex_path is false, as the
+       // path will be compared with another one in internal style later
+       // in Converters::move.
        string const path2 = use_latex_path ?
-               support::latex_path(path, ext, dots) :
-               support::os::external_path(path);
+               support::latex_path(path, ext, dots) : path;
        return support::subst(input, placeholder, path2);
 }