]> git.lyx.org Git - lyx.git/blobdiff - src/CutAndPaste.cpp
* GuiToolbar.cpp:
[lyx.git] / src / CutAndPaste.cpp
index 3b54dc890ae1e597d83786ef00f7a030b4df085e..e878e30c1f4bd647bbe0c6411dabf06ba8f2faa0 100644 (file)
@@ -17,6 +17,7 @@
 
 #include "Buffer.h"
 #include "buffer_funcs.h"
+#include "BufferList.h"
 #include "BufferParams.h"
 #include "BufferView.h"
 #include "Changes.h"
@@ -123,6 +124,7 @@ pasteSelectionHelper(Cursor & cur, ParagraphList const & parlist,
                                        breakParagraphConservative(
                                                        buffer.params(),
                                                        insertion, i, j);
+                                       break;
                                }
                        }
                }
@@ -365,20 +367,19 @@ void putClipboard(ParagraphList const & paragraphs,
        // a DocumentClass, via new, that is never deleted. If we were to go to
        // some kind of garbage collection there, or a shared_ptr, then this
        // would not be needed.
-       // FIXME: this cannot be static because it gets destructed after the main
-       // LyX singleton is destroyed and the code is just not ready for that yet!
-       //static Buffer buffer("", false);
-       Buffer buffer("", false);
-       buffer.setUnnamed(true);
-       buffer.paragraphs() = paragraphs;
-       buffer.params().setDocumentClass(docclass);
+       static Buffer * buffer = theBufferList().newBuffer(
+               FileName::tempName().absFilename() + "_clipboard.internal");
+       buffer->setUnnamed(true);
+       buffer->paragraphs() = paragraphs;
+       buffer->inset().setBuffer(*buffer);
+       buffer->params().setDocumentClass(docclass);
        ostringstream lyx;
-       if (buffer.write(lyx))
+       if (buffer->write(lyx))
                theClipboard().put(lyx.str(), plaintext);
        else
                theClipboard().put(string(), plaintext);
        // Save that memory
-       buffer.paragraphs().clear();
+       buffer->paragraphs().clear();
 }
 
 
@@ -758,7 +759,7 @@ void saveSelection(Cursor & cur)
        if (cur.selection() 
            && cur.selBegin() == cur.bv().cursor().selBegin()
            && cur.selEnd() == cur.bv().cursor().selEnd()) {
-               LYXERR(Debug::ACTION, "'" << cur.selectionAsString(true) << "'");
+               LYXERR(Debug::SELECTION, "saveSelection: '" << cur.selectionAsString(true) << "'");
                copySelectionToStack(cur, selectionBuffer);
        }
 }