diff --git a/src/frontends/qt4/GuiExternal.cpp b/src/frontends/qt4/GuiExternal.cpp index 8f6d54f2bd..412f16275c 100644 --- a/src/frontends/qt4/GuiExternal.cpp +++ b/src/frontends/qt4/GuiExternal.cpp @@ -14,6 +14,7 @@ #include "GuiExternal.h" +#include "Buffer.h" #include "FuncRequest.h" #include "support/gettext.h" #include "Length.h" @@ -27,7 +28,10 @@ #include "graphics/GraphicsCacheItem.h" #include "graphics/GraphicsImage.h" +#include "frontends/alert.h" + #include "support/convert.h" +#include "support/ExceptionMessage.h" #include "support/FileFilterList.h" #include "support/filetools.h" #include "support/lstrings.h" @@ -633,8 +637,21 @@ void GuiExternal::updateTemplate() void GuiExternal::applyView() { params_.filename.set(fromqstr(fileED->text()), fromqstr(bufferFilepath())); - params_.filename.setEmbed(embedCB->checkState() == Qt::Checked); + try { + Buffer & buf = buffer(); + EmbeddedFile file(fromqstr(fileED->text()), buf.filePath()); + file.setEmbed(embedCB->checkState() == Qt::Checked); + // move file around if needed, an exception may be raised. + file.enable(buf.embedded(), &buf, true); + // if things are OK..., embed params_.filename + params_.filename.setEmbed(file.embedded()); + } catch (ExceptionMessage const & message) { + Alert::error(message.title_, message.details_); + // failed to embed + params_.filename.setEmbed(false); + } + params_.settemplate(getTemplate(externalCO->currentIndex()).lyxName); params_.draft = draftCB->isChecked(); diff --git a/src/insets/InsetExternal.cpp b/src/insets/InsetExternal.cpp index d9d210107e..c6f1142bc9 100644 --- a/src/insets/InsetExternal.cpp +++ b/src/insets/InsetExternal.cpp @@ -30,12 +30,9 @@ #include "MetricsInfo.h" #include "OutputParams.h" -#include "frontends/alert.h" - #include "graphics/PreviewLoader.h" #include "support/debug.h" -#include "support/ExceptionMessage.h" #include "support/filetools.h" #include "support/gettext.h" #include "support/lstrings.h" @@ -63,8 +60,6 @@ string defaultTemplateName; namespace lyx { -namespace Alert = frontend::Alert; - namespace external { TempName::TempName() @@ -444,15 +439,6 @@ void InsetExternal::doDispatch(Cursor & cur, FuncRequest & cmd) case LFUN_INSET_MODIFY: { InsetExternalParams p; InsetExternalMailer::string2params(to_utf8(cmd.argument()), buffer(), p); - if (!p.filename.empty()) { - try { - p.filename.enable(buffer().embedded(), &buffer(), true); - } catch (ExceptionMessage const & message) { - Alert::error(message.title_, message.details_); - // do not set parameter if an error happens - break; - } - } setParams(p); break; }