diff options
Diffstat (limited to 'indra')
| -rw-r--r-- | indra/llui/llui.cpp | 5 | ||||
| -rw-r--r-- | indra/newview/llappviewer.cpp | 66 | ||||
| -rw-r--r-- | indra/viewer_components/updater/llupdaterservice.cpp | 86 | ||||
| -rw-r--r-- | indra/viewer_components/updater/tests/llupdaterservice_test.cpp | 12 | 
4 files changed, 111 insertions, 58 deletions
| diff --git a/indra/llui/llui.cpp b/indra/llui/llui.cpp index ff9af21e54..19c42bf61a 100644 --- a/indra/llui/llui.cpp +++ b/indra/llui/llui.cpp @@ -1620,7 +1620,10 @@ void LLUI::initClass(const settings_map_t& settings,  void LLUI::cleanupClass()  { -	sImageProvider->cleanUp(); +	if(sImageProvider) +	{ +		sImageProvider->cleanUp(); +	}  }  void LLUI::setPopupFuncs(const add_popup_t& add_popup, const remove_popup_t& remove_popup,  const clear_popups_t& clear_popups) diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index 10c03954bc..c06f0c18e8 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -661,6 +661,14 @@ bool LLAppViewer::init()      initThreads();      writeSystemInfo(); +	// Initialize updater service (now that we have an io pump) +	initUpdater(); +	if(isQuitting()) +	{ +		// Early out here because updater set the quitting flag. +		return true; +	} +  	//////////////////////////////////////////////////////////////////////////////  	//////////////////////////////////////////////////////////////////////////////  	////////////////////////////////////////////////////////////////////////////// @@ -979,9 +987,6 @@ bool LLAppViewer::mainLoop()  	LLHTTPClient::setPump(*gServicePump);  	LLCurl::setCAFile(gDirUtilp->getCAFile()); -	// Initialize updater service (now that we have an io pump) -	initUpdater(); -	  	// Note: this is where gLocalSpeakerMgr and gActiveSpeakerMgr used to be instantiated.  	LLVoiceChannel::initClass(); @@ -1364,11 +1369,14 @@ bool LLAppViewer::cleanup()  	llinfos << "Cleaning Up" << llendflush;  	// Must clean up texture references before viewer window is destroyed. -	LLHUDManager::getInstance()->updateEffects(); -	LLHUDObject::updateAll(); -	LLHUDManager::getInstance()->cleanupEffects(); -	LLHUDObject::cleanupHUDObjects(); -	llinfos << "HUD Objects cleaned up" << llendflush; +	if(LLHUDManager::instanceExists()) +	{ +		LLHUDManager::getInstance()->updateEffects(); +		LLHUDObject::updateAll(); +		LLHUDManager::getInstance()->cleanupEffects(); +		LLHUDObject::cleanupHUDObjects(); +		llinfos << "HUD Objects cleaned up" << llendflush; +	}  	LLKeyframeDataCache::clear(); @@ -1380,8 +1388,10 @@ bool LLAppViewer::cleanup()  	// Note: this is where gWorldMap used to be deleted.  	// Note: this is where gHUDManager used to be deleted. -	LLHUDManager::getInstance()->shutdownClass(); -	 +	if(LLHUDManager::instanceExists()) +	{ +		LLHUDManager::getInstance()->shutdownClass(); +	}  	delete gAssetStorage;  	gAssetStorage = NULL; @@ -1683,7 +1693,10 @@ bool LLAppViewer::cleanup()  #ifndef LL_RELEASE_FOR_DOWNLOAD  	llinfos << "Auditing VFS" << llendl; -	gVFS->audit(); +	if(gVFS) +	{ +		gVFS->audit(); +	}  #endif  	llinfos << "Misc Cleanup" << llendflush; @@ -2383,8 +2396,13 @@ void LLAppViewer::initUpdater()  	std::string service_path = gSavedSettings.getString("UpdaterServicePath");  	U32 check_period = gSavedSettings.getU32("UpdaterServiceCheckPeriod"); -	mUpdater->initialize(protocol_version, url, service_path, channel, version); -	mUpdater->setCheckPeriod(check_period); +	mUpdater->setAppExitCallback(boost::bind(&LLAppViewer::forceQuit, this)); +	mUpdater->initialize(protocol_version,  +						 url,  +						 service_path,  +						 channel,  +						 version); + 	mUpdater->setCheckPeriod(check_period);  	if(gSavedSettings.getBOOL("UpdaterServiceActive"))  	{  		mUpdater->startChecking(); @@ -2550,15 +2568,18 @@ void LLAppViewer::cleanupSavedSettings()  	// save window position if not maximized  	// as we don't track it in callbacks -	BOOL maximized = gViewerWindow->mWindow->getMaximized(); -	if (!maximized) +	if(NULL != gViewerWindow)  	{ -		LLCoordScreen window_pos; - -		if (gViewerWindow->mWindow->getPosition(&window_pos)) +		BOOL maximized = gViewerWindow->mWindow->getMaximized(); +		if (!maximized)  		{ -			gSavedSettings.setS32("WindowX", window_pos.mX); -			gSavedSettings.setS32("WindowY", window_pos.mY); +			LLCoordScreen window_pos; + +			if (gViewerWindow->mWindow->getPosition(&window_pos)) +			{ +				gSavedSettings.setS32("WindowX", window_pos.mX); +				gSavedSettings.setS32("WindowY", window_pos.mY); +			}  		}  	} @@ -4297,7 +4318,10 @@ void LLAppViewer::disconnectViewer()  	// This is where we used to call gObjectList.destroy() and then delete gWorldp.  	// Now we just ask the LLWorld singleton to cleanly shut down. -	LLWorld::getInstance()->destroyClass(); +	if(LLWorld::instanceExists()) +	{ +		LLWorld::getInstance()->destroyClass(); +	}  	// call all self-registered classes  	LLDestroyClassList::instance().fireCallbacks(); diff --git a/indra/viewer_components/updater/llupdaterservice.cpp b/indra/viewer_components/updater/llupdaterservice.cpp index 28d9075efa..466b27f6fe 100644 --- a/indra/viewer_components/updater/llupdaterservice.cpp +++ b/indra/viewer_components/updater/llupdaterservice.cpp @@ -68,6 +68,7 @@ class LLUpdaterServiceImpl :  	unsigned int mCheckPeriod;  	bool mIsChecking; +	bool mIsDownloading;  	LLUpdateChecker mUpdateChecker;  	LLUpdateDownloader mUpdateDownloader; @@ -115,14 +116,14 @@ public:  	bool onMainLoop(LLSD const & event);	  private: -	void retry(void); - +	void restartTimer(unsigned int seconds);  };  const std::string LLUpdaterServiceImpl::sListenerName = "LLUpdaterServiceImpl";  LLUpdaterServiceImpl::LLUpdaterServiceImpl() :  	mIsChecking(false), +	mIsDownloading(false),  	mCheckPeriod(0),  	mUpdateChecker(*this),  	mUpdateDownloader(*this) @@ -141,10 +142,10 @@ void LLUpdaterServiceImpl::initialize(const std::string& protocol_version,  									  const std::string& channel,  									  const std::string& version)  { -	if(mIsChecking) +	if(mIsChecking || mIsDownloading)  	{ -		throw LLUpdaterService::UsageError("Call LLUpdaterService::stopCheck()" -			" before setting params."); +		throw LLUpdaterService::UsageError("LLUpdaterService::initialize call " +										   "while updater is running.");  	}  	mProtocolVersion = protocol_version; @@ -167,16 +168,20 @@ void LLUpdaterServiceImpl::setCheckPeriod(unsigned int seconds)  void LLUpdaterServiceImpl::startChecking()  { -	if(!mIsChecking) +	if(mUrl.empty() || mChannel.empty() || mVersion.empty())  	{ -		if(mUrl.empty() || mChannel.empty() || mVersion.empty()) -		{ -			throw LLUpdaterService::UsageError("Set params before call to " -				"LLUpdaterService::startCheck()."); -		} -		mIsChecking = true; -	 -		mUpdateChecker.check(mProtocolVersion, mUrl, mPath, mChannel, mVersion); +		throw LLUpdaterService::UsageError("Set params before call to " +			"LLUpdaterService::startCheck()."); +	} + +	mIsChecking = true; + +	if(!mIsDownloading) +	{ +		// Checking can only occur during the mainloop. +		// reset the timer to 0 so that the next mainloop event  +		// triggers a check; +		restartTimer(0);   	}  } @@ -185,6 +190,7 @@ void LLUpdaterServiceImpl::stopChecking()  	if(mIsChecking)  	{  		mIsChecking = false; +		mTimer.stop();  	}  } @@ -205,16 +211,21 @@ bool LLUpdaterServiceImpl::checkForInstall()  		// Found an update info - now lets see if its valid.  		LLSD update_info;  		LLSDSerialize::fromXMLDocument(update_info, update_marker); +		update_marker.close(); +		LLFile::remove(update_marker_path());  		// Get the path to the installer file.  		LLSD path = update_info.get("path");  		if(path.isDefined() && !path.asString().empty())  		{  			// install! + +			if(mAppExitCallback) +			{ +				mAppExitCallback(); +			}  		} -		update_marker.close(); -		LLFile::remove(update_marker_path());  		result = true;  	}  	return result; @@ -226,7 +237,7 @@ bool LLUpdaterServiceImpl::checkForResume()  	llstat stat_info;  	if(0 == LLFile::stat(mUpdateDownloader.downloadMarkerPath(), &stat_info))  	{ -		mIsChecking = true; +		mIsDownloading = true;  		mUpdateDownloader.resume();  		result = true;  	} @@ -235,13 +246,18 @@ bool LLUpdaterServiceImpl::checkForResume()  void LLUpdaterServiceImpl::error(std::string const & message)  { -	retry(); +	if(mIsChecking) +	{ +		restartTimer(mCheckPeriod); +	}  }  void LLUpdaterServiceImpl::optionalUpdate(std::string const & newVersion,  										  LLURI const & uri,  										  std::string const & hash)  { +	mTimer.stop(); +	mIsDownloading = true;  	mUpdateDownloader.download(uri, hash);  } @@ -249,50 +265,60 @@ void LLUpdaterServiceImpl::requiredUpdate(std::string const & newVersion,  										  LLURI const & uri,  										  std::string const & hash)  { +	mTimer.stop(); +	mIsDownloading = true;  	mUpdateDownloader.download(uri, hash);  }  void LLUpdaterServiceImpl::upToDate(void)  { -	retry(); +	if(mIsChecking) +	{ +		restartTimer(mCheckPeriod); +	}  }  void LLUpdaterServiceImpl::downloadComplete(LLSD const & data)   {  +	mIsDownloading = false; +  	// Save out the download data to the SecondLifeUpdateReady -	// marker file. +	// marker file.   	llofstream update_marker(update_marker_path());  	LLSDSerialize::toPrettyXML(data, update_marker); - -	// Stop checking. -	stopChecking(); - -	// Wait for restart...?  }  void LLUpdaterServiceImpl::downloadError(std::string const & message)   {  -	retry();  +	mIsDownloading = false; + +	// Restart the  +	if(mIsChecking) +	{ +		restartTimer(mCheckPeriod);  +	}  } -void LLUpdaterServiceImpl::retry(void) +void LLUpdaterServiceImpl::restartTimer(unsigned int seconds)  {  	LL_INFOS("UpdaterService") << "will check for update again in " <<   	mCheckPeriod << " seconds" << LL_ENDL;   	mTimer.start(); -	mTimer.setTimerExpirySec(mCheckPeriod); +	mTimer.setTimerExpirySec(seconds);  	LLEventPumps::instance().obtain("mainloop").listen(  		sListenerName, boost::bind(&LLUpdaterServiceImpl::onMainLoop, this, _1));  }  bool LLUpdaterServiceImpl::onMainLoop(LLSD const & event)  { -	if(mTimer.hasExpired()) +	if(mTimer.getStarted() && mTimer.hasExpired())  	{  		mTimer.stop();  		LLEventPumps::instance().obtain("mainloop").stopListening(sListenerName);  		mUpdateChecker.check(mProtocolVersion, mUrl, mPath, mChannel, mVersion); -	} else { +	}  +	else  +	{  		// Keep on waiting...  	} diff --git a/indra/viewer_components/updater/tests/llupdaterservice_test.cpp b/indra/viewer_components/updater/tests/llupdaterservice_test.cpp index 57732ad0a5..aa30fa717d 100644 --- a/indra/viewer_components/updater/tests/llupdaterservice_test.cpp +++ b/indra/viewer_components/updater/tests/llupdaterservice_test.cpp @@ -102,12 +102,12 @@ void LLUpdateDownloader::resume(void) {}  /*
  #pragma warning(disable: 4273)
 -llus_mock_llifstream::llus_mock_llifstream(const std::string& _Filename, -										   ios_base::openmode _Mode, -										   int _Prot) : -	std::basic_istream<char,std::char_traits< char > >(NULL,true) -{} - +llus_mock_llifstream::llus_mock_llifstream(const std::string& _Filename,
 +										   ios_base::openmode _Mode,
 +										   int _Prot) :
 +	std::basic_istream<char,std::char_traits< char > >(NULL,true)
 +{}
 +
  llus_mock_llifstream::~llus_mock_llifstream() {}
  bool llus_mock_llifstream::is_open() const {return true;}
  void llus_mock_llifstream::close() {}
 | 
