Commits

Anonymous committed 926f7e0

CHOP-135 Bug fixes.

Comments (0)

Files changed (7)

indra/llcommon/llfile.cpp

 	if(is_open())
 	{
 		if (_Filebuffer->close() == 0)
+		{
 			_Myios::setstate(ios_base::failbit);	/*Flawfinder: ignore*/
+		}
+		delete _Filebuffer;
+		_Filebuffer = NULL;
+		_ShouldClose = false;
 	}
 }
 

indra/newview/llappviewer.cpp

  	mUpdater->setCheckPeriod(check_period);
 	if(gSavedSettings.getBOOL("UpdaterServiceActive"))
 	{
-		mUpdater->startChecking();
+		bool install_if_ready = true;
+		mUpdater->startChecking(install_if_ready);
 	}
 
     LLEventPump & updater_pump = LLEventPumps::instance().obtain(LLUpdaterService::pumpName());

indra/newview/llchiclet.cpp

 
 LLChicletPanel::~LLChicletPanel()
 {
-	LLTransientFloaterMgr::getInstance()->removeControlView(mLeftScrollButton);
-	LLTransientFloaterMgr::getInstance()->removeControlView(mRightScrollButton);
-
+	if(LLTransientFloaterMgr::instanceExists())
+	{
+		LLTransientFloaterMgr::getInstance()->removeControlView(mLeftScrollButton);
+		LLTransientFloaterMgr::getInstance()->removeControlView(mRightScrollButton);
+	}
 }
 
 void im_chiclet_callback(LLChicletPanel* panel, const LLSD& data){

indra/newview/lltransientfloatermgr.cpp

 
 LLTransientFloaterMgr::LLTransientFloaterMgr()
 {
-	gViewerWindow->getRootView()->addMouseDownCallback(boost::bind(
+	if(gViewerWindow)
+	{
+		gViewerWindow->getRootView()->addMouseDownCallback(boost::bind(
 			&LLTransientFloaterMgr::leftMouseClickCallback, this, _1, _2, _3));
+	}
 
 	mGroupControls.insert(std::pair<ETransientGroup, std::set<LLView*> >(GLOBAL, std::set<LLView*>()));
 	mGroupControls.insert(std::pair<ETransientGroup, std::set<LLView*> >(DOCKED, std::set<LLView*>()));

indra/viewer_components/updater/llupdatedownloader.cpp

 
 void LLUpdateDownloader::Implementation::resume(void)
 {
-	if(isDownloading()) mClient.downloadError("download in progress");
+	mCancelled = false;
+
+	if(isDownloading()) {
+		mClient.downloadError("download in progress");
+	}
 
 	mDownloadRecordPath = downloadMarkerPath();
 	llifstream dataStream(mDownloadRecordPath);

indra/viewer_components/updater/llupdaterservice.cpp

 	
 	void setCheckPeriod(unsigned int seconds);
 
-	void startChecking();
+	void startChecking(bool install_if_ready);
 	void stopChecking();
 	bool isChecking();
 	
 	void setAppExitCallback(LLUpdaterService::app_exit_callback_t aecb) { mAppExitCallback = aecb;}
 
-	bool checkForInstall(); // Test if a local install is ready.
+	bool checkForInstall(bool launchInstaller); // Test if a local install is ready.
 	bool checkForResume(); // Test for resumeable d/l.
 
 	// LLUpdateChecker::Client:
 
 private:
 	void restartTimer(unsigned int seconds);
+	void stopTimer();
 };
 
 const std::string LLUpdaterServiceImpl::sListenerName = "LLUpdaterServiceImpl";
 	mCheckPeriod = seconds;
 }
 
-void LLUpdaterServiceImpl::startChecking()
+void LLUpdaterServiceImpl::startChecking(bool install_if_ready)
 {
 	if(mUrl.empty() || mChannel.empty() || mVersion.empty())
 	{
 	mIsChecking = true;
 
     // Check to see if an install is ready.
-	if(!checkForInstall())
+	bool has_install = checkForInstall(install_if_ready);
+	if(!has_install)
 	{
-		checkForResume();
-	}
+		checkForResume(); // will set mIsDownloading to true if resuming
 
-	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); 
+		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); 
+		}
 	}
 }
 
 	if(mIsChecking)
 	{
 		mIsChecking = false;
-		mTimer.stop();
+		stopTimer();
 	}
 
     if(mIsDownloading)
     {
-        this->mUpdateDownloader.cancel();
+        mUpdateDownloader.cancel();
+		mIsDownloading = false;
     }
 }
 
 	return mIsChecking;
 }
 
-bool LLUpdaterServiceImpl::checkForInstall()
+bool LLUpdaterServiceImpl::checkForInstall(bool launchInstaller)
 {
-	bool result = false; // return true if install is found.
+	bool foundInstall = false; // return true if install is found.
 
 	llifstream update_marker(update_marker_path(), 
 							 std::ios::in | std::ios::binary);
 		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");
 			{
 				llinfos << "ignoring update dowloaded by different client version" << llendl;
 				LLFile::remove(path.asString());
+				LLFile::remove(update_marker_path());
 			}
 			else
 			{
 				; // Nothing to clean up.
 			}
 			
-			result = false;
+			foundInstall = false;
 		} 
 		else if(path.isDefined() && !path.asString().empty())
 		{
-			int result = ll_install_update(install_script_path(),
-										   update_info["path"].asString(),
-										   install_script_mode());	
-			
-			if((result == 0) && mAppExitCallback)
+			if(launchInstaller)
 			{
-				mAppExitCallback();
-			} else if(result != 0) {
-				llwarns << "failed to run update install script" << LL_ENDL;
-			} else {
-				; // No op.
+				LLFile::remove(update_marker_path());
+
+				int result = ll_install_update(install_script_path(),
+											   update_info["path"].asString(),
+											   install_script_mode());	
+				
+				if((result == 0) && mAppExitCallback)
+				{
+					mAppExitCallback();
+				} else if(result != 0) {
+					llwarns << "failed to run update install script" << LL_ENDL;
+				} else {
+					; // No op.
+				}
 			}
 			
-			result = true;
+			foundInstall = true;
 		}
 	}
-	return result;
+	return foundInstall;
 }
 
 bool LLUpdaterServiceImpl::checkForResume()
 										  LLURI const & uri,
 										  std::string const & hash)
 {
-	mTimer.stop();
+	stopTimer();
 	mIsDownloading = true;
 	mUpdateDownloader.download(uri, hash);
 }
 										  LLURI const & uri,
 										  std::string const & hash)
 {
-	mTimer.stop();
+	stopTimer();
 	mIsDownloading = true;
 	mUpdateDownloader.download(uri, hash);
 }
 		sListenerName, boost::bind(&LLUpdaterServiceImpl::onMainLoop, this, _1));
 }
 
+void LLUpdaterServiceImpl::stopTimer()
+{
+	mTimer.stop();
+	LLEventPumps::instance().obtain("mainloop").stopListening(sListenerName);
+}
+
 bool LLUpdaterServiceImpl::onMainLoop(LLSD const & event)
 {
 	if(mTimer.getStarted() && mTimer.hasExpired())
 	{
-		mTimer.stop();
-		LLEventPumps::instance().obtain("mainloop").stopListening(sListenerName);
+		stopTimer();
 
 		// Check for failed install.
 		if(LLFile::isfile(ll_install_failed_marker_path()))
 	mImpl->setCheckPeriod(seconds);
 }
 	
-void LLUpdaterService::startChecking()
+void LLUpdaterService::startChecking(bool install_if_ready)
 {
-	mImpl->startChecking();
+	mImpl->startChecking(install_if_ready);
 }
 
 void LLUpdaterService::stopChecking()

indra/viewer_components/updater/llupdaterservice.h

 
 	void setCheckPeriod(unsigned int seconds);
 	
-	void startChecking();
+	void startChecking(bool install_if_ready = false);
 	void stopChecking();
 	bool isChecking();