]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetGraphics.cpp
Cosmetics.
[lyx.git] / src / insets / InsetGraphics.cpp
index 13de24daabbd79b4705d8bed6f7d9946b76af448..0953912cf970e013586565a1d8ccaf50cef3e333 100644 (file)
@@ -154,6 +154,23 @@ InsetGraphics::~InsetGraphics()
 }
 
 
+void InsetGraphics::setBuffer(Buffer & buffer)
+{
+       if (buffer_) {
+               try {
+                       // a file may not be copied successfully when, e.g. buffer_
+                       // has already been closed.
+                       params_.filename = params_.filename.copyTo(&buffer);
+               } catch (ExceptionMessage const & message) {
+                       Alert::error(message.title_, message.details_);
+                       // failed to embed
+                       params_.filename.setEmbed(false);
+               }
+       }
+       Inset::setBuffer(buffer);
+}
+
+
 void InsetGraphics::doDispatch(Cursor & cur, FuncRequest & cmd)
 {
        switch (cmd.action) {
@@ -167,16 +184,9 @@ void InsetGraphics::doDispatch(Cursor & cur, FuncRequest & cmd)
        case LFUN_INSET_MODIFY: {
                InsetGraphicsParams p;
                InsetGraphicsMailer::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;
-                       }
+               if (!p.filename.empty())
                        setParams(p);
-               else
+               else
                        cur.noUpdate();
                break;
        }