]> git.lyx.org Git - features.git/commitdiff
Fix crash with Menu->Edit->Paste recent
authorAbdelrazak Younes <younes@lyx.org>
Wed, 30 Jul 2008 09:09:23 +0000 (09:09 +0000)
committerAbdelrazak Younes <younes@lyx.org>
Wed, 30 Jul 2008 09:09:23 +0000 (09:09 +0000)
As an added bonus, the selection will be adapted to current Buffer (for quites, etc).

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@26001 a592a061-630c-0410-9148-cb99ea01b6c8

src/CutAndPaste.cpp
src/CutAndPaste.h
src/frontends/qt4/Menus.cpp

index f13664b35df76db5ec2e41aa51f12e5e3c289beb..82ea982b44efcf845fd59c23f2b9bf191cab429d 100644 (file)
@@ -555,9 +555,11 @@ void switchBetweenClasses(DocumentClass const * const oldone,
 }
 
 
-vector<docstring> availableSelections()
+vector<docstring> availableSelections(Buffer const * buf)
 {
        vector<docstring> selList;
+       if (!buf)
+               return selList;
 
        CutStack::const_iterator cit = theCuts.begin();
        CutStack::const_iterator end = theCuts.end();
@@ -569,7 +571,10 @@ vector<docstring> availableSelections()
                ParagraphList::const_iterator pit = pars.begin();
                ParagraphList::const_iterator pend = pars.end();
                for (; pit != pend; ++pit) {
-                       asciiSel += pit->asString(AS_STR_INSETS);
+                       Paragraph par(*pit, 0, 26);
+                       // adapt paragraph to current buffer.
+                       par.setBuffer(const_cast<Buffer &>(*buf));
+                       asciiSel += par.asString(AS_STR_INSETS);
                        if (asciiSel.size() > 25) {
                                asciiSel.replace(22, docstring::npos,
                                                 from_ascii("..."));
index c263a5c82a7126a103a536f9e67a8dfd786a0cb4..3d6e3808f6f84b9617be3298dc3bcf5fd2f4fbad 100644 (file)
@@ -33,7 +33,7 @@ class ParagraphList;
 namespace cap {
 
 /// Get all elements of the cut buffer in plain text format.
-std::vector<docstring> availableSelections();
+std::vector<docstring> availableSelections(Buffer const *);
 /// Get the number of available elements in the cut buffer.
 size_type numberOfSelections();
 /// Get the sel_index-th element of the cut buffer in plain text format.
index a808444642664e5b7b7b2e4f5bbdc3c92a25e260..adf17d24288519f952d08aa2d8df15de6c3f2d93 100644 (file)
@@ -291,7 +291,7 @@ public:
        void expandFlexInsert(Buffer const * buf, std::string s);
        void expandToc2(Toc const & toc_list, size_t from, size_t to, int depth);
        void expandToc(Buffer const * buf);
-       void expandPasteRecent();
+       void expandPasteRecent(Buffer const * buf);
        void expandToolbars();
        void expandBranches(Buffer const * buf);
        void expandCiteStyles(BufferView const *);
@@ -989,9 +989,9 @@ void MenuDefinition::expandToc(Buffer const * buf)
 }
 
 
-void MenuDefinition::expandPasteRecent()
+void MenuDefinition::expandPasteRecent(Buffer const * buf)
 {
-       docstring_list const sel = cap::availableSelections();
+       docstring_list const sel = cap::availableSelections(buf);
 
        docstring_list::const_iterator cit = sel.begin();
        docstring_list::const_iterator end = sel.end();
@@ -1367,7 +1367,7 @@ void Menus::Impl::expand(MenuDefinition const & frommenu,
                        break;
 
                case MenuItem::PasteRecent:
-                       tomenu.expandPasteRecent();
+                       tomenu.expandPasteRecent(buf);
                        break;
 
                case MenuItem::Toolbars: