Skip to content

Commit

Permalink
Merge pull request #85180 from AThousandShips/self_list_fix
Browse files Browse the repository at this point in the history
[Core] Prevent copying of `SelfList` and `SelfList::List`
  • Loading branch information
akien-mga committed Jan 8, 2024
2 parents b88535f + 904ecb1 commit 81f618d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 16 deletions.
6 changes: 6 additions & 0 deletions core/templates/self_list.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,9 @@ class SelfList {
_FORCE_INLINE_ SelfList<T> *first() { return _first; }
_FORCE_INLINE_ const SelfList<T> *first() const { return _first; }

// Forbid copying, which has broken behavior.
void operator=(const List &) = delete;

_FORCE_INLINE_ List() {}
_FORCE_INLINE_ ~List() {
// A self list must be empty on destruction.
Expand All @@ -185,6 +188,9 @@ class SelfList {
_FORCE_INLINE_ const SelfList<T> *prev() const { return _prev; }
_FORCE_INLINE_ T *self() const { return _self; }

// Forbid copying, which has broken behavior.
void operator=(const SelfList<T> &) = delete;

_FORCE_INLINE_ SelfList(T *p_self) {
_self = p_self;
}
Expand Down
16 changes: 0 additions & 16 deletions scene/2d/tile_map_layer.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,14 +173,6 @@ class DebugQuadrant : public RefCounted {

SelfList<DebugQuadrant> dirty_quadrant_list_element;

// For those, copy everything but SelfList elements.
DebugQuadrant(const DebugQuadrant &p_other) :
dirty_quadrant_list_element(this) {
quadrant_coords = p_other.quadrant_coords;
cells = p_other.cells;
canvas_item = p_other.canvas_item;
}

DebugQuadrant() :
dirty_quadrant_list_element(this) {
}
Expand Down Expand Up @@ -213,14 +205,6 @@ class RenderingQuadrant : public RefCounted {

SelfList<RenderingQuadrant> dirty_quadrant_list_element;

// For those, copy everything but SelfList elements.
RenderingQuadrant(const RenderingQuadrant &p_other) :
dirty_quadrant_list_element(this) {
quadrant_coords = p_other.quadrant_coords;
cells = p_other.cells;
canvas_items = p_other.canvas_items;
}

RenderingQuadrant() :
dirty_quadrant_list_element(this) {
}
Expand Down

0 comments on commit 81f618d

Please sign in to comment.