Andre Poenitz wrote:
On Thu, Jul 10, 2008 at 06:09:28PM +0200, Abdelrazak Younes wrote:
Index: src/Undo.cpp
===================================================================
--- src/Undo.cpp        (revision 25531)
+++ src/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,8 +321,8 @@
        if (undo.isFullBuffer) {
                LASSERT(undo.pars, /**/);
                // This is a full document
-               otherstack.top().bparams = buffer_.params();
-               buffer_.params() = undo.bparams;
+               otherstack.top().bparams = &buffer_.params();
+               buffer_.params() = *undo.bparams;

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?
Ah... right, but then that would be a memory leak... I guess we need a shared_pointer here...

Abdel.

Reply via email to