]> git.lyx.org Git - features.git/commitdiff
Make sure MarkAsExporting is deleted before buffer
authorVincent van Ravesteijn <vfr@lyx.org>
Sun, 28 Apr 2013 16:47:11 +0000 (18:47 +0200)
committerVincent van Ravesteijn <vfr@lyx.org>
Sun, 28 Apr 2013 16:51:21 +0000 (18:51 +0200)
This fixes a crash when cutting something.

src/CutAndPaste.cpp

index b0af8753cc622fdf0addb4405f6a751465297234..35e7f748a00fd6bf2b2eb0d629241d91110ae464 100644 (file)
@@ -504,26 +504,29 @@ void putClipboard(ParagraphList const & paragraphs,
        // applications, the number that can parse it should go up in the future.
        buffer->params().html_math_output = BufferParams::MathML;
 
-       // The Buffer is being used to export. This is necessary so that the
-       // updateMacros call will record the needed information.
-       MarkAsExporting mex(buffer);
-
-       buffer->updateBuffer(Buffer::UpdateMaster, OutputUpdate);
-       buffer->updateMacros();
-       buffer->updateMacroInstances(OutputUpdate);
-
-       // LyX's own format
-       string lyx;
-       ostringstream oslyx;
-       if (buffer->write(oslyx))
-               lyx = oslyx.str();
-
-       // XHTML format
-       odocstringstream oshtml;
-       OutputParams runparams(encodings.fromLyXName("utf8"));
-       buffer->writeLyXHTMLSource(oshtml, runparams, Buffer::FullSource);
-
-       theClipboard().put(lyx, oshtml.str(), plaintext);
+       // Make sure MarkAsExporting is deleted before buffer is
+       {
+               // The Buffer is being used to export. This is necessary so that the
+               // updateMacros call will record the needed information.
+               MarkAsExporting mex(buffer);
+
+               buffer->updateBuffer(Buffer::UpdateMaster, OutputUpdate);
+               buffer->updateMacros();
+               buffer->updateMacroInstances(OutputUpdate);
+
+               // LyX's own format
+               string lyx;
+               ostringstream oslyx;
+               if (buffer->write(oslyx))
+                       lyx = oslyx.str();
+
+               // XHTML format
+               odocstringstream oshtml;
+               OutputParams runparams(encodings.fromLyXName("utf8"));
+               buffer->writeLyXHTMLSource(oshtml, runparams, Buffer::FullSource);
+
+               theClipboard().put(lyx, oshtml.str(), plaintext);
+       }
 
        // Save that memory
        delete buffer;