When using signals2 across multiple DDLs, everything works fine until the dlls gets unloaded, which results in crash the next time we dispatch the signal.
I found this stackoverflow post which describes the same issue i'm having.
The test sample:
Shared.cpp:
#include <boost/dll.hpp>
#include <boost/signals2.hpp>
#include <iostream>
struct SomeInterface
{
boost::signals2::signal<void()> signal;
};
boost::signals2::connection con;
void init(SomeInterface* iface)
{
con = iface->signal.connect([] { std::cout << "Hello, Shared!" << std::endl; });
}
void shutdown()
{
con.disconnect();
}
BOOST_DLL_AUTO_ALIAS(init);
BOOST_DLL_AUTO_ALIAS(shutdown);
Host.cpp:
#include <boost/dll.hpp>
#include <boost/signals2.hpp>
#include <iostream>
struct SomeInterface
{
boost::signals2::signal<void()> signal;
};
int main()
{
SomeInterface* iface = new SomeInterface;
{
boost::dll::shared_library dll("Shared", boost::dll::load_mode::append_decorations);
auto init = dll.get<void (*)(SomeInterface*)>("init");
auto shutdown = dll.get<void (*)()>("shutdown");
init(iface);
iface->signal();
shutdown();
}
iface->signal();
return 0;
}
When using signals2 across multiple DDLs, everything works fine until the dlls gets unloaded, which results in crash the next time we dispatch the signal.
I found this stackoverflow post which describes the same issue i'm having.
The test sample:
Shared.cpp:
Host.cpp: