From 261277783fa16e0c974b1981a5eb0a208fca955e Mon Sep 17 00:00:00 2001 From: Neil Date: Fri, 21 Apr 2017 09:30:16 +1000 Subject: More consistent deletion of standard methods. --- src/CallTip.h | 2 +- src/CellBuffer.h | 12 +++++++++++- src/ContractionState.h | 3 +++ src/Document.h | 3 +++ src/EditModel.h | 2 +- src/EditView.h | 3 +++ src/Editor.h | 5 ++++- src/Partitioning.h | 7 +++++++ src/PerLine.h | 20 ++++++++++++++++++++ src/PositionCache.cxx | 16 +++++++++++++--- src/PositionCache.h | 16 ++++++++++++++-- src/RESearch.h | 1 + src/RunStyles.h | 3 ++- src/ScintillaBase.h | 2 +- src/SparseVector.h | 3 ++- src/SplitVector.h | 4 ++++ src/ViewStyle.h | 4 ++-- src/XPM.h | 2 +- 18 files changed, 93 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/CallTip.h b/src/CallTip.h index aec915373..ad669fa22 100644 --- a/src/CallTip.h +++ b/src/CallTip.h @@ -53,7 +53,7 @@ public: int verticalOffset; // pixel offset up or down of the calltip with respect to the line CallTip(); - // Deleted so CallTip objects can not be copied + // Deleted so CallTip objects can not be copied. CallTip(const CallTip &) = delete; CallTip &operator=(const CallTip &) = delete; ~CallTip(); diff --git a/src/CellBuffer.h b/src/CellBuffer.h index c073d5e5e..8667b8bfa 100644 --- a/src/CellBuffer.h +++ b/src/CellBuffer.h @@ -32,6 +32,9 @@ class LineVector { public: LineVector(); + // Deleted so LineVector objects can not be copied. + LineVector(const LineVector &) = delete; + void operator=(const LineVector &) = delete; ~LineVector(); void Init(); void SetPerLine(PerLine *pl); @@ -63,6 +66,9 @@ public: bool mayCoalesce; Action(); + // Deleted so Action objects can not be copied. + Action(const Action &) = delete; + void operator=(const Action &) = delete; ~Action(); void Create(actionType at_, Sci::Position position_=0, const char *data_=0, Sci::Position lenData_=0, bool mayCoalesce_=true); void Destroy(); @@ -85,8 +91,9 @@ class UndoHistory { public: UndoHistory(); - // Deleted so UndoHistory objects can not be copied + // Deleted so UndoHistory objects can not be copied. UndoHistory(const UndoHistory &) = delete; + void operator=(const UndoHistory &) = delete; ~UndoHistory(); const char *AppendAction(actionType at, Sci::Position position, const char *data, Sci::Position lengthData, bool &startSequence, bool mayCoalesce=true); @@ -145,6 +152,9 @@ private: public: CellBuffer(); + // Deleted so CellBuffer objects can not be copied. + CellBuffer(const CellBuffer &) = delete; + void operator=(const CellBuffer &) = delete; ~CellBuffer(); /// Retrieving positions outside the range of the buffer works and returns 0 diff --git a/src/ContractionState.h b/src/ContractionState.h index 91146f409..5df68a0de 100644 --- a/src/ContractionState.h +++ b/src/ContractionState.h @@ -36,6 +36,9 @@ class ContractionState { public: ContractionState(); + // Deleted so ContractionState objects can not be copied. + ContractionState(const ContractionState &) = delete; + void operator=(const ContractionState &) = delete; virtual ~ContractionState(); void Clear(); diff --git a/src/Document.h b/src/Document.h index b8a88c0df..b6c9c5bd1 100644 --- a/src/Document.h +++ b/src/Document.h @@ -260,6 +260,9 @@ public: DecorationList decorations; Document(); + // Deleted so Document objects can not be copied. + Document(const Document &) = delete; + void operator=(const Document &) = delete; virtual ~Document(); int AddRef(); diff --git a/src/EditModel.h b/src/EditModel.h index e8b031a65..087cf4934 100644 --- a/src/EditModel.h +++ b/src/EditModel.h @@ -53,7 +53,7 @@ public: Document *pdoc; EditModel(); - // Deleted so EditModel objects can not be copied + // Deleted so EditModel objects can not be copied. explicit EditModel(const EditModel &) = delete; EditModel &operator=(const EditModel &) = delete; virtual ~EditModel(); diff --git a/src/EditView.h b/src/EditView.h index d884019d4..7a3926aa2 100644 --- a/src/EditView.h +++ b/src/EditView.h @@ -90,6 +90,9 @@ public: DrawWrapMarkerFn customDrawWrapMarker; EditView(); + // Deleted so EditView objects can not be copied. + EditView(const EditView &) = delete; + void operator=(const EditView &) = delete; virtual ~EditView(); bool SetTwoPhaseDraw(bool twoPhaseDraw); diff --git a/src/Editor.h b/src/Editor.h index 4e5e56f5b..9ddb753e6 100644 --- a/src/Editor.h +++ b/src/Editor.h @@ -257,7 +257,7 @@ protected: // ScintillaBase subclass needs access to much of Editor bool convertPastes; Editor(); - // Deleted so Editor objects can not be copied + // Deleted so Editor objects can not be copied. explicit Editor(const Editor &) = delete; Editor &operator=(const Editor &) = delete; ~Editor() override; @@ -624,6 +624,9 @@ public: } } } + // Deleted so AutoSurface objects can not be copied. + AutoSurface(const AutoSurface &) = delete; + void operator=(const AutoSurface &) = delete; ~AutoSurface() { delete surf; } diff --git a/src/Partitioning.h b/src/Partitioning.h index 2c82cfac9..726b7fcdb 100644 --- a/src/Partitioning.h +++ b/src/Partitioning.h @@ -22,6 +22,9 @@ public: SetGrowSize(growSize_); ReAllocate(growSize_); } + // Deleted so SplitVectorWithRangeAdd objects can not be copied. + SplitVectorWithRangeAdd(const SplitVectorWithRangeAdd &) = delete; + void operator=(const SplitVectorWithRangeAdd &) = delete; ~SplitVectorWithRangeAdd() { } void RangeAddDelta(int start, int end, int delta) { @@ -92,6 +95,10 @@ public: Allocate(growSize); } + // Deleted so Partitioning objects can not be copied. + Partitioning(const Partitioning &) = delete; + void operator=(const Partitioning &) = delete; + ~Partitioning() { delete body; body = 0; diff --git a/src/PerLine.h b/src/PerLine.h index faf4c1cd8..300a50a86 100644 --- a/src/PerLine.h +++ b/src/PerLine.h @@ -30,6 +30,9 @@ class MarkerHandleSet { public: MarkerHandleSet(); + // Deleted so MarkerHandleSet objects can not be copied. + MarkerHandleSet(const MarkerHandleSet &) = delete; + void operator=(const MarkerHandleSet &) = delete; ~MarkerHandleSet(); int Length() const; int MarkValue() const; ///< Bit set of marker numbers. @@ -47,6 +50,9 @@ class LineMarkers : public PerLine { public: LineMarkers() : handleCurrent(0) { } + // Deleted so Worker objects can not be copied. + LineMarkers(const LineMarkers &) = delete; + void operator=(const LineMarkers &) = delete; virtual ~LineMarkers(); void Init() override; void InsertLine(Sci::Line line) override; @@ -64,6 +70,11 @@ public: class LineLevels : public PerLine { SplitVector levels; public: + LineLevels() { + } + // Deleted so Worker objects can not be copied. + LineLevels(const LineLevels &) = delete; + void operator=(const LineLevels &) = delete; virtual ~LineLevels(); void Init() override; void InsertLine(Sci::Line line) override; @@ -80,6 +91,9 @@ class LineState : public PerLine { public: LineState() { } + // Deleted so Worker objects can not be copied. + LineState(const LineState &) = delete; + void operator=(const LineState &) = delete; virtual ~LineState(); void Init() override; void InsertLine(Sci::Line line) override; @@ -95,6 +109,9 @@ class LineAnnotation : public PerLine { public: LineAnnotation() { } + // Deleted so Worker objects can not be copied. + LineAnnotation(const LineAnnotation &) = delete; + void operator=(const LineAnnotation &) = delete; virtual ~LineAnnotation(); void Init() override; void InsertLine(Sci::Line line) override; @@ -119,6 +136,9 @@ class LineTabstops : public PerLine { public: LineTabstops() { } + // Deleted so Worker objects can not be copied. + LineTabstops(const LineTabstops &) = delete; + void operator=(const LineTabstops &) = delete; virtual ~LineTabstops(); void Init() override; void InsertLine(Sci::Line line) override; diff --git a/src/PositionCache.cxx b/src/PositionCache.cxx index c5ba231de..c302f8581 100644 --- a/src/PositionCache.cxx +++ b/src/PositionCache.cxx @@ -561,7 +561,17 @@ bool BreakFinder::More() const { } PositionCacheEntry::PositionCacheEntry() : - styleNumber(0), len(0), clock(0), positions(0) { + styleNumber(0), len(0), clock(0), positions(nullptr) { +} + +// Copy constructor not currently used, but needed for being element in std::vector. +PositionCacheEntry::PositionCacheEntry(const PositionCacheEntry &other) : + styleNumber(other.styleNumber), len(other.styleNumber), clock(other.styleNumber), positions(nullptr) { + if (other.positions) { + const size_t lenData = len + (len / sizeof(XYPOSITION)) + 1; + positions = new XYPOSITION[lenData]; + memcpy(positions, other.positions, lenData * sizeof(XYPOSITION)); + } } void PositionCacheEntry::Set(unsigned int styleNumber_, const char *s_, @@ -571,7 +581,7 @@ void PositionCacheEntry::Set(unsigned int styleNumber_, const char *s_, len = len_; clock = clock_; if (s_ && positions_) { - positions = new XYPOSITION[len + (len / 4) + 1]; + positions = new XYPOSITION[len + (len / sizeof(XYPOSITION)) + 1]; for (unsigned int i=0; i *values; - // Deleted so SparseVector objects can not be copied + // Deleted so SparseVector objects can not be copied. SparseVector(const SparseVector &) = delete; + void operator=(const SparseVector &) = delete; void ClearValue(int partition) { values->SetValueAt(partition, T()); } diff --git a/src/SplitVector.h b/src/SplitVector.h index 1601bfaa6..e6a7701bb 100644 --- a/src/SplitVector.h +++ b/src/SplitVector.h @@ -70,6 +70,10 @@ public: Init(); } + // Deleted so SplitVector objects can not be copied. + SplitVector(const SplitVector &) = delete; + void operator=(const SplitVector &) = delete; + ~SplitVector() { delete []body; body = 0; diff --git a/src/ViewStyle.h b/src/ViewStyle.h index 95e1ffc2c..ad482c814 100644 --- a/src/ViewStyle.h +++ b/src/ViewStyle.h @@ -32,7 +32,7 @@ private: std::vector names; public: FontNames(); - // FontNames objects can not be copied + // FontNames objects can not be copied. FontNames(const FontNames &) = delete; FontNames &operator=(const FontNames &) = delete; ~FontNames(); @@ -44,7 +44,7 @@ class FontRealised : public FontMeasurements { public: Font font; FontRealised(); - // FontRealised objects can not be copied + // FontRealised objects can not be copied. FontRealised(const FontRealised &) = delete; FontRealised &operator=(const FontRealised &) = delete; virtual ~FontRealised(); diff --git a/src/XPM.h b/src/XPM.h index cc0d52bc0..789485eb0 100644 --- a/src/XPM.h +++ b/src/XPM.h @@ -50,7 +50,7 @@ class RGBAImage { public: RGBAImage(int width_, int height_, float scale_, const unsigned char *pixels_); explicit RGBAImage(const XPM &xpm); - // Deleted so RGBAImage objects can not be copied + // Deleted so RGBAImage objects can not be copied. RGBAImage(const RGBAImage &) = delete; RGBAImage &operator=(const RGBAImage &) = delete; virtual ~RGBAImage(); -- cgit v1.2.3