This is a medium-level EasyHack, and can be split up nicely into converting individual classes one after another. If you work on one class, or one set of classes inside a subsystem, please add a line to this bug stating so. What is this about ================== The LibreOffice codebase, at a number of occasions, employs the CopyOnWrite pattern to make passing big objects around by-value acceptably cheap, see this article for some more background: http://en.wikibooks.org/wiki/More_C%2B%2B_Idioms/Copy-on-write Currently we have quite a number of ad-hoc implementations of that pattern, with a number of known problems (getting it wrong in corner cases, different refcount semantics (is zero refcount good for deletion? does it mean one client left?), and a (hopefully generic) helper template for easy conversion of already-pimpled classes: http://cgit.freedesktop.org/libreoffice/core/tree/o3tl/inc/o3tl/cow_wrapper.hxx The task at hand is to convert as many of those sprawling ad-hoc implementations over to cow_wrapper What this is not about ====================== This is not about whether COW is a useful pattern in the first place - we want to consolidate the code here to avoid nasty corner cases. If you want to go for a tangential read on that, this one is nice: http://www.gotw.ca/gotw/045.htm Also note that cow_wrapper defaults to non-threadsafe mode (mimicking std behaviour in LibO code, the application being inherently single-threaded anyway). Details ======= If you want to find a victim, go grep the source tree for .hxx files containing nRefCount (there are variations in that name, but the aforementioned one should already give enough hits for the while). If the code looks like implementing pimpl idiom (http://www.gotw.ca/gotw/024.htm) and Copy-on-write semantics, try wedging it into using cow_wrapper instead. Example conversion from back in the day: http://cgit.freedesktop.org/libreoffice/core/commit/?id=b6368dd527fd7ebe307cebe5c2275983df9ee851 and http://cgit.freedesktop.org/libreoffice/core/commit/?id=776b7235e23735189dbeafa6de93a4a2eaa2bf30
Thomas Arnhold committed a patch related to this issue. It has been pushed to "master": http://cgit.freedesktop.org/libreoffice/core/commit/?id=62fca307fc0fc775234572c79a1237494c2d72a7 fdo#62525: use cow_wrapper for SdrShadowAttribute The patch should be included in the daily builds available at http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More information about daily builds can be found at: http://wiki.documentfoundation.org/Testing_Daily_Builds Affected users are encouraged to test the fix and report feedback.
Thomas Arnhold committed a patch related to this issue. It has been pushed to "master": http://cgit.freedesktop.org/libreoffice/core/commit/?id=cafc879f8978ea9f7fca1be9f6aa5057f0a59617 fdo#62525: use cow_wrapper for FillBitmapAttribute The patch should be included in the daily builds available at http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More information about daily builds can be found at: http://wiki.documentfoundation.org/Testing_Daily_Builds Affected users are encouraged to test the fix and report feedback.
Thomas Arnhold committed a patch related to this issue. It has been pushed to "master": http://cgit.freedesktop.org/libreoffice/core/commit/?id=75ad992d1801334a2bb39e1b0bdf3ca5f3714625 fdo#62525: use cow_wrapper for FillGradientAttribute The patch should be included in the daily builds available at http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More information about daily builds can be found at: http://wiki.documentfoundation.org/Testing_Daily_Builds Affected users are encouraged to test the fix and report feedback.
Thomas Arnhold committed a patch related to this issue. It has been pushed to "master": http://cgit.freedesktop.org/libreoffice/core/commit/?id=63da9d632827e7d08450dfd72bdcdfbed9c73cae fdo#62525: use cow_wrapper for FillHatchAttribute The patch should be included in the daily builds available at http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More information about daily builds can be found at: http://wiki.documentfoundation.org/Testing_Daily_Builds Affected users are encouraged to test the fix and report feedback.
Thomas Arnhold committed a patch related to this issue. It has been pushed to "master": http://cgit.freedesktop.org/libreoffice/core/commit/?id=32ec7666596b2a0f27c72f9d856e2ec0f0545f6b fdo#62525: use cow_wrapper for FontAttribute The patch should be included in the daily builds available at http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More information about daily builds can be found at: http://wiki.documentfoundation.org/Testing_Daily_Builds Affected users are encouraged to test the fix and report feedback.
Thomas Arnhold committed a patch related to this issue. It has been pushed to "master": http://cgit.freedesktop.org/libreoffice/core/commit/?id=44e7cb139d921d6c003d4367a8064bc653342541 fdo#62525: use cow_wrapper for LineAttribute The patch should be included in the daily builds available at http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More information about daily builds can be found at: http://wiki.documentfoundation.org/Testing_Daily_Builds Affected users are encouraged to test the fix and report feedback.
Thomas Arnhold committed a patch related to this issue. It has been pushed to "master": http://cgit.freedesktop.org/libreoffice/core/commit/?id=4e188ae252322485c54b4c3a6c081bde2f966a9f fdo#62525: use cow_wrapper for LineStartEndAttribute The patch should be included in the daily builds available at http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More information about daily builds can be found at: http://wiki.documentfoundation.org/Testing_Daily_Builds Affected users are encouraged to test the fix and report feedback.
Thomas Arnhold committed a patch related to this issue. It has been pushed to "master": http://cgit.freedesktop.org/libreoffice/core/commit/?id=c42bdb023725016af22d7cee8cf81c8975234d94 fdo#62525: use cow_wrapper for MaterialAttribute3D The patch should be included in the daily builds available at http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More information about daily builds can be found at: http://wiki.documentfoundation.org/Testing_Daily_Builds Affected users are encouraged to test the fix and report feedback.
Thomas Arnhold committed a patch related to this issue. It has been pushed to "master": http://cgit.freedesktop.org/libreoffice/core/commit/?id=f98bee58fbf1e4862477fb6aa014447746f1ef9d fdo#62525: use cow_wrapper for SdrFillAttribute The patch should be included in the daily builds available at http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More information about daily builds can be found at: http://wiki.documentfoundation.org/Testing_Daily_Builds Affected users are encouraged to test the fix and report feedback.
Thomas Arnhold committed a patch related to this issue. It has been pushed to "master": http://cgit.freedesktop.org/libreoffice/core/commit/?id=f5cf7f36f90f454fd40c5894fbdf5ae070b6b59e fdo#62525: use cow_wrapper for SdrFillBitmapAttribute The patch should be included in the daily builds available at http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More information about daily builds can be found at: http://wiki.documentfoundation.org/Testing_Daily_Builds Affected users are encouraged to test the fix and report feedback.
Thomas Arnhold committed a patch related to this issue. It has been pushed to "master": http://cgit.freedesktop.org/libreoffice/core/commit/?id=f61b5c3654fc011ab0c6e042f6df010e39536d85 fdo#62525: use cow_wrapper for Sdr3DLightAttribute The patch should be included in the daily builds available at http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More information about daily builds can be found at: http://wiki.documentfoundation.org/Testing_Daily_Builds Affected users are encouraged to test the fix and report feedback.
Thomas Arnhold committed a patch related to this issue. It has been pushed to "master": http://cgit.freedesktop.org/libreoffice/core/commit/?id=4f989f306898db0b9732301b03e2b4d02159869d fdo#62525: use cow_wrapper for SdrLightingAttribute The patch should be included in the daily builds available at http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More information about daily builds can be found at: http://wiki.documentfoundation.org/Testing_Daily_Builds Affected users are encouraged to test the fix and report feedback.
Thomas Arnhold committed a patch related to this issue. It has been pushed to "master": http://cgit.freedesktop.org/libreoffice/core/commit/?id=8ee042bdb5502228fecf9a05da491bbb2cb3efc5 fdo#62525: use cow_wrapper for SdrLineAttribute The patch should be included in the daily builds available at http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More information about daily builds can be found at: http://wiki.documentfoundation.org/Testing_Daily_Builds Affected users are encouraged to test the fix and report feedback.
Thomas Arnhold committed a patch related to this issue. It has been pushed to "master": http://cgit.freedesktop.org/libreoffice/core/commit/?id=92261a33c8ebd2d1c4d35b1b526e98abe746955e fdo#62525: use cow_wrapper for StrokeAttribute The patch should be included in the daily builds available at http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More information about daily builds can be found at: http://wiki.documentfoundation.org/Testing_Daily_Builds Affected users are encouraged to test the fix and report feedback.
Thomas Arnhold committed a patch related to this issue. It has been pushed to "master": http://cgit.freedesktop.org/libreoffice/core/commit/?id=12012150d2027f78e872dc15b063b12a60d3a7d9 fdo#62525: use cow_wrapper for SdrLineStartEndAttribute The patch should be included in the daily builds available at http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More information about daily builds can be found at: http://wiki.documentfoundation.org/Testing_Daily_Builds Affected users are encouraged to test the fix and report feedback.
Thomas Arnhold committed a patch related to this issue. It has been pushed to "master": http://cgit.freedesktop.org/libreoffice/core/commit/?id=d3dff92c74bdf0fdb8b638d85fd5a41a64bd96c9 fdo#62525: use cow_wrapper for SdrSceneAttribute The patch should be included in the daily builds available at http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More information about daily builds can be found at: http://wiki.documentfoundation.org/Testing_Daily_Builds Affected users are encouraged to test the fix and report feedback.
Thomas Arnhold committed a patch related to this issue. It has been pushed to "master": http://cgit.freedesktop.org/libreoffice/core/commit/?id=7470c93a7b70eec967a52ddbf8a3c9430d3b6f2f fdo#62525: use cow_wrapper for Sdr3DObjectAttribute The patch should be included in the daily builds available at http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More information about daily builds can be found at: http://wiki.documentfoundation.org/Testing_Daily_Builds Affected users are encouraged to test the fix and report feedback.
Thomas Arnhold committed a patch related to this issue. It has been pushed to "master": http://cgit.freedesktop.org/libreoffice/core/commit/?id=0c85109e647ab1d1d8d87891b3bba23d90cd7e65 fdo#62525: use cow_wrapper for ViewInformation2D The patch should be included in the daily builds available at http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More information about daily builds can be found at: http://wiki.documentfoundation.org/Testing_Daily_Builds Affected users are encouraged to test the fix and report feedback.
Thomas Arnhold committed a patch related to this issue. It has been pushed to "master": http://cgit.freedesktop.org/libreoffice/core/commit/?id=78bec2b6f40144277464a64a9851d1dc940ed336 fdo#62525: use cow_wrapper for ViewInformation3D The patch should be included in the daily builds available at http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More information about daily builds can be found at: http://wiki.documentfoundation.org/Testing_Daily_Builds Affected users are encouraged to test the fix and report feedback.
I'm retiring on this, because I don't have time for libo in the near feature. Thorsten suggested me to have a look at the Bitmap classes as a next step, because there is a high advantage of using cow wrapper. But it can be any other, too. One more todo on this: There is some nice documentation in cow_wrapper.hxx, which doesn't get it into the doxygen version: http://cgit.freedesktop.org/libreoffice/core/tree/include/o3tl/cow_wrapper.hxx http://docs.libreoffice.org/o3tl/html/cow__wrapper_8hxx.html The whole 'Copy-on-write wrapper.' with the included code example are missing.
adding LibreOffice developer list as CC to unresolved EasyHacks for better visibility. see e.g. http://nabble.documentfoundation.org/minutes-of-ESC-call-td4076214.html for details
It seems that unotools/source/config/pathoptions.cxx in line 175 we have an manual refcounting, but this is globally inside that file... I little strange BTW :)
Thorsten Behrens committed a patch related to this issue. It has been pushed to "master": http://cgit.freedesktop.org/libreoffice/core/commit/?id=6a42657fa9afc93c3e4b7afc0c00c0de8e704169 tdf#62525: use cow_wrapper for SdrFormTextAttribute It will be available in 5.0.0. The patch should be included in the daily builds available at http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More information about daily builds can be found at: http://wiki.documentfoundation.org/Testing_Daily_Builds Affected users are encouraged to test the fix and report feedback.
Thorsten Behrens committed a patch related to this issue. It has been pushed to "master": http://cgit.freedesktop.org/libreoffice/core/commit/?id=27e1a92d3bddf3c3e8595256e67aff006a402b6a tdf#62525: use cow_wrapper for SdrFormTextOutlineAttribute It will be available in 5.0.0. The patch should be included in the daily builds available at http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More information about daily builds can be found at: http://wiki.documentfoundation.org/Testing_Daily_Builds Affected users are encouraged to test the fix and report feedback.
Thorsten Behrens committed a patch related to this issue. It has been pushed to "master": http://cgit.freedesktop.org/libreoffice/core/commit/?id=e9bb2e6f09d711833e659db3b229326d5e997266 tdf#62525: use cow_wrapper for SdrTextAttribute It will be available in 5.0.0. The patch should be included in the daily builds available at http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More information about daily builds can be found at: http://wiki.documentfoundation.org/Testing_Daily_Builds Affected users are encouraged to test the fix and report feedback.
Daniel Robertson committed a patch related to this issue. It has been pushed to "master": http://cgit.freedesktop.org/libreoffice/core/commit/?id=c1a9d0139112d7489ca6dd29b18f9418c6da3085 tdf#62525: use cow_wrapper for SvGlobalName It will be available in 5.1.0. The patch should be included in the daily builds available at http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More information about daily builds can be found at: http://wiki.documentfoundation.org/Testing_Daily_Builds Affected users are encouraged to test the fix and report feedback.
Daniel Robertson committed a patch related to this issue. It has been pushed to "master": http://cgit.freedesktop.org/libreoffice/core/commit/?id=49cb81b411e1c68cada5d3f4375de713118fce64 tdf#62525 vcl: use cow_wrapper for Gradient It will be available in 5.1.0. The patch should be included in the daily builds available at http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More information about daily builds can be found at: http://wiki.documentfoundation.org/Testing_Daily_Builds Affected users are encouraged to test the fix and report feedback.
Daniel Robertson committed a patch related to this issue. It has been pushed to "master": http://cgit.freedesktop.org/libreoffice/core/commit/?id=e9e5fee720eb72fe789651861f48982d3d87674d tdf#62525 editeng: OutlinerParaObject It will be available in 5.1.0. The patch should be included in the daily builds available at http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More information about daily builds can be found at: http://wiki.documentfoundation.org/Testing_Daily_Builds Affected users are encouraged to test the fix and report feedback.
Migrating Whiteboard tags to Keywords: (EasyHack DifficultyInteresting SkillCpp TopicCleanup) [NinjaEdit]
JanI is default CC for Easy Hacks (Add Jan; remove LibreOffice Dev List from CC) [NinjaEdit]
More classes can be found with http://opengrok.libreoffice.org/search?q=nRefCount&project=core&defs=&refs=&path=&hist=
Xisco Fauli committed a patch related to this issue. It has been pushed to "master": http://cgit.freedesktop.org/libreoffice/core/commit/?id=188439aac2e2e85821b4a114c1298bdf36a7b2ea tdf#62525 vcl: use cow_wrapper for font It will be available in 5.2.0. The patch should be included in the daily builds available at http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More information about daily builds can be found at: http://wiki.documentfoundation.org/Testing_Daily_Builds Affected users are encouraged to test the fix and report feedback.
Xisco Fauli committed a patch related to this issue. It has been pushed to "master": http://cgit.freedesktop.org/libreoffice/core/commit/?id=80590c1162bd7b1e3230785168dc87e0ce069f8a tdf#62525 vcl: use cow_wrapper for Hatch It will be available in 5.2.0. The patch should be included in the daily builds available at http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More information about daily builds can be found at: http://wiki.documentfoundation.org/Testing_Daily_Builds Affected users are encouraged to test the fix and report feedback.
Xisco Fauli committed a patch related to this issue. It has been pushed to "master": http://cgit.freedesktop.org/libreoffice/core/commit/?id=bc43165a473c774f6b9c762c465efe2273b4483a tdf#62525 vcl: use cow_wrapper for lineinfo It will be available in 5.2.0. The patch should be included in the daily builds available at http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More information about daily builds can be found at: http://wiki.documentfoundation.org/Testing_Daily_Builds Affected users are encouraged to test the fix and report feedback.
Xisco Fauli committed a patch related to this issue. It has been pushed to "master": http://cgit.freedesktop.org/libreoffice/core/commit/?id=23dfb9e14571d96f9bd23d178f397ee35c36f686 tdf#62525 vcl: use cow_wrapper for mapmod It will be available in 5.2.0. The patch should be included in the daily builds available at http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More information about daily builds can be found at: http://wiki.documentfoundation.org/Testing_Daily_Builds Affected users are encouraged to test the fix and report feedback.
Xisco Fauli committed a patch related to this issue. It has been pushed to "master": http://cgit.freedesktop.org/libreoffice/core/commit/?id=b6f3b2b0ab9404917b7805bb89701c110b468768 tdf#62525 vcl: use cow_wrapper for wall It will be available in 5.2.0. The patch should be included in the daily builds available at http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More information about daily builds can be found at: http://wiki.documentfoundation.org/Testing_Daily_Builds Affected users are encouraged to test the fix and report feedback.
A polite ping still working on this issue ? Could be resolved when looking at the many commits, in that case please update status.
Xisco Fauli committed a patch related to this issue. It has been pushed to "master": http://cgit.freedesktop.org/libreoffice/core/commit/?id=0325b22a2a2b537a71f53b7c5d3e6c13fef68911 tdf#62525 vcl: use cow_wrapper for jobset It will be available in 5.3.0. The patch should be included in the daily builds available at http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More information about daily builds can be found at: http://wiki.documentfoundation.org/Testing_Daily_Builds Affected users are encouraged to test the fix and report feedback.
Xisco Fauli committed a patch related to this issue. It has been pushed to "master": http://cgit.freedesktop.org/libreoffice/core/commit/?id=7346a0cbea43f49578c5209da1416aa0b27fbddb tdf#62525 vcl: use cow_wrapper for ImpXPolygon It will be available in 5.3.0. The patch should be included in the daily builds available at http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More information about daily builds can be found at: http://wiki.documentfoundation.org/Testing_Daily_Builds Affected users are encouraged to test the fix and report feedback.
Xisco Fauli committed a patch related to this issue. It has been pushed to "master": http://cgit.freedesktop.org/libreoffice/core/commit/?id=09f88760acddc96cb38febd36fd987eefaa04bc0 tdf#62525 vcl: use cow_wrapper for ImpXPolyPolygon It will be available in 5.3.0. The patch should be included in the daily builds available at http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More information about daily builds can be found at: http://wiki.documentfoundation.org/Testing_Daily_Builds Affected users are encouraged to test the fix and report feedback.
Xisco Fauli committed a patch related to this issue. It has been pushed to "master": http://cgit.freedesktop.org/libreoffice/core/commit/?id=e6d2827fc385353f07d1703714f715718576c130 tdf#62525 vcl: use cow_wrapper for PPTCharPropSet It will be available in 5.3.0. The patch should be included in the daily builds available at http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More information about daily builds can be found at: http://wiki.documentfoundation.org/Testing_Daily_Builds Affected users are encouraged to test the fix and report feedback.
To find further examples, something like the following is useful: $ git grep -in 'sal.*refcount' -- *.hxx
Andreas Brandner committed a patch related to this issue. It has been pushed to "master": http://cgit.freedesktop.org/libreoffice/core/commit/?id=225115af05cba9a603130914b49c5b28ed451108 tdf#62525 tools: use cow_wrapper class for Polygon It will be available in 6.1.0. The patch should be included in the daily builds available at http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More information about daily builds can be found at: http://wiki.documentfoundation.org/Testing_Daily_Builds Affected users are encouraged to test the fix and report feedback.