diff options
| -rw-r--r-- | indra/newview/llappviewer.cpp | 7 | ||||
| -rw-r--r-- | indra/newview/llfilepicker.cpp | 19 | ||||
| -rw-r--r-- | indra/newview/llfilepicker.h | 2 | ||||
| -rw-r--r-- | indra/newview/llviewermenufile.cpp | 53 | ||||
| -rw-r--r-- | indra/newview/llviewermenufile.h | 26 | 
5 files changed, 99 insertions, 8 deletions
| diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index 33ab12c623..e3bfb823d0 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -78,6 +78,7 @@  #include "llteleporthistory.h"  #include "lllocationhistory.h"  #include "llfasttimerview.h" +#include "llviewermenufile.h"  #include "llvoicechannel.h"  #include "llsidetray.h" @@ -1567,6 +1568,8 @@ bool LLAppViewer::cleanup()  	sTextureFetch->shutDownTextureCacheThread() ;  	sTextureFetch->shutDownImageDecodeThread() ; +	LLFilePickerThread::cleanupClass(); +  	delete sTextureCache;      sTextureCache = NULL;  	delete sTextureFetch; @@ -1717,6 +1720,8 @@ bool LLAppViewer::initThreads()  	// Mesh streaming and caching  	gMeshRepo.init(); +	LLFilePickerThread::initClass(); +  	// *FIX: no error handling here!  	return true;  } @@ -3461,6 +3466,8 @@ void LLAppViewer::idle()  	LLEventTimer::updateClass();  	LLCriticalDamp::updateInterpolants();  	LLMortician::updateClass(); +	LLFilePickerThread::clearDead();  //calls LLFilePickerThread::notify() +  	F32 dt_raw = idle_timer.getElapsedTimeAndResetF32();  	// Cap out-of-control frame times diff --git a/indra/newview/llfilepicker.cpp b/indra/newview/llfilepicker.cpp index 6a502e8d8c..868d0b67c8 100644 --- a/indra/newview/llfilepicker.cpp +++ b/indra/newview/llfilepicker.cpp @@ -211,7 +211,7 @@ BOOL LLFilePicker::setupFilter(ELoadFilter filter)  	return res;  } -BOOL LLFilePicker::getOpenFile(ELoadFilter filter) +BOOL LLFilePicker::getOpenFile(ELoadFilter filter, BOOL blocking)  {  	if( mLocked )  	{ @@ -230,8 +230,11 @@ BOOL LLFilePicker::getOpenFile(ELoadFilter filter)  	setupFilter(filter); -	// Modal, so pause agent -	send_agent_pause(); +	if (blocking) +	{ +		// Modal, so pause agent +		send_agent_pause(); +	}  	reset(); @@ -242,10 +245,14 @@ BOOL LLFilePicker::getOpenFile(ELoadFilter filter)  		std::string filename = utf16str_to_utf8str(llutf16string(mFilesW));  		mFiles.push_back(filename);  	} -	send_agent_resume(); -	// Account for the fact that the app has been stalled. -	LLFrameTimer::updateFrameTime(); +	if (blocking) +	{ +		send_agent_resume(); +		// Account for the fact that the app has been stalled. +		LLFrameTimer::updateFrameTime(); +	} +	  	return success;  } diff --git a/indra/newview/llfilepicker.h b/indra/newview/llfilepicker.h index 98dc36c296..b96f957673 100644 --- a/indra/newview/llfilepicker.h +++ b/indra/newview/llfilepicker.h @@ -113,7 +113,7 @@ public:  	// open the dialog. This is a modal operation  	BOOL getSaveFile( ESaveFilter filter = FFSAVE_ALL, const std::string& filename = LLStringUtil::null ); -	BOOL getOpenFile( ELoadFilter filter = FFLOAD_ALL ); +	BOOL getOpenFile( ELoadFilter filter = FFLOAD_ALL, BOOL blocking = TRUE  );  	BOOL getMultipleOpenFiles( ELoadFilter filter = FFLOAD_ALL );  	// Get the filename(s) found. getFirstFile() sets the pointer to diff --git a/indra/newview/llviewermenufile.cpp b/indra/newview/llviewermenufile.cpp index e260220493..8b53751275 100644 --- a/indra/newview/llviewermenufile.cpp +++ b/indra/newview/llviewermenufile.cpp @@ -100,6 +100,57 @@ class LLFileEnableUploadModel : public view_listener_t  	}  }; +LLMutex* LLFilePickerThread::sMutex = NULL; +std::queue<LLFilePickerThread*> LLFilePickerThread::sDeadQ; + +//virtual  +void LLFilePickerThread::run() +{ +	LLFilePicker picker; +	if (picker.getOpenFile(mFilter, FALSE)) +	{ +		mFile = picker.getFirstFile(); +	} +	 +	{ +		LLMutexLock lock(sMutex); +		sDeadQ.push(this); +	} + +} + +//static +void LLFilePickerThread::initClass() +{ +	sMutex = new LLMutex(NULL); +} + +//static +void LLFilePickerThread::cleanupClass() +{ +	clearDead(); +	 +	delete sMutex; +	sMutex = NULL; +} + +//static +void LLFilePickerThread::clearDead() +{ +	if (!sDeadQ.empty()) +	{ +		LLMutexLock lock(sMutex); +		while (!sDeadQ.empty()) +		{ +			LLFilePickerThread* thread = sDeadQ.front(); +			thread->notify(thread->mFile); +			delete thread; +			sDeadQ.pop(); +		} +	} +} + +  //============================================================================  #if LL_WINDOWS @@ -290,7 +341,7 @@ class LLFileUploadModel : public view_listener_t  {  	bool handleEvent(const LLSD& userdata)  	{ -		LLFloaterModelPreview* fmp = (LLFloaterModelPreview*) LLFloaterReg::showInstance("upload_model"); +		LLFloaterModelPreview* fmp = (LLFloaterModelPreview*) LLFloaterReg::getInstance("upload_model");  		if (fmp)  		{  			fmp->loadModel(3); diff --git a/indra/newview/llviewermenufile.h b/indra/newview/llviewermenufile.h index e700b0565e..8936b5cdb4 100644 --- a/indra/newview/llviewermenufile.h +++ b/indra/newview/llviewermenufile.h @@ -36,6 +36,7 @@  #include "llfoldertype.h"  #include "llassetstorage.h"  #include "llinventorytype.h" +#include "llfilepicker.h"  class LLTransactionID; @@ -120,5 +121,30 @@ void on_new_single_inventory_upload_complete(  	const LLSD& server_response,  	S32 upload_price); +class LLFilePickerThread : public LLThread +{ //multi-threaded file picker (runs system specific file picker in background and calls "notify" from main thread) +public: + +	static std::queue<LLFilePickerThread*> sDeadQ; +	static LLMutex* sMutex; + +	static void initClass(); +	static void cleanupClass(); +	static void clearDead(); + +	std::string mFile;  + +	LLFilePicker::ELoadFilter mFilter; + +	LLFilePickerThread(LLFilePicker::ELoadFilter filter) +		: LLThread("file picker"), mFilter(filter) +	{ + +	} +	virtual void run(); + +	virtual void notify(const std::string& filename) = 0; +}; +  #endif | 
