I ran into a segfault when I tried to create an std::vector of SharedData. There were two underlying causes for this:
When GlobalEvent is moved/copied, it doesn't update ev_handler_lifetime_ to point to the new instance of event_handler_. If the original GlobalEvent was later destroyed, the copy would segfault when it tried to fire its handler.
When SharedData is moved/copied, its ev_update_ receives a copy of the handler in the original SharedData. If the original was later destroyed, the copy would segfault when it tried to perform its state update.
This PR defines copy/move constructors and assignment operators for both classes so that everything gets updated properly and the copies can continue to function after the originals are destroyed.
I ran into a segfault when I tried to create an
std::vector
ofSharedData
. There were two underlying causes for this:GlobalEvent
is moved/copied, it doesn't updateev_handler_lifetime_
to point to the new instance ofevent_handler_
. If the originalGlobalEvent
was later destroyed, the copy would segfault when it tried to fire its handler.SharedData
is moved/copied, itsev_update_
receives a copy of the handler in the originalSharedData
. If the original was later destroyed, the copy would segfault when it tried to perform its state update.This PR defines copy/move constructors and assignment operators for both classes so that everything gets updated properly and the copies can continue to function after the originals are destroyed.