VclPtr some improvements ?

Michael Meeks michael.meeks at
Sat May 20 09:40:38 UTC 2017


	Julien had some good ideas for simplifying VclPtr usage; here is the
background - currently we have:

	VclPtr<Foo> pFoo;
		+ empty VclPtr pointer eg. shared_ptr<Foo> xFoo;

	VclPtrInstance<Foo> pFoo( pParent );
		+ creates a pFoo as above, and initializes it to an
		  instance; we can't expose 'new Foo()' publicly due
		  to the odd reference counting behavior. ::Create
		  is a little like make_shared
		+ sementically this is:
		  VclPtr<Foo> pFoo = VclPtr<Foo>::Create( pParent );

	* Suggestion - lets kill VclPtrInstance in a world with
	  'auto' its main use of saving a bit of typing is gone

		auto pFoo = VclPtr<Foo>::Create( pParent );

	ScopedVclPtr<Foo> pFoo;
		+ empty VclPtr that is disposed when it goes out of
		+ I guess something like unique_ptr - but with a
		  safe ref-count to the underlying object which can
	 	  survive (in a disposed state) for longer than the
		+ something of a confusing name

	* Suggestion: rename it to VclPtrAutoDispose - longer but
	  perhaps clearer (?) - or something else ?

	ScopedVclPtrInstance<Foo> pFoo( pParent );

	* Suggestion: as above - re-use auto and an:

		auto pFoo = VclPtrAutoDispose<Foo>::Create( pParent );

	Thoughts pro & con appreciated before doing the cleanup =) are there
better / more familiar name and approaches ?

	Hopefully using 'auto' would at least kill half of the template
complexity there =)



michael.meeks at <><, Pseudo Engineer, itinerant idiot

More information about the LibreOffice mailing list