On 10/14/25 20:18, jijinbei wrote:
If we could gradually replace some of these with well-maintained external ones, we could reduce maintenance cost and modernize the codebase.

For example:

  * our own smart pointer implementations,

        Hmm; the VclPtr<> stuff started off as a migration to std::shared_ptr - 
but ... IIRC this was stymied at the last minute with the results we see today. The 
existing code (and there is a lot of it) - has the habit of doing a lot of 
referencing during initialization which creates significant aggravation here.

        Find, debug and clean all that up, and we can switch to shared_ptr - 
although we will prolly want to keep dispose() still. Quite probably that is 
do-able by turning all constructor content into some 'initialize()' method with 
the same parameters as a first step, and then making all constructors take no 
state. Big mechanical change there - hopefully reasonably low risk; and can be 
done incrementally - just make sure all OutputDevice derived constructors chain 
immediately to an initialize() method with those parameters if they do not 
already - then when done - make the cut-over.

        
https://git.libreoffice.org/core/+/refs/heads/master/vcl/README.lifecycle.md

        Has details - see "One extra gotcha - an initial reference-count of 1" 
which is the nub of the issue.

        Ultimately the switch to having a hard & reliable lifecycle mechanism 
to replace the nightmare of implicit ownership semantics, combined with some 
horrible mix of shared_ptrs in some places made LibreOffice -much- easier to reason 
about, debug, and ultimately made things like Collabora Online possible (I still 
have too many scars from debugging the old approach =)

        It was a nightmare change - that was extremely hard to keep working vs. 
the cutting edge of the code since pre the new UI re-work from Caolan it was 
everywhere. Thanks so much to Noel, Bubli and others IIRC for helping me out 
getting it in, and cleaning up some of the follow-on problems.

        HTH,

                Michael.

--
Michael Meeks <>< CEO Collabora Productivity,
St Johns Innovation Centre, Cowley Road, Cambridge CB4 0DS, UK
Registered in England & Wales no 08644931, (M) +44 7795 666 147

Reply via email to