Re: changing the UNO dispose/disposing() protocol ?

2023-05-31 Thread Miklos Vajna
Hi Noel,

On Tue, May 30, 2023 at 12:29:40PM +0200, Noel Grandin  
wrote:
> > Do you have a context for this? I assume you dived into some actual
> > problem and then this came up?
> >
> I am specifically looking at cleaning up memory leaks, and a lot of those
> have to do with cycles forming in the UNO object graph.
> A recurrent problem in cleaning this up is when something throws
> DisposedException and short-circuits the dispose() logic in caller code.

I see. And also noticed in the meantime that the VclPtr dispose also
just does nothing on multiple disposes, so this sounds reasonable to me,
improves consistency.

Regards,

Miklos


Re: changing the UNO dispose/disposing() protocol ?

2023-05-30 Thread Noel Grandin
On Tue, 30 May 2023 at 10:25, Stephan Bergmann  wrote:

> This does not encourage implementations of XComponent to throw
> DisposedException upon repeated calls to dispose, anyway.
>
>
Aha, that is good to know!
In that case I can fix the cases where it is unnecessarily throwing (one by
one of course).


Re: changing the UNO dispose/disposing() protocol ?

2023-05-30 Thread Noel Grandin
On Tue, 30 May 2023 at 08:40, Miklos Vajna  wrote:

> Did you try if make check enforces the current behavior?
>
No idea.


>
> Do you have a context for this? I assume you dived into some actual
> problem and then this came up?
>
>
I am specifically looking at cleaning up memory leaks, and a lot of those
have to do with cycles forming in the UNO object graph.
A recurrent problem in cleaning this up is when something throws
DisposedException and short-circuits the dispose() logic in caller code.


Re: changing the UNO dispose/disposing() protocol ?

2023-05-30 Thread Stephan Bergmann

On 5/28/23 16:02, Noel Grandin wrote:
Specifically, I would like to change the part where if a component is 
already disposed, it throws a DisposedException. Instead it should 
simply ignore the call (i.e. return early)


The documentation of css.lang.XComponent::dispose at 
udkapi/com/sun/star/lang/XComponent.idl states



After this method has been called, the object should behave as 
passive
as possible, thus it should ignore all calls
in case it can comply with its specification (for instance 
addEventListener()).
Often the object can't fulfill its specification anymore,
in this case it must throw the DisposedException
(which is derived from com::sun::star::uno::RuntimeException)
when it gets called.

For some objects no real owner can be identified, thus it can be
disposed from multiple reference holders. In this case
the object should be able to cope with multiple dispose()-calls (which
are inevitable in a multithreaded environment).


This does not encourage implementations of XComponent to throw 
DisposedException upon repeated calls to dispose, anyway.




Re: changing the UNO dispose/disposing() protocol ?

2023-05-30 Thread Miklos Vajna
Hi Noel,

On Sun, May 28, 2023 at 04:02:21PM +0200, Noel Grandin  
wrote:
> I would like to change the existing UNO dispose()/disposing() protocol.
> 
> Specifically, I would like to change the part where if a component is
> already disposed, it throws a DisposedException. Instead it should simply
> ignore the call (i.e. return early)

That's indeed how file close / DB close usually happens in other
projects, I think.

Did you try if make check enforces the current behavior?

Do you have a context for this? I assume you dived into some actual
problem and then this came up?

Thanks,

Miklos