From: Enrico Forestieri Date: Fri, 12 Jan 2007 03:19:58 +0000 (+0000) Subject: Make sure that all inputed filenames are in internal style, and avoid X-Git-Tag: 1.6.10~11215 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=6b513c51f10c1f1f85ea8a61a7daa773a695c1cc;p=lyx.git Make sure that all inputed filenames are in internal style, and avoid 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 --- diff --git a/src/frontends/qt4/QExternal.C b/src/frontends/qt4/QExternal.C index 48e01e8be3..8d7a131bf8 100644 --- a/src/frontends/qt4/QExternal.C +++ b/src/frontends/qt4/QExternal.C @@ -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( diff --git a/src/frontends/qt4/QGraphics.C b/src/frontends/qt4/QGraphics.C index 5de55f52b1..5c3c7c53b1 100644 --- a/src/frontends/qt4/QGraphics.C +++ b/src/frontends/qt4/QGraphics.C @@ -32,6 +32,7 @@ #include "support/convert.h" #include "support/lstrings.h" #include "support/lyxlib.h" +#include "support/os.h" #include #include @@ -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 diff --git a/src/frontends/qt4/QInclude.C b/src/frontends/qt4/QInclude.C index c34a0c55c2..62a0fac901 100644 --- a/src/frontends/qt4/QInclude.C +++ b/src/frontends/qt4/QInclude.C @@ -10,6 +10,8 @@ #include +#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(); diff --git a/src/frontends/qt4/QPrefsDialog.C b/src/frontends/qt4/QPrefsDialog.C index 0dafd89134..bb3610740d 100644 --- a/src/frontends/qt4/QPrefsDialog.C +++ b/src/frontends/qt4/QPrefsDialog.C @@ -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)); } diff --git a/src/insets/ExternalSupport.C b/src/insets/ExternalSupport.C index f724b85168..7b769cd956 100644 --- a/src/insets/ExternalSupport.C +++ b/src/insets/ExternalSupport.C @@ -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); }