Closed Bug 539694 Opened 16 years ago Closed 14 years ago

accessible objects should have private copy constructor

Categories

(Core :: Disability Access APIs, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla11

People

(Reporter: surkov, Assigned: jhk)

References

(Blocks 1 open bug)

Details

(Keywords: access, Whiteboard: [good first bug][mentor=surkov.alexander@gmail.com][lang=c++])

Attachments

(2 files, 2 obsolete files)

Accessible objects should define copy constructor and assignment operators in private section to avoid accident calls (internal or on AT side). It was inspired by talk with Pete.
Whiteboard: [good first bug][mentor=surkov.alexander@gmail.com][lang=c++]
it appears you only need to check nsAccessNode and not any of the things that inherit from it because having a private copy constructor / operator = means things inheriting from you can't copy you. Here's a test with gcc 4.6 tbsaunde@football:/tmp$ cat test.cpp class foo { public: foo() { } private: foo& operator =(const foo& aValue); foo(const foo&); }; class dir : public foo { public: dir() : foo() { } int mType; }; int main() { dir bar; dir baz = bar; return baz.mType; } tbsaunde@football:/tmp$ g++ test.cpp test.cpp: In copy constructor ‘dir::dir(const dir&)’: test.cpp:7:3: error: ‘foo::foo(const foo&)’ is private test.cpp:10:7: error: within this context test.cpp: In function ‘int main()’: test.cpp:20:13: note: synthesized method ‘dir::dir(const dir&)’ first required here tbsaunde@football:/tmp$ sorry about the weird characters in the error message, it would appear something between bugzilla and my terminal dislikes utf8 :/
Attached patch Introduced copy constructor (obsolete) — Splinter Review
patch_1
Attachment #581202 - Flags: review?(trev.saunders)
Attached patch Patch_2 (obsolete) — Splinter Review
.
Attachment #581202 - Attachment is obsolete: true
Attachment #581205 - Flags: review?(trev.saunders)
Attachment #581202 - Flags: review?(trev.saunders)
Comment on attachment 581205 [details] [diff] [review] Patch_2 r=tbsaunde not surkov
Attachment #581205 - Flags: review?(trev.saunders) → review+
r = tbsaunde
Attachment #581211 - Flags: review?(trev.saunders)
Comment on attachment 581211 [details] [diff] [review] Introduced copy constructor review not needed since same patch.
Attachment #581211 - Flags: review?(trev.saunders)
Just to note, there's a new macro you should use to do this, MOZ_DELETE: http://hg.mozilla.org/mozilla-central/annotate/3c321d2c9884/mfbt/Attributes.h#l106 It's just a matter of #include "mozilla/Attributes.h", then putting MOZ_DELETE at the ends of declarations like the ones in comment 9's URL. This has the advantage of producing errors at compile time, not (potentially) at link time (if the code making the accidental copy is a friend of the class being copied).
Assignee: nobody → jigneshhk1992
Status: NEW → ASSIGNED
Target Milestone: --- → mozilla11
Jignesh, could you address comment #10 please?
Attachment #581205 - Attachment is obsolete: true
Attachment #595446 - Flags: review?(surkov.alexander)
Comment on attachment 595446 [details] [diff] [review] Thanks for Pointing out. Review of attachment 595446 [details] [diff] [review]: ----------------------------------------------------------------- r=me, thank you for doing this
Attachment #595446 - Flags: review?(surkov.alexander) → review+
Status: ASSIGNED → RESOLVED
Closed: 14 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: