Re: [sigc] Unexpected behavior when freeing a trackable object from inside a slot
- From: Kjell Ahlstedt <kjellahlstedt gmail com>
- To: "Andrey H." <ahanins gmail com>
- Cc: libsigc-list gnome org
- Subject: Re: [sigc] Unexpected behavior when freeing a trackable object from inside a slot
- Date: Thu, 29 Aug 2019 16:47:03 +0200
Den 2019-08-14 kl. 17:09, skrev Andrey H. via libsigc-list:
Hi,
I noticed that if a trackable object is freed from inside the slot
which is setup to track this object then the slot is immediately
invalidated. Problem arises when such a slot holds a lambda which
captures some other variables by-value or some variables are bound by
value to the slot. In such cases the invalidation of the slot causes
all bound object instances to be immediately freed.
I have attached a test case patch (for the current master) which
demonstrates the issue using lambda captures and sigc::bind bounds.
My question: is it a bug or it's supposed to work like that?
The patch also contains a 3rd test which disconnects the slot
explicitly from inside the lambda slot with captured variables, but in
this case it doesn't cause captured variables to be freed right from
inside the slot. So I'm inclined to think that track_obj should behave
in a similar safe way.
BR, Andrey
A bug or not a bug? It's not ideal, of course. But I think it would be
difficult to make sigc::track_obj() postpone invalidation the way
slot::disconnect() does. It postpones some actions until the slot call
has finished. Disconnecting the slot is less rude than deleting part of
it while it's executing.
You can file an issue to GitHub if you like, but I think this is
something you have to accept. Unless you can create a clever fix yourself.
Kjell
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]