From 9472b43539e7b4a6a3f5e657b0ec06e9e6e5eab9 Mon Sep 17 00:00:00 2001 From: Neil Date: Sat, 28 Apr 2018 10:31:25 +1000 Subject: Delete standard functions on classes where there could be attempts to copy. --- src/CallTip.h | 2 ++ src/CellBuffer.cxx | 5 +++++ src/CellBuffer.h | 2 ++ src/EditModel.h | 4 +++- src/EditView.h | 6 +++++- src/Editor.h | 4 +++- src/PerLine.h | 12 +++++++++++- src/PositionCache.h | 10 ++++++++++ src/ScintillaBase.cxx | 5 +++++ src/ScintillaBase.h | 4 +++- src/SparseVector.h | 8 +++++--- src/Style.h | 6 +++++- src/ViewStyle.h | 6 ++++++ src/XPM.h | 11 +++++++++++ 14 files changed, 76 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/CallTip.h b/src/CallTip.h index 9c00a777d..a37138d5f 100644 --- a/src/CallTip.h +++ b/src/CallTip.h @@ -53,7 +53,9 @@ public: CallTip(); // Deleted so CallTip objects can not be copied. CallTip(const CallTip &) = delete; + CallTip(CallTip &&) = delete; CallTip &operator=(const CallTip &) = delete; + CallTip &operator=(CallTip &&) = delete; ~CallTip(); void PaintCT(Surface *surfaceWindow); diff --git a/src/CellBuffer.cxx b/src/CellBuffer.cxx index 893938f2f..f1ac548cc 100644 --- a/src/CellBuffer.cxx +++ b/src/CellBuffer.cxx @@ -53,6 +53,11 @@ public: LineVector() : starts(256), perLine(0) { Init(); } + // Deleted so LineVector objects can not be copied. + LineVector(const LineVector &) = delete; + LineVector(LineVector &&) = delete; + LineVector &operator=(const LineVector &) = delete; + LineVector &operator=(LineVector &&) = delete; ~LineVector() override { } void Init() override { diff --git a/src/CellBuffer.h b/src/CellBuffer.h index 3e3ec3015..a98d9abcb 100644 --- a/src/CellBuffer.h +++ b/src/CellBuffer.h @@ -66,7 +66,9 @@ public: UndoHistory(); // Deleted so UndoHistory objects can not be copied. UndoHistory(const UndoHistory &) = delete; + UndoHistory(UndoHistory &&) = delete; void operator=(const UndoHistory &) = delete; + void operator=(UndoHistory &&) = delete; ~UndoHistory(); const char *AppendAction(actionType at, Sci::Position position, const char *data, Sci::Position lengthData, bool &startSequence, bool mayCoalesce=true); diff --git a/src/EditModel.h b/src/EditModel.h index eae18cacf..7ad719c12 100644 --- a/src/EditModel.h +++ b/src/EditModel.h @@ -54,8 +54,10 @@ public: EditModel(); // Deleted so EditModel objects can not be copied. - explicit EditModel(const EditModel &) = delete; + EditModel(const EditModel &) = delete; + EditModel(EditModel &&) = delete; EditModel &operator=(const EditModel &) = delete; + EditModel &operator=(EditModel &&) = delete; virtual ~EditModel(); virtual Sci::Line TopLineOfMain() const = 0; virtual Point GetVisibleOriginInMain() const = 0; diff --git a/src/EditView.h b/src/EditView.h index 37d0423bb..ac42f072b 100644 --- a/src/EditView.h +++ b/src/EditView.h @@ -92,7 +92,9 @@ public: EditView(); // Deleted so EditView objects can not be copied. EditView(const EditView &) = delete; + EditView(EditView &&) = delete; void operator=(const EditView &) = delete; + void operator=(EditView &&) = delete; virtual ~EditView(); bool SetTwoPhaseDraw(bool twoPhaseDraw); @@ -159,8 +161,10 @@ class AutoLineLayout { LineLayout *ll; public: AutoLineLayout(LineLayoutCache &llc_, LineLayout *ll_) : llc(llc_), ll(ll_) {} - explicit AutoLineLayout(const AutoLineLayout &) = delete; + AutoLineLayout(const AutoLineLayout &) = delete; + AutoLineLayout(AutoLineLayout &&) = delete; AutoLineLayout &operator=(const AutoLineLayout &) = delete; + AutoLineLayout &operator=(AutoLineLayout &&) = delete; ~AutoLineLayout() { llc.Dispose(ll); ll = 0; diff --git a/src/Editor.h b/src/Editor.h index 9fda8ddea..33dae2f67 100644 --- a/src/Editor.h +++ b/src/Editor.h @@ -256,8 +256,10 @@ protected: // ScintillaBase subclass needs access to much of Editor Editor(); // Deleted so Editor objects can not be copied. - explicit Editor(const Editor &) = delete; + Editor(const Editor &) = delete; + Editor(Editor &&) = delete; Editor &operator=(const Editor &) = delete; + Editor &operator=(Editor &&) = delete; ~Editor() override; virtual void Initialise() = 0; virtual void Finalise(); diff --git a/src/PerLine.h b/src/PerLine.h index c75a83f65..ad9f9ee75 100644 --- a/src/PerLine.h +++ b/src/PerLine.h @@ -30,7 +30,9 @@ public: MarkerHandleSet(); // Deleted so MarkerHandleSet objects can not be copied. MarkerHandleSet(const MarkerHandleSet &) = delete; + MarkerHandleSet(MarkerHandleSet &&) = delete; void operator=(const MarkerHandleSet &) = delete; + void operator=(MarkerHandleSet &&) = delete; ~MarkerHandleSet(); bool Empty() const noexcept; int MarkValue() const noexcept; ///< Bit set of marker numbers. @@ -72,9 +74,11 @@ class LineLevels : public PerLine { public: LineLevels() { } - // Deleted so Worker objects can not be copied. + // Deleted so LineLevels objects can not be copied. LineLevels(const LineLevels &) = delete; + LineLevels(LineLevels &&) = delete; void operator=(const LineLevels &) = delete; + void operator=(LineLevels &&) = delete; ~LineLevels() override; void Init() override; void InsertLine(Sci::Line line) override; @@ -93,7 +97,9 @@ public: } // Deleted so Worker objects can not be copied. LineState(const LineState &) = delete; + LineState(LineState &&) = delete; void operator=(const LineState &) = delete; + void operator=(LineState &&) = delete; ~LineState() override; void Init() override; void InsertLine(Sci::Line line) override; @@ -111,7 +117,9 @@ public: } // Deleted so Worker objects can not be copied. LineAnnotation(const LineAnnotation &) = delete; + LineAnnotation(LineAnnotation &&) = delete; void operator=(const LineAnnotation &) = delete; + void operator=(LineAnnotation &&) = delete; ~LineAnnotation() override; void Init() override; void InsertLine(Sci::Line line) override; @@ -138,7 +146,9 @@ public: } // Deleted so Worker objects can not be copied. LineTabstops(const LineTabstops &) = delete; + LineTabstops(LineTabstops &&) = delete; void operator=(const LineTabstops &) = delete; + void operator=(LineTabstops &&) = delete; ~LineTabstops() override; void Init() override; void InsertLine(Sci::Line line) override; diff --git a/src/PositionCache.h b/src/PositionCache.h index fcbb1cdf7..c294edebd 100644 --- a/src/PositionCache.h +++ b/src/PositionCache.h @@ -77,7 +77,9 @@ public: explicit LineLayout(int maxLineLength_); // Deleted so LineLayout objects can not be copied. LineLayout(const LineLayout &) = delete; + LineLayout(LineLayout &&) = delete; void operator=(const LineLayout &) = delete; + void operator=(LineLayout &&) = delete; virtual ~LineLayout(); void Resize(int maxLineLength_); void Free(); @@ -110,7 +112,9 @@ public: LineLayoutCache(); // Deleted so LineLayoutCache objects can not be copied. LineLayoutCache(const LineLayoutCache &) = delete; + LineLayoutCache(LineLayoutCache &&) = delete; void operator=(const LineLayoutCache &) = delete; + void operator=(LineLayoutCache &&) = delete; virtual ~LineLayoutCache(); void Deallocate(); enum { @@ -137,7 +141,9 @@ public: // Copy constructor not currently used, but needed for being element in std::vector. PositionCacheEntry(const PositionCacheEntry &); // Deleted so PositionCacheEntry objects can not be assigned. + PositionCacheEntry(PositionCacheEntry &&) = delete; void operator=(const PositionCacheEntry &) = delete; + void operator=(PositionCacheEntry &&) = delete; ~PositionCacheEntry(); void Set(unsigned int styleNumber_, const char *s_, unsigned int len_, XYPOSITION *positions_, unsigned int clock_); void Clear(); @@ -204,7 +210,9 @@ public: int xStart, bool breakForSelection, const Document *pdoc_, const SpecialRepresentations *preprs_, const ViewStyle *pvsDraw); // Deleted so BreakFinder objects can not be copied. BreakFinder(const BreakFinder &) = delete; + BreakFinder(BreakFinder &&) = delete; void operator=(const BreakFinder &) = delete; + void operator=(BreakFinder &&) = delete; ~BreakFinder(); TextSegment Next(); bool More() const; @@ -218,7 +226,9 @@ public: PositionCache(); // Deleted so PositionCache objects can not be copied. PositionCache(const PositionCache &) = delete; + PositionCache(PositionCache &&) = delete; void operator=(const PositionCache &) = delete; + void operator=(PositionCache &&) = delete; ~PositionCache(); void Clear(); void SetSize(size_t size_); diff --git a/src/ScintillaBase.cxx b/src/ScintillaBase.cxx index 9c4e8cf78..9855c1638 100644 --- a/src/ScintillaBase.cxx +++ b/src/ScintillaBase.cxx @@ -553,6 +553,11 @@ public: int lexLanguage; explicit LexState(Document *pdoc_); + // Deleted so LexState objects can not be copied. + LexState(const LexState &) = delete; + LexState(LexState &&) = delete; + LexState &operator=(const LexState &) = delete; + LexState &operator=(LexState &&) = delete; ~LexState() override; void SetLexer(uptr_t wParam); void SetLexerLanguage(const char *languageName); diff --git a/src/ScintillaBase.h b/src/ScintillaBase.h index 202098129..e886f22e2 100644 --- a/src/ScintillaBase.h +++ b/src/ScintillaBase.h @@ -53,8 +53,10 @@ protected: ScintillaBase(); // Deleted so ScintillaBase objects can not be copied. - explicit ScintillaBase(const ScintillaBase &) = delete; + ScintillaBase(const ScintillaBase &) = delete; + ScintillaBase(ScintillaBase &&) = delete; ScintillaBase &operator=(const ScintillaBase &) = delete; + ScintillaBase &operator=(ScintillaBase &&) = delete; ~ScintillaBase() override; void Initialise() override {} void Finalise() override; diff --git a/src/SparseVector.h b/src/SparseVector.h index 0667e54c4..2d3e9cfae 100644 --- a/src/SparseVector.h +++ b/src/SparseVector.h @@ -18,9 +18,6 @@ private: std::unique_ptr> starts; std::unique_ptr> values; T empty; - // Deleted so SparseVector objects can not be copied. - SparseVector(const SparseVector &) = delete; - void operator=(const SparseVector &) = delete; void ClearValue(Sci::Position partition) { values->SetValueAt(partition, T()); } @@ -30,6 +27,11 @@ public: values = std::make_unique>(); values->InsertEmpty(0, 2); } + // Deleted so SparseVector objects can not be copied. + SparseVector(const SparseVector &) = delete; + SparseVector(SparseVector &&) = delete; + void operator=(const SparseVector &) = delete; + void operator=(SparseVector &&) = delete; ~SparseVector() { starts.reset(); // starts dead here but not used by ClearValue. diff --git a/src/Style.h b/src/Style.h index 51ab5d3e6..58cc3cd82 100644 --- a/src/Style.h +++ b/src/Style.h @@ -34,8 +34,10 @@ class FontAlias : public Font { public: FontAlias(); // FontAlias objects can not be assigned except for initialization - FontAlias &operator=(const FontAlias &) = delete; FontAlias(const FontAlias &); + FontAlias(FontAlias &&) = delete; + FontAlias &operator=(const FontAlias &) = delete; + FontAlias &operator=(FontAlias &&) = delete; ~FontAlias() override; void MakeAlias(Font &fontOrigin); void ClearFont(); @@ -70,8 +72,10 @@ public: Style(); Style(const Style &source); + Style(Style &&) = delete; ~Style(); Style &operator=(const Style &source); + Style &operator=(Style &&) = delete; void Clear(ColourDesired fore_, ColourDesired back_, int size_, const char *fontName_, int characterSet_, diff --git a/src/ViewStyle.h b/src/ViewStyle.h index c2e052e03..2a4e7329a 100644 --- a/src/ViewStyle.h +++ b/src/ViewStyle.h @@ -32,7 +32,9 @@ public: FontNames(); // FontNames objects can not be copied. FontNames(const FontNames &) = delete; + FontNames(FontNames &&) = delete; FontNames &operator=(const FontNames &) = delete; + FontNames &operator=(FontNames &&) = delete; ~FontNames(); void Clear(); const char *Save(const char *name); @@ -44,7 +46,9 @@ public: FontRealised(); // FontRealised objects can not be copied. FontRealised(const FontRealised &) = delete; + FontRealised(FontRealised &&) = delete; FontRealised &operator=(const FontRealised &) = delete; + FontRealised &operator=(FontRealised &&) = delete; virtual ~FontRealised(); void Realise(Surface &surface, int zoomLevel, int technology, const FontSpecification &fs); }; @@ -174,8 +178,10 @@ public: ViewStyle(); ViewStyle(const ViewStyle &source); + ViewStyle(ViewStyle &&) = delete; // Can only be copied through copy constructor which ensures font names initialised correctly ViewStyle &operator=(const ViewStyle &) = delete; + ViewStyle &operator=(ViewStyle &&) = delete; ~ViewStyle(); void CalculateMarginWidthAndMask(); void Init(size_t stylesSize_=256); diff --git a/src/XPM.h b/src/XPM.h index 2af0ae84e..92deb9e8a 100644 --- a/src/XPM.h +++ b/src/XPM.h @@ -25,6 +25,10 @@ class XPM { public: explicit XPM(const char *textForm); explicit XPM(const char *const *linesForm); + XPM(const XPM &) = delete; + XPM(XPM &&) = delete; + XPM &operator=(const XPM &) = delete; + XPM &operator=(XPM &&) = delete; ~XPM(); void Init(const char *textForm); void Init(const char *const *linesForm); @@ -50,7 +54,9 @@ public: explicit RGBAImage(const XPM &xpm); // Deleted so RGBAImage objects can not be copied. RGBAImage(const RGBAImage &) = delete; + RGBAImage(RGBAImage &&) = delete; RGBAImage &operator=(const RGBAImage &) = delete; + RGBAImage &operator=(RGBAImage &&) = delete; virtual ~RGBAImage(); int GetHeight() const { return height; } int GetWidth() const { return width; } @@ -72,6 +78,11 @@ class RGBAImageSet { mutable int width; ///< Memorize largest width of the set. public: RGBAImageSet(); + // Deleted so RGBAImageSet objects can not be copied. + RGBAImageSet(const RGBAImageSet &) = delete; + RGBAImageSet(RGBAImageSet &&) = delete; + RGBAImageSet &operator=(const RGBAImageSet &) = delete; + RGBAImageSet &operator=(RGBAImageSet &&) = delete; ~RGBAImageSet(); /// Remove all images. void Clear(); -- cgit v1.2.3