Subject: Re: [boost] Interest in non-intrusive signal/slot lib?
From: Dominique Devienne (ddevienne_at_[hidden])
Date: 2015-05-12 04:34:49
On Tue, May 12, 2015 at 4:25 AM, Emil Dotchevski <emildotchevski_at_[hidden]>
> The result is a small, non-intrusive signals/slots library that allows
> objects of any type to be used as signal emitters, e.g. one of the
> examples shows how signals can be emitted by a Windows HWND object.
> Documentation and source code released under the Boost license can be
> here: http://www.revergestudios.com/boost-synapse/.
Interesting. Thanks for sharing.
One thing that surprised me in the example is that you store the
QPushButton in a shared_ptr, which from shared_ptr point-of-view has sole
ownership, while also setting the QDialog as the parent of that button.
http://doc.qt.io/qt-4.8/qwidget.html#QWidget states "The new widget is
deleted when its parent is deleted". The shared_ptr goes out of scope
before the QDialog, so obviously Qt has a way to avoid the double-delete (I
suspect via its internal/intrusive tracking of children), but the other way
around (longer lifetime for the shared_ptr) would crash, no? And the
shared_ptr seems to be required by the API?
Also the fact that you must static_cast from a void* to get back the
QPushButton is a little disturbing, when the single type itself never
"said" in its signature the emitter has to be a QPushButton. Wouldn't such
casting also be fraught with dangers in case of multiple or virtual
inheritance? Thanks, --DD
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk