diff --git a/uppsrc/Core/BiCont.h b/uppsrc/Core/BiCont.h index c25347b25..4e85a1bb0 100644 --- a/uppsrc/Core/BiCont.h +++ b/uppsrc/Core/BiCont.h @@ -110,6 +110,8 @@ public: T& AddTail(T *newt) { bv.AddTail(newt); return *newt; } template TT& CreateHead() { TT *q = new TT; bv.AddHead(q); return *q; } template TT& CreateTail() { TT *q = new TT; bv.AddTail(q); return *q; } + T& AddHead(One&& one) { ASSERT(one); return AddHead(one.Detach()); } + T& AddTail(One&& one) { ASSERT(one); return AddTail(one.Detach()); } T& Head() { return *(T *) bv.Head(); } T& Tail() { return *(T *) bv.Tail(); } const T& Head() const { return *(const T *) bv.Head(); } diff --git a/uppsrc/Core/Other.h b/uppsrc/Core/Other.h index 61d849d9d..9d7d8949e 100644 --- a/uppsrc/Core/Other.h +++ b/uppsrc/Core/Other.h @@ -18,67 +18,6 @@ int StaticTypeNo() { return typeno; } -template -class One : MoveableAndDeepCopyOption< One > { - mutable T *ptr; - - void Free() { if(ptr && ptr != (T*)1) delete ptr; } - template - void Pick(One&& data) { ptr = data.Detach(); } - -public: - void Attach(T *data) { Free(); ptr = data; } - T *Detach() { T *t = ptr; ptr = NULL; return t; } - void Clear() { Free(); ptr = NULL; } - - void operator=(T *data) { Attach(data); } - - template - void operator=(One&& d) { if((void *)this != (void *)&d) { Free(); Pick(pick(d)); }} - - const T *operator->() const { ASSERT(ptr); return ptr; } - T *operator->() { ASSERT(ptr); return ptr; } - const T *operator~() const { return ptr; } - T *operator~() { return ptr; } - const T *Get() const { return ptr; } - T *Get() { return ptr; } - const T& operator*() const { ASSERT(ptr); return *ptr; } - T& operator*() { ASSERT(ptr); return *ptr; } - - template - TT& Create(Args&&... args) { TT *q = new TT(std::forward(args)...); Attach(q); return *q; } - template // with C++ conforming compiler, this would not be needed - GCC bug workaround - TT& Create() { TT *q = new TT; Attach(q); return *q; } - template - T& Create(Args&&... args) { T *q = new T(std::forward(args)...); Attach(q); return *q; } - T& Create() { T *q = new T; Attach(q); return *q; } - - template - bool Is() const { return dynamic_cast(ptr); } - - bool IsEmpty() const { return !ptr; } - - operator bool() const { return ptr; } - - String ToString() const { return ptr ? AsString(*ptr) : ""; } - - One() { ptr = NULL; } - One(T *newt) { ptr = newt; } - template - One(One&& p) { Pick(pick(p)); } - One(const One& p, int) { ptr = p.IsEmpty() ? NULL : new T(clone(*p)); } - One(const One& p) = delete; - void operator=(const One& p) = delete; - ~One() { Free(); } -}; - -template -One MakeOne(Args... args) { - One r; - r.Create(args...); - return r; -} - class Any : Moveable { struct BaseData { int typeno; diff --git a/uppsrc/Core/Vcont.h b/uppsrc/Core/Vcont.h index d9c6fd602..ef0a553d6 100644 --- a/uppsrc/Core/Vcont.h +++ b/uppsrc/Core/Vcont.h @@ -100,6 +100,67 @@ public: Buffer(std::initializer_list init) : Buffer(init.size(), init) {} }; +template +class One : MoveableAndDeepCopyOption< One > { + mutable T *ptr; + + void Free() { if(ptr && ptr != (T*)1) delete ptr; } + template + void Pick(One&& data) { ptr = data.Detach(); } + +public: + void Attach(T *data) { Free(); ptr = data; } + T *Detach() { T *t = ptr; ptr = NULL; return t; } + void Clear() { Free(); ptr = NULL; } + + void operator=(T *data) { Attach(data); } + + template + void operator=(One&& d) { if((void *)this != (void *)&d) { Free(); Pick(pick(d)); }} + + const T *operator->() const { ASSERT(ptr); return ptr; } + T *operator->() { ASSERT(ptr); return ptr; } + const T *operator~() const { return ptr; } + T *operator~() { return ptr; } + const T *Get() const { return ptr; } + T *Get() { return ptr; } + const T& operator*() const { ASSERT(ptr); return *ptr; } + T& operator*() { ASSERT(ptr); return *ptr; } + + template + TT& Create(Args&&... args) { TT *q = new TT(std::forward(args)...); Attach(q); return *q; } + template // with C++ conforming compiler, this would not be needed - GCC bug workaround + TT& Create() { TT *q = new TT; Attach(q); return *q; } + template + T& Create(Args&&... args) { T *q = new T(std::forward(args)...); Attach(q); return *q; } + T& Create() { T *q = new T; Attach(q); return *q; } + + template + bool Is() const { return dynamic_cast(ptr); } + + bool IsEmpty() const { return !ptr; } + + operator bool() const { return ptr; } + + String ToString() const { return ptr ? AsString(*ptr) : ""; } + + One() { ptr = NULL; } + One(T *newt) { ptr = newt; } + template + One(One&& p) { Pick(pick(p)); } + One(const One& p, int) { ptr = p.IsEmpty() ? NULL : new T(clone(*p)); } + One(const One& p) = delete; + void operator=(const One& p) = delete; + ~One() { Free(); } +}; + +template +One MakeOne(Args&&... args) { + One r; + r.Create(std::forward(args)...); + return r; +} + template class Index; template @@ -286,6 +347,7 @@ public: T& Add(const T& x) { T *q = new T(x); vector.Add(q); return *q; } T& Add(T&& x) { T *q = new T(pick(x)); vector.Add(q); return *q; } T& Add(T *newt) { vector.Add(newt); return *newt; } + T& Add(One&& one) { ASSERT(one); return Add(one.Detach()); } template TT& Create(Args&&... args) { TT *q = new TT(std::forward(args)...); Add(q); return *q; } const T& operator[](int i) const { return Get(i); } diff --git a/uppsrc/Core/src.tpp/Array_en-us.tpp b/uppsrc/Core/src.tpp/Array_en-us.tpp index bc85feb63..57c8ec6ae 100644 --- a/uppsrc/Core/src.tpp/Array_en-us.tpp +++ b/uppsrc/Core/src.tpp/Array_en-us.tpp @@ -131,11 +131,18 @@ can be either T or a type derived from T. No constructor is applied. [s7; [*/ Return value]-|Reference to the new element (that is [* `*newt]).&] [s0;*%- &] [s4;%- &] +[s5;:Upp`:`:Array`:`:Add`(Upp`:`:One``&`&`):%- [*@4 T][@(0.0.255) `&]_[* Add]([_^Upp`:`:One^ O +ne]<[*@4 T]>`&`&_[*@3 one])&] +[s2; Creates a new element in the Array, moving the content of [%-*@3 one] +to it. [%-*@3 one] must contain a value, otherwise the behavior +is undefined.&] +[s3; &] +[s4;%- &] [s5;:Upp`:`:Array`:`:Create`(Args`&`&`.`.`.args`):%- [@(0.0.255) template]_<[@(0.0.255) c lass]_[*@4 TT], [@(0.0.255) class...]_[*@4 Args]>_[*@4 TT][@(0.0.255) `&]_[* Create]([*@4 Args][@(0.0.255) `& `&...]_[*@3 args])&] -[s2; Creates and adds a new element to the Array. [%-*@3 args] are -forwarded to constructor.&] +[s2; Creates a new element in the Array. [%-*@3 args] are forwarded +to constructor.&] [s3;%- &] [s4;%- &] [s5;:Array`:`:operator`[`]`(int`)const:%- [@(0.0.255) const]_[*@4 T][@(0.0.255) `&]_[* operat diff --git a/uppsrc/Core/src.tpp/BiArray_en-us.tpp b/uppsrc/Core/src.tpp/BiArray_en-us.tpp index 3e66c1706..bbf8d2821 100644 --- a/uppsrc/Core/src.tpp/BiArray_en-us.tpp +++ b/uppsrc/Core/src.tpp/BiArray_en-us.tpp @@ -1,5 +1,4 @@ topic "BiArray"; -[2 $$0,0#00000000000000000000000000000000:Default] [i448;a25;kKO9;2 $$1,0#37138531426314131252341829483380:class] [l288;2 $$2,0#27521748481378242620020725143825:desc] [0 $$3,0#96390100711032703541132217272105:end] @@ -9,6 +8,7 @@ topic "BiArray"; [l288;i1121;b17;O9;~~~.1408;2 $$7,0#10431211400427159095818037425705:param] [i448;b42;O9;2 $$8,8#61672508125594000341940100500538:tparam] [b42;2 $$9,9#13035079074754324216151401829390:normal] +[2 $$0,0#00000000000000000000000000000000:Default] [{_}%EN-US [ {{10000@(113.42.0) [s0; [*@7;4 BiArray]]}}&] [s3; &] @@ -176,6 +176,22 @@ _[*@4 TT][@(0.0.255) `&]_[* CreateTail]()&] [s2; Creates a new element of type [%-*@4 TT] at the tail.&] [s3;%- &] [s4;%- &] +[s5;:Upp`:`:BiArray`:`:AddHead`(Upp`:`:One``&`&`):%- [*@4 T][@(0.0.255) `&]_[* AddHead]( +[_^Upp`:`:One^ One]<[*@4 T]>`&`&_[*@3 one])&] +[s2; Creates a new element at the head, moving the content of [%-*@3 one] +to it. [%-*@3 one] must contain a value, otherwise the behavior +is undefined.&] +[s6; Invalidates iterators to the BiArray.&] +[s0; &] +[s4;%- &] +[s5;:Upp`:`:BiArray`:`:AddTail`(Upp`:`:One``&`&`):%- [*@4 T][@(0.0.255) `&]_[* AddTail]( +[_^Upp`:`:One^ One]<[*@4 T]>`&`&_[*@3 one])&] +[s2; Creates a new element at the tail, moving the content of [%-*@3 one] +to it. [%-*@3 one] must contain a value, otherwise the behavior +is undefined.&] +[s6; Invalidates iterators to the BiArray.&] +[s3; &] +[s4;%- &] [s5;:BiArray`:`:Head`(`):%- [*@4 T][@(0.0.255) `&]_[* Head]()&] [s2; Returns reference to the head of the BiArray. Same as operator`[`](0).&] [s7; [*/ Return value]-|Reference to the head of BiArray.&] diff --git a/uppsrc/Core/src.tpp/BiVector_en-us.tpp b/uppsrc/Core/src.tpp/BiVector_en-us.tpp index 478718c3a..ef542ee25 100644 --- a/uppsrc/Core/src.tpp/BiVector_en-us.tpp +++ b/uppsrc/Core/src.tpp/BiVector_en-us.tpp @@ -1,5 +1,4 @@ topic "BiVector"; -[2 $$0,0#00000000000000000000000000000000:Default] [i448;a25;kKO9;2 $$1,0#37138531426314131252341829483380:class] [l288;2 $$2,0#27521748481378242620020725143825:desc] [0 $$3,0#96390100711032703541132217272105:end] @@ -9,6 +8,7 @@ topic "BiVector"; [l288;i1121;b17;O9;~~~.1408;2 $$7,0#10431211400427159095818037425705:param] [i448;b42;O9;2 $$8,8#61672508125594000341940100500538:tparam] [b42;2 $$9,9#13035079074754324216151401829390:normal] +[2 $$0,0#00000000000000000000000000000000:Default] [{_}%EN-US [ {{10000@(113.42.0) [s0; [*@7;4 BiVector]]}}&] [s3; &] @@ -105,24 +105,6 @@ of the [* BiVector]. The new element will be at position [* GetCount]() [s6; Invalidates iterators and references to the BiVector.&] [s3;%- &] [s4;%- &] -[s5;:Upp`:`:BiVector`:`:AddHeadPick`(T`&`&`):%- [@(0.0.255) void]_[* AddHeadPick]([*@4 T][@(0.0.255) `& -`&]_[*@3 x])&] -[s2; Adds a new element at the head of the [* BiVector] and picks value -of the parameter [%-*@3 x]. The new element will be at position -0.&] -[s6; Requires T to have pick constructor.&] -[s2; Invalidates iterators and references to the BiVector.&] -[s3; &] -[s4;%- &] -[s5;:Upp`:`:BiVector`:`:AddTailPick`(T`&`&`):%- [@(0.0.255) void]_[* AddTailPick]([*@4 T][@(0.0.255) `& -`&]_[*@3 x])&] -[s2; Adds a new element at the tail of the [* BiVector] and picks value -of the parameter [%-*@3 x]. The new element will be at position -[* GetCount]() `- 1.&] -[s6; Requires T to have pick constructor.&] -[s2; Invalidates iterators and references to the BiVector.&] -[s3;%- &] -[s4;%- &] [s5;:BiVector`:`:Head`(`):%- [*@4 T][@(0.0.255) `&]_[* Head]()&] [s2; Returns a reference to the head of the [* BiVector] . Same as operator`[`](0).&] diff --git a/uppsrc/CtrlLib/CtrlUtil.h b/uppsrc/CtrlLib/CtrlUtil.h index edaa6f2f0..a3311e988 100644 --- a/uppsrc/CtrlLib/CtrlUtil.h +++ b/uppsrc/CtrlLib/CtrlUtil.h @@ -435,6 +435,8 @@ private: public: void Put(Item *newitem) { item.Add(newitem); } + void Put(One&& newitem) { item.Add(newitem.Detach()); } + template void Put(Ctrl& ctrl, T& val); diff --git a/uppsrc/RichEdit/Modify.cpp b/uppsrc/RichEdit/Modify.cpp index 707c34d9f..719407d98 100644 --- a/uppsrc/RichEdit/Modify.cpp +++ b/uppsrc/RichEdit/Modify.cpp @@ -31,9 +31,9 @@ void RichEdit::UndoBegSelFix::Apply(RichText& txt) BegSelUnFixRaw(txt); } -RichEdit::UndoRec *RichEdit::UndoBegSelFix::GetRedo(const RichText& txt) +One RichEdit::UndoBegSelFix::GetRedo(const RichText& txt) { - return new RichEdit::UndoBegSelUnFix; + return MakeOne(); } void RichEdit::UndoBegSelUnFix::Apply(RichText& text) @@ -41,16 +41,16 @@ void RichEdit::UndoBegSelUnFix::Apply(RichText& text) BegSelFixRaw(text); } -RichEdit::UndoRec * RichEdit::UndoBegSelUnFix::GetRedo(const RichText& txt) +One RichEdit::UndoBegSelUnFix::GetRedo(const RichText& txt) { - return new RichEdit::UndoBegSelFix; + return MakeOne(); } bool RichEdit::BegSelTabFix(int& count) { if(begtabsel) { // If selection starts with first table which is the first element in the text int c = cursor; - AddUndo(new UndoBegSelFix); + AddUndo(MakeOne()); BegSelFixRaw(text); // adds an empty paragraph at the start Move(0); Move(c + 1, true); // and changes the selection @@ -65,7 +65,7 @@ void RichEdit::BegSelTabFixEnd(bool fix) { // removes empty paragraph added by BegSelTabFix if(fix && GetLength() > 0) { int c = cursor; - AddUndo(new UndoBegSelUnFix); + AddUndo(MakeOne()); BegSelUnFixRaw(text); Move(0); Move(c - 1, true); @@ -78,7 +78,7 @@ bool RichEdit::InvalidRange(int l, int h) return !InSameTxt(text.GetRichPos(min(l, h)), text.GetRichPos(max(l, h))); } -void RichEdit::AddUndo(UndoRec *ur) +void RichEdit::AddUndo(One&& ur) { redo.Clear(); SetModify(); @@ -89,23 +89,23 @@ void RichEdit::AddUndo(UndoRec *ur) found = false; ur->cursor = cursor; ur->serial = undoserial; - undo.AddTail(ur); + undo.AddTail(pick(ur)); } void RichEdit::SaveStylesUndo() { - AddUndo(new UndoStyles(text)); + AddUndo(MakeOne(text)); } void RichEdit::SaveStyleUndo(const Uuid& id) { - AddUndo(new UndoStyle(text, id)); + AddUndo(MakeOne(text, id)); } void RichEdit::SaveFormat(int pos, int count) { Limit(pos, count); - AddUndo(new UndoFormat(text, pos, count)); + AddUndo(MakeOne(text, pos, count)); } void RichEdit::SaveFormat() @@ -156,7 +156,7 @@ void RichEdit::Remove(int pos, int len, bool forward) RichTxt::FormatInfo fi; if(forward) fi = text.GetFormatInfo(pos, 0); - AddUndo(new UndoRemove(text, pos, len)); + AddUndo(MakeOne(text, pos, len)); text.Remove(pos, len); if(forward) { SaveFormat(pos, 0); @@ -194,7 +194,7 @@ void RichEdit::Insert(int pos, const RichText& txt, bool typing) } } } - AddUndo(new UndoInsert(pos, l, typing)); + AddUndo(MakeOne(pos, l, typing)); } void RichEdit::Undo() @@ -208,10 +208,10 @@ void RichEdit::Undo() while(undo.GetCount()) { UndoRec& u = undo.Tail(); if(u.serial != serial) break; - UndoRec *r = u.GetRedo(text); + One r = u.GetRedo(text); r->serial = u.serial; r->cursor = cursor; - redo.Add(r); + redo.Add(pick(r)); u.Apply(text); c = u.cursor; undo.DropTail(); @@ -233,10 +233,10 @@ void RichEdit::Redo() while(redo.GetCount()) { UndoRec& r = redo.Top(); if(r.serial != serial) break; - UndoRec *u = r.GetRedo(text); + One u = r.GetRedo(text); u->serial = r.serial; u->cursor = cursor; - undo.AddTail(u); + undo.AddTail(pick(u)); r.Apply(text); c = r.cursor; redo.Drop(); diff --git a/uppsrc/RichEdit/RichEdit.h b/uppsrc/RichEdit/RichEdit.h index eeaa727f0..7b9da8331 100644 --- a/uppsrc/RichEdit/RichEdit.h +++ b/uppsrc/RichEdit/RichEdit.h @@ -306,10 +306,10 @@ private: int serial; int cursor; - virtual void Apply(RichText& txt) = 0; - virtual UndoRec *GetRedo(const RichText& txt) = 0; + virtual void Apply(RichText& txt) = 0; + virtual One GetRedo(const RichText& txt) = 0; - UndoRec *Serial(int s) { serial = s; return this; } + One Serial(int s) { serial = s; return this; } virtual ~UndoRec() {} }; @@ -319,8 +319,8 @@ private: int length; bool typing; - virtual void Apply(RichText& txt); - virtual UndoRec *GetRedo(const RichText& txt); + virtual void Apply(RichText& txt); + virtual One GetRedo(const RichText& txt); UndoInsert(int pos, int length, bool typing = false); }; @@ -329,8 +329,8 @@ private: int pos; RichText text; - virtual void Apply(RichText& txt); - virtual UndoRec *GetRedo(const RichText& txt); + virtual void Apply(RichText& txt); + virtual One GetRedo(const RichText& txt); UndoRemove(const RichText& txt, int pos, int length); }; @@ -340,8 +340,8 @@ private: int length; RichText::Formating format; - virtual void Apply(RichText& txt); - virtual UndoRec *GetRedo(const RichText& txt); + virtual void Apply(RichText& txt); + virtual One GetRedo(const RichText& txt); UndoFormat(const RichText& txt, int pos, int length); }; @@ -350,8 +350,8 @@ private: Uuid id; RichStyle style; - virtual void Apply(RichText& txt); - virtual UndoRec *GetRedo(const RichText& txt); + virtual void Apply(RichText& txt); + virtual One GetRedo(const RichText& txt); UndoStyle(const RichText& txt, const Uuid& id); }; @@ -359,8 +359,8 @@ private: struct UndoStyles : UndoRec { RichStyles styles; - virtual void Apply(RichText& txt); - virtual UndoRec *GetRedo(const RichText& txt); + virtual void Apply(RichText& txt); + virtual One GetRedo(const RichText& txt); UndoStyles(const RichText& txt); }; @@ -369,8 +369,8 @@ private: int table; RichTable::Format format; - virtual void Apply(RichText& txt); - virtual UndoRec *GetRedo(const RichText& txt); + virtual void Apply(RichText& txt); + virtual One GetRedo(const RichText& txt); UndoTableFormat(const RichText& txt, int table); }; @@ -378,8 +378,8 @@ private: struct UndoCreateTable : UndoRec { int table; - virtual void Apply(RichText& txt); - virtual UndoRec *GetRedo(const RichText& txt); + virtual void Apply(RichText& txt); + virtual One GetRedo(const RichText& txt); UndoCreateTable(int table) : table(table) {} }; @@ -388,8 +388,8 @@ private: int pos; RichTable table; - virtual void Apply(RichText& txt); - virtual UndoRec *GetRedo(const RichText& txt); + virtual void Apply(RichText& txt); + virtual One GetRedo(const RichText& txt); UndoDestroyTable(const RichText& txt, int pos); }; @@ -399,8 +399,8 @@ private: bool before; RichPara::Format format; - virtual void Apply(RichText& txt); - virtual UndoRec *GetRedo(const RichText& txt); + virtual void Apply(RichText& txt); + virtual One GetRedo(const RichText& txt); UndoRemoveParaSpecial(const RichText& txt, int table, bool before); }; @@ -409,8 +409,8 @@ private: int table; bool before; - virtual void Apply(RichText& txt); - virtual UndoRec *GetRedo(const RichText& txt); + virtual void Apply(RichText& txt); + virtual One GetRedo(const RichText& txt); UndoInsertParaSpecial(int table, bool before) : table(table), before(before) {} }; @@ -419,25 +419,25 @@ private: int table; RichTable copy; - virtual void Apply(RichText& txt); - virtual UndoRec *GetRedo(const RichText& txt); + virtual void Apply(RichText& txt); + virtual One GetRedo(const RichText& txt); UndoTable(const RichText& txt, int table); }; struct UndoBegSelFix : UndoRec { - virtual void Apply(RichText& txt); - virtual UndoRec *GetRedo(const RichText& txt); + virtual void Apply(RichText& txt); + virtual One GetRedo(const RichText& txt); }; struct UndoBegSelUnFix : UndoRec { - virtual void Apply(RichText& txt); - virtual UndoRec *GetRedo(const RichText& txt); + virtual void Apply(RichText& txt); + virtual One GetRedo(const RichText& txt); }; BiArray undo; Array redo; - + FileSel imagefs; struct StyleKey { @@ -494,7 +494,7 @@ private: void Limit(int& pos, int& count); bool InvalidRange(int c1, int c2); void NextUndo() { undoserial += incundoserial; incundoserial = false; } - void AddUndo(UndoRec *undo); + void AddUndo(One&& ur); void BeginRulerTrack(); void RulerTrack(); diff --git a/uppsrc/RichEdit/Table.cpp b/uppsrc/RichEdit/Table.cpp index cd6926fe3..92eeebe3a 100644 --- a/uppsrc/RichEdit/Table.cpp +++ b/uppsrc/RichEdit/Table.cpp @@ -4,12 +4,12 @@ namespace Upp { void RichEdit::SaveTableFormat(int table) { - AddUndo(new UndoTableFormat(text, table)); + AddUndo(MakeOne(text, table)); } void RichEdit::SaveTable(int table) { - AddUndo(new UndoTable(text, table)); + AddUndo(MakeOne(text, table)); } void RichEdit::InsertTable() @@ -52,7 +52,7 @@ void RichEdit::InsertTable() begtabsel = false; } SaveFormat(cursor, 0); - AddUndo(new UndoCreateTable(text.SetTable(cursor, table))); + AddUndo(MakeOne(text.SetTable(cursor, table))); Finish(); } @@ -72,12 +72,12 @@ struct CtrlRetrieveItemValueNN : public CtrlRetriever::Item { template void Advn(CtrlRetriever& r, Ctrl& ctrl, T& value) { ctrl <<= value; - r.Put(new CtrlRetrieveItemValueNN(ctrl, value)); + r.Put(MakeOne>(ctrl, value)); } void RichEdit::DestroyTable() { - AddUndo(new UndoDestroyTable(text, cursorp.table)); + AddUndo(MakeOne(text, cursorp.table)); int c = text.GetCellPos(cursorp.table, 0, 0).pos; text.DestroyTable(cursorp.table); Move(c); @@ -208,13 +208,13 @@ bool RichEdit::RemoveSpecial(int ll, int hh, bool back) if(InSameTxt(p1, p2)) return false; if(p1.paralen == 0 && p2.posintab == 0 && text.CanRemoveParaSpecial(p2.table, true)) { - AddUndo(new UndoRemoveParaSpecial(text, p2.table, true)); + AddUndo(MakeOne(text, p2.table, true)); text.RemoveParaSpecial(p2.table, true); Move(cursor - back); } else if(p2.paralen == 0 && p1.posintab == p1.tablen && text.CanRemoveParaSpecial(p1.table, false)) { - AddUndo(new UndoRemoveParaSpecial(text, p1.table, false)); + AddUndo(MakeOne(text, p1.table, false)); text.RemoveParaSpecial(p1.table, false); Move(cursor - back); } @@ -230,13 +230,13 @@ bool RichEdit::InsertLineSpecial() fmt.newpage = false; fmt.label.Clear(); if(cursorp.posintab == 0 && text.ShouldInsertParaSpecial(cursorp.table, true)) { - AddUndo(new UndoInsertParaSpecial(cursorp.table, true)); + AddUndo(MakeOne(cursorp.table, true)); text.InsertParaSpecial(cursorp.table, true, fmt); Move(cursor + 1); return true; } if(cursorp.posintab == cursorp.tablen && text.ShouldInsertParaSpecial(cursorp.table, false)) { - AddUndo(new UndoInsertParaSpecial(cursorp.table, false)); + AddUndo(MakeOne(cursorp.table, false)); text.InsertParaSpecial(cursorp.table, false, fmt); Move(cursor + 1); return true; diff --git a/uppsrc/RichEdit/TableUndo.cpp b/uppsrc/RichEdit/TableUndo.cpp index 15cb33a9f..b830c9aee 100644 --- a/uppsrc/RichEdit/TableUndo.cpp +++ b/uppsrc/RichEdit/TableUndo.cpp @@ -7,9 +7,9 @@ void RichEdit::UndoTableFormat::Apply(RichText& txt) txt.SetTableFormat(table, format); } -RichEdit::UndoRec *RichEdit::UndoTableFormat::GetRedo(const RichText& txt) +One RichEdit::UndoTableFormat::GetRedo(const RichText& txt) { - return new UndoTableFormat(txt, table); + return MakeOne(txt, table); } RichEdit::UndoTableFormat::UndoTableFormat(const RichText& txt, int table) @@ -26,9 +26,9 @@ void RichEdit::UndoCreateTable::Apply(RichText& txt) txt.DestroyTable(table); } -RichEdit::UndoRec *RichEdit::UndoCreateTable::GetRedo(const RichText& txt) +One RichEdit::UndoCreateTable::GetRedo(const RichText& txt) { - return new UndoDestroyTable(txt, table); + return MakeOne(txt, table); } // ----------------------- @@ -38,9 +38,9 @@ void RichEdit::UndoDestroyTable::Apply(RichText& txt) txt.SetTable(pos, table); } -RichEdit::UndoRec *RichEdit::UndoDestroyTable::GetRedo(const RichText& txt) +One RichEdit::UndoDestroyTable::GetRedo(const RichText& txt) { - return new UndoCreateTable(txt.GetRichPos(pos).table + 1); + return MakeOne(txt.GetRichPos(pos).table + 1); } RichEdit::UndoDestroyTable::UndoDestroyTable(const RichText& txt, int tab) @@ -57,9 +57,9 @@ void RichEdit::UndoInsertParaSpecial::Apply(RichText& txt) RichCellPos p = txt.GetCellPos(table, 0, 0); } -RichEdit::UndoRec *RichEdit::UndoInsertParaSpecial::GetRedo(const RichText& txt) +One RichEdit::UndoInsertParaSpecial::GetRedo(const RichText& txt) { - return new UndoRemoveParaSpecial(txt, table, before); + return MakeOne(txt, table, before); } // ----------------------- @@ -69,9 +69,9 @@ void RichEdit::UndoRemoveParaSpecial::Apply(RichText& txt) txt.InsertParaSpecial(table, before, format); } -RichEdit::UndoRec *RichEdit::UndoRemoveParaSpecial::GetRedo(const RichText& txt) +One RichEdit::UndoRemoveParaSpecial::GetRedo(const RichText& txt) { - return new UndoInsertParaSpecial(table, before); + return MakeOne(table, before); } RichEdit::UndoRemoveParaSpecial::UndoRemoveParaSpecial(const RichText& txt, int table, bool before) @@ -88,9 +88,9 @@ void RichEdit::UndoTable::Apply(RichText& txt) txt.ReplaceTable(table, copy); } -RichEdit::UndoRec *RichEdit::UndoTable::GetRedo(const RichText& txt) +One RichEdit::UndoTable::GetRedo(const RichText& txt) { - return new UndoTable(txt, table); + return MakeOne(txt, table); } RichEdit::UndoTable::UndoTable(const RichText& txt, int tab) diff --git a/uppsrc/RichEdit/Undo.cpp b/uppsrc/RichEdit/Undo.cpp index f2332bb8a..f4e4744c0 100644 --- a/uppsrc/RichEdit/Undo.cpp +++ b/uppsrc/RichEdit/Undo.cpp @@ -7,9 +7,9 @@ void RichEdit::UndoInsert::Apply(RichText& txt) txt.Remove(pos, length); } -RichEdit::UndoRec *RichEdit::UndoInsert::GetRedo(const RichText& txt) +One RichEdit::UndoInsert::GetRedo(const RichText& txt) { - return new UndoRemove(txt, pos, length); + return MakeOne(txt, pos, length); } RichEdit::UndoInsert::UndoInsert(int pos, int length, bool typing) @@ -22,9 +22,9 @@ void RichEdit::UndoRemove::Apply(RichText& txt) txt.Insert(pos, text); } -RichEdit::UndoRec *RichEdit::UndoRemove::GetRedo(const RichText& txt) +One RichEdit::UndoRemove::GetRedo(const RichText& txt) { - return new UndoInsert(pos, text.GetLength()); + return MakeOne(pos, text.GetLength()); } RichEdit::UndoRemove::UndoRemove(const RichText& txt, int pos, int length) @@ -40,9 +40,9 @@ void RichEdit::UndoFormat::Apply(RichText& txt) txt.RestoreFormat(pos, format); } -RichEdit::UndoRec *RichEdit::UndoFormat::GetRedo(const RichText& txt) +One RichEdit::UndoFormat::GetRedo(const RichText& txt) { - return new UndoFormat(txt, pos, length); + return MakeOne(txt, pos, length); } RichEdit::UndoFormat::UndoFormat(const RichText& txt, int pos, int length) @@ -58,9 +58,9 @@ void RichEdit::UndoStyle::Apply(RichText& txt) txt.SetStyle(id, style); } -RichEdit::UndoRec *RichEdit::UndoStyle::GetRedo(const RichText& txt) +One RichEdit::UndoStyle::GetRedo(const RichText& txt) { - return new UndoStyle(txt, id); + return MakeOne(txt, id); } RichEdit::UndoStyle::UndoStyle(const RichText& txt, const Uuid& id) @@ -76,9 +76,9 @@ void RichEdit::UndoStyles::Apply(RichText& txt) txt.SetStyles(styles); } -RichEdit::UndoRec *RichEdit::UndoStyles::GetRedo(const RichText& txt) +One RichEdit::UndoStyles::GetRedo(const RichText& txt) { - return new UndoStyles(txt); + return MakeOne(txt); } RichEdit::UndoStyles::UndoStyles(const RichText& txt) diff --git a/uppsrc/plugin/sqlite3/Sqlite3upp.cpp b/uppsrc/plugin/sqlite3/Sqlite3upp.cpp index 1c51d5cbe..26d6cb489 100644 --- a/uppsrc/plugin/sqlite3/Sqlite3upp.cpp +++ b/uppsrc/plugin/sqlite3/Sqlite3upp.cpp @@ -433,6 +433,7 @@ void Sqlite3Session::Close() { sql.Clear(); if (NULL != db) { SessionClose(); + DEBUGCODE(int retval =) sqlite3_close(db); // If this function fails, that means that some of the // prepared statements have not been finalized.