X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fserver_finder.cc;h=4b532f98129d4f70386040d9dfc182761973312f;hb=1858190cff2f960f3d1f0a5cc02c69da86088f5b;hp=315d8d79dadc00b5d8cb87363b8a2e59b3929c0d;hpb=b0297f77b23099a52d37becfa45930ee730bda4b;p=dcpomatic.git diff --git a/src/lib/server_finder.cc b/src/lib/server_finder.cc index 315d8d79d..4b532f981 100644 --- a/src/lib/server_finder.cc +++ b/src/lib/server_finder.cc @@ -27,6 +27,7 @@ #include "raw_convert.h" #include #include +#include #include "i18n.h" @@ -45,10 +46,15 @@ ServerFinder::ServerFinder () , _search_thread (0) , _listen_thread (0) , _stop (false) +{ + Config::instance()->Changed.connect (boost::bind (&ServerFinder::config_changed, this, _1)); +} + +void +ServerFinder::start () { _search_thread = new boost::thread (boost::bind (&ServerFinder::search_thread, this)); _listen_thread = new boost::thread (boost::bind (&ServerFinder::listen_thread, this)); - Config::instance()->Changed.connect (boost::bind (&ServerFinder::config_changed, this, _1)); } ServerFinder::~ServerFinder () @@ -56,10 +62,14 @@ ServerFinder::~ServerFinder () _stop = true; _search_condition.notify_all (); - _search_thread->join (); + if (_search_thread) { + _search_thread->join (); + } _listen_io_service.stop (); - _listen_thread->join (); + if (_listen_thread) { + _listen_thread->join (); + } } void @@ -194,6 +204,7 @@ ServerFinder::instance () { if (!_instance) { _instance = new ServerFinder (); + _instance->start (); } return _instance;