On Tue, May 12, 2015 at 4:25 AM, Emil Dotchevski
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
included
examples shows how signals can be emitted by a Windows HWND object.
Documentation and source code released under the Boost license can be found 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