Closed Bug 1152951 Opened 9 years ago Closed 9 years ago

Explicitly delete copy-constructor & reassignment operator on flexbox stack-allocated helper-structs

Categories

(Core :: Layout, defect)

defect
Not set
trivial

Tracking

()

RESOLVED FIXED
mozilla40
Tracking Status
firefox40 --- fixed

People

(Reporter: dholbert, Assigned: dholbert)

References

Details

Attachments

(1 file)

Flexbox code instantiates some helper-objects on the stack to manage state, and passes around references to them.

These objects should never be copied.  Any copying would almost certainly be a bug (because state updates on the copy would be lost & not make it back to the original).

So, we should delete the automatically-generated copy-constructor on these objects, to catch any such accidental-copying bugs at compile time.  (And the reassignment operator, for good measure.)
Attached patch fix v1Splinter Review
Here's the (trivial) fix.

A few notes:
 (1) PositionTracker previously had a halfhearted attempt to prevent copying, by making its copy constructor private.  The "= delete" version that I'm replacing it with is strictly better.
 (2) The PositionTracker subclasses don't need this treatment -- they get these functions implicitly-deleted, via deriving from PositionTracker. (The child class's default copy-constructor / reassignment operator makes use of to the parent class's function; so given that the parent class has its functions deleted, the child class does too.) I verified this locally by trying to copy/reassign instances of these child classes, and I got a compile error. (good)
 (3) The "=delete" syntax is supported by on all our supported compilers, as of bug 1118486. (and this is documented at https://developer.mozilla.org/en-US/docs/Using_CXX_in_Mozilla_code as well)
Attachment #8590478 - Flags: review?(mats)
Blocks: 1152913
Comment on attachment 8590478 [details] [diff] [review]
fix v1

r=mats
Attachment #8590478 - Flags: review?(mats) → review+
https://hg.mozilla.org/mozilla-central/rev/f3466cb572cb
Status: NEW → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla40
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: