- // 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"));
+ // We do not need to produce images, etc.
+ runparams.dryrun = true;
+ buffer->writeLyXHTMLSource(oshtml, runparams, Buffer::FullSource);
+
+ theClipboard().put(lyx, oshtml.str(), plaintext);
+ }