Bug 62525

Summary: Convert manual refcounting / copy-on-write implementations to cow_wrapper
Product: LibreOffice Reporter: Thorsten Behrens <thb>
Component: LibreofficeAssignee: Not Assigned <libreoffice-bugs>
Status: NEW --- QA Contact:
Severity: normal    
Priority: medium CC: libreoffice, thomas-libo
Version: unspecified   
Hardware: Other   
OS: All   
Whiteboard: EasyHack DifficultyInteresting SkillCpp TopicCleanup target:4.1.0
i915 platform: i915 features:

Description Thorsten Behrens 2013-03-19 14:30:54 UTC
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
Comment 1 Commit Notification 2013-03-23 20:08:37 UTC
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.
Comment 2 Commit Notification 2013-03-23 20:26:40 UTC
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.
Comment 3 Commit Notification 2013-03-23 21:01:18 UTC
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.
Comment 4 Commit Notification 2013-03-27 12:18:28 UTC
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.
Comment 5 Commit Notification 2013-03-27 12:25:15 UTC
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.
Comment 6 Commit Notification 2013-04-02 13:02:59 UTC
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.
Comment 7 Commit Notification 2013-04-02 13:03:17 UTC
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.
Comment 8 Commit Notification 2013-04-02 13:03:34 UTC
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.
Comment 9 Commit Notification 2013-04-03 09:38:38 UTC
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.
Comment 10 Commit Notification 2013-04-03 09:38:57 UTC
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.
Comment 11 Commit Notification 2013-04-03 09:39:16 UTC
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.
Comment 12 Commit Notification 2013-04-03 09:39:35 UTC
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.
Comment 13 Commit Notification 2013-04-03 09:39:53 UTC
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.
Comment 14 Commit Notification 2013-04-03 09:40:12 UTC
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.
Comment 15 Commit Notification 2013-04-03 09:40:30 UTC
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.
Comment 16 Commit Notification 2013-04-03 09:40:49 UTC
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.
Comment 17 Commit Notification 2013-04-03 09:41:08 UTC
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.
Comment 18 Commit Notification 2013-04-03 10:12:57 UTC
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.
Comment 19 Commit Notification 2013-04-03 10:19:49 UTC
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.
Comment 20 Thomas Arnhold 2013-08-11 08:04:18 UTC
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.
Comment 21 Björn Michaelsen 2013-10-04 18:46:39 UTC
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
Comment 22 Marcos Souza 2013-11-01 09:37:47 UTC
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 :)

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.