From a33c5930cbfe9b2a29359d906d6b869e983a782a Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Mon, 13 Mar 2017 14:19:50 -0400 Subject: DRTVWR-418: Use LLTempBoundListener to manage "mainloop" listener. LLUpdaterServiceImpl binds its onMainLoop() listener method to the "mainloop" event so it can wake up periodically to recheck for updates. (Suggests maybe a smarter conventional callback-on-timer facility with a central queue, instead of every interested party intercepting *every* frame...) ~LLUpdaterServiceImpl() was calling LLEventPumps::instance() only to disconnect that listener, which was resurrecting the deleted LLEventPumps instance. Instead store an LLTempBoundListener in LLUpdaterServiceImpl, the conventional way to implicitly disconnect on destroy. Use its disconnect() method when explicit disconnection is desired. --- indra/viewer_components/updater/llupdaterservice.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'indra') diff --git a/indra/viewer_components/updater/llupdaterservice.cpp b/indra/viewer_components/updater/llupdaterservice.cpp index 1665e41e70..df021948c3 100644 --- a/indra/viewer_components/updater/llupdaterservice.cpp +++ b/indra/viewer_components/updater/llupdaterservice.cpp @@ -158,7 +158,8 @@ public: private: std::string mNewChannel; std::string mNewVersion; - + LLTempBoundListener mMainLoopConnection; + void restartTimer(unsigned int seconds); void setState(LLUpdaterService::eUpdaterState state); void stopTimer(); @@ -179,7 +180,8 @@ LLUpdaterServiceImpl::LLUpdaterServiceImpl() : LLUpdaterServiceImpl::~LLUpdaterServiceImpl() { LL_INFOS("UpdaterService") << "shutting down updater service" << LL_ENDL; - LLEventPumps::instance().obtain("mainloop").stopListening(sListenerName); + // Destroying an LLTempBoundListener implicitly disconnects. That's its + // whole purpose. } void LLUpdaterServiceImpl::initialize(const std::string& channel, @@ -560,7 +562,7 @@ void LLUpdaterServiceImpl::restartTimer(unsigned int seconds) seconds << " seconds" << LL_ENDL; mTimer.start(); mTimer.setTimerExpirySec((F32)seconds); - LLEventPumps::instance().obtain("mainloop").listen( + mMainLoopConnection = LLEventPumps::instance().obtain("mainloop").listen( sListenerName, boost::bind(&LLUpdaterServiceImpl::onMainLoop, this, _1)); } @@ -589,7 +591,7 @@ void LLUpdaterServiceImpl::setState(LLUpdaterService::eUpdaterState state) void LLUpdaterServiceImpl::stopTimer() { mTimer.stop(); - LLEventPumps::instance().obtain("mainloop").stopListening(sListenerName); + mMainLoopConnection.disconnect(); } bool LLUpdaterServiceImpl::onMainLoop(LLSD const & event) -- cgit v1.2.3