rgheck wrote:
Andre Poenitz wrote:
But if the idea is to store the params _because they change_,
that should be a copy, i.e.

   otherstack.top().bparams = new BufferParams(buffer_.params())

with a corresponing delete somewhere, shouldn't it?

Well, here's a patch I suggested previously. JMarc thought it might be better to use a shared_ptr here. I have no strong views. You?

Isn't the attached patch simpler?

Abdel.

Index: Undo.cpp
===================================================================
--- Undo.cpp    (revision 25541)
+++ Undo.cpp    (working copy)
@@ -73,7 +73,7 @@
                    MathData * ar, BufferParams const & bp, 
                    bool ifb) :
                kind(kin), cursor(cur), cell(cel), from(fro), end(en),
-               pars(pl), array(ar), bparams(bp), isFullBuffer(ifb)
+               pars(pl), array(ar), bparams(&bp), isFullBuffer(ifb)
        {}
        /// Which kind of operation are we recording for?
        UndoKind kind;
@@ -90,7 +90,7 @@
        /// the contents of the saved MathData (for mathed)
        MathData * array;
        /// Only used in case of full backups
-       BufferParams bparams;
+       BufferParams const * bparams;
        /// Only used in case of full backups
        bool isFullBuffer;
 private:
@@ -321,9 +321,10 @@
        if (undo.isFullBuffer) {
                LASSERT(undo.pars, /**/);
                // This is a full document
-               otherstack.top().bparams = buffer_.params();
-               buffer_.params() = undo.bparams;
+               otherstack.top().bparams = new BufferParams(buffer_.params());
+               buffer_.params() = *undo.bparams;
                swap(buffer_.paragraphs(), *undo.pars);
+               delete undo.bparams;
                delete undo.pars;
                undo.pars = 0;
        } else if (dit.inMathed()) {

Reply via email to