FIRE-7514: Script in external editor needs to be saved twice to be updated in internal editor

Mon, 05 Jan 2015 10:10:28 +0100

author
Ansariel
date
Mon, 05 Jan 2015 10:10:28 +0100
changeset 43095
e86e761eca54
parent 43094
02a50237407f
child 43096
4b731b22e2db

FIRE-7514: Script in external editor needs to be saved twice to be updated in internal editor

indra/newview/fslslpreproc.cpp file | annotate | diff | revisions
indra/newview/fslslpreproc.h file | annotate | diff | revisions
indra/newview/llpreviewscript.cpp file | annotate | diff | revisions
indra/newview/llpreviewscript.h file | annotate | diff | revisions
     1.1 --- a/indra/newview/fslslpreproc.cpp	Tue Dec 30 21:26:54 2014 +0100
     1.2 +++ b/indra/newview/fslslpreproc.cpp	Mon Jan 05 10:10:28 2015 +0100
     1.3 @@ -672,9 +672,10 @@
     1.4  	}
     1.5  }
     1.6  
     1.7 -void FSLSLPreprocessor::preprocess_script(BOOL close, BOOL defcache)
     1.8 +void FSLSLPreprocessor::preprocess_script(BOOL close, bool sync, BOOL defcache)
     1.9  {
    1.10  	mClose = close;
    1.11 +	mSync = sync;
    1.12  	mDefinitionCaching = defcache;
    1.13  	caching_files.clear();
    1.14  	mCore->mErrorList->setCommentText(std::string("PreProc Starting..."));
    1.15 @@ -1156,7 +1157,7 @@
    1.16  			outfield->setText(LLStringExplicit(output));
    1.17  		}
    1.18  		mCore->mPostScript = output;
    1.19 -		mCore->doSaveComplete((void*)mCore,mClose);
    1.20 +		mCore->doSaveComplete((void*)mCore,mClose,mSync);
    1.21  	}
    1.22  	mWaving = FALSE;
    1.23  }
     2.1 --- a/indra/newview/fslslpreproc.h	Tue Dec 30 21:26:54 2014 +0100
     2.2 +++ b/indra/newview/fslslpreproc.h	Mon Jan 05 10:10:28 2015 +0100
     2.3 @@ -46,7 +46,7 @@
     2.4  public:
     2.5  
     2.6  	FSLSLPreprocessor(LLScriptEdCore* corep)
     2.7 -		: mCore(corep), mWaving(FALSE), mClose(FALSE)
     2.8 +		: mCore(corep), mWaving(FALSE), mClose(FALSE), mSync(false)
     2.9  	{}
    2.10  
    2.11  	static bool mono_directive(std::string const& text, bool agent_inv = true);
    2.12 @@ -59,7 +59,7 @@
    2.13  	static LLUUID findInventoryByName(std::string name);
    2.14  	static void FSProcCacheCallback(LLVFS *vfs, const LLUUID& uuid, LLAssetType::EType type,
    2.15  									void *userdata, S32 result, LLExtStat extstat);
    2.16 -	void preprocess_script(BOOL close = FALSE, BOOL defcache = FALSE);
    2.17 +	void preprocess_script(BOOL close = FALSE, bool sync = false, BOOL defcache = FALSE);
    2.18  	void start_process();
    2.19  	void display_error(std::string err);
    2.20  
    2.21 @@ -86,6 +86,7 @@
    2.22  	LLScriptEdCore* mCore;
    2.23  	BOOL mWaving;
    2.24  	BOOL mClose;
    2.25 +	bool mSync;
    2.26  	BOOL mHDDInclude;
    2.27  	std::string mMainScriptName;
    2.28  };
     3.1 --- a/indra/newview/llpreviewscript.cpp	Tue Dec 30 21:26:54 2014 +0100
     3.2 +++ b/indra/newview/llpreviewscript.cpp	Mon Jan 05 10:10:28 2015 +0100
     3.3 @@ -400,7 +400,10 @@
     3.4  	const std::string& sample,
     3.5  	const LLHandle<LLFloater>& floater_handle,
     3.6  	void (*load_callback)(void*),
     3.7 -	void (*save_callback)(void*, BOOL),
     3.8 +	// <FS:Ansariel> FIRE-7514: Script in external editor needs to be saved twice
     3.9 +	//void (*save_callback)(void*, BOOL),
    3.10 +	void (*save_callback)(void*, BOOL, bool),
    3.11 +	// </FS:Ansariel>
    3.12  	void (*search_replace_callback) (void* userdata),
    3.13  	void* userdata,
    3.14  	S32 bottom_pad)
    3.15 @@ -620,7 +623,10 @@
    3.16  	LLMenuItemCallGL* menuItem;
    3.17  	
    3.18  	menuItem = getChild<LLMenuItemCallGL>("Save");
    3.19 -	menuItem->setClickCallback(boost::bind(&LLScriptEdCore::doSave, this, FALSE));
    3.20 +	// <FS:Ansariel> FIRE-7514: Script in external editor needs to be saved twice
    3.21 +	//menuItem->setClickCallback(boost::bind(&LLScriptEdCore::doSave, this, FALSE));
    3.22 +	menuItem->setClickCallback(boost::bind(&LLScriptEdCore::doSave, this, FALSE, true));
    3.23 +	// </FS:Ansariel>
    3.24  	menuItem->setEnableCallback(boost::bind(&LLScriptEdCore::hasChanged, this));
    3.25  	
    3.26  	menuItem = getChild<LLMenuItemCallGL>("Revert All Changes");
    3.27 @@ -685,8 +691,8 @@
    3.28  
    3.29  void LLScriptEdCore::initButtonBar()
    3.30  {
    3.31 -	mSaveBtn->setClickedCallback(boost::bind(&LLScriptEdCore::doSave, this, FALSE));
    3.32 -	mSaveBtn2->setClickedCallback(boost::bind(&LLScriptEdCore::doSave, this, FALSE));	// <FS:Zi> support extra save button
    3.33 +	mSaveBtn->setClickedCallback(boost::bind(&LLScriptEdCore::doSave, this, FALSE, true));
    3.34 +	mSaveBtn2->setClickedCallback(boost::bind(&LLScriptEdCore::doSave, this, FALSE, true));	// <FS:Zi> support extra save button
    3.35  	mCutBtn->setClickedCallback(boost::bind(&LLTextEditor::cut, mEditor));
    3.36  	mCopyBtn->setClickedCallback(boost::bind(&LLTextEditor::copy, mEditor));
    3.37  	mPasteBtn->setClickedCallback(boost::bind(&LLTextEditor::paste, mEditor));
    3.38 @@ -1197,26 +1203,29 @@
    3.39  	self->setHelpPage(self->mFunctions->getSimple());
    3.40  }
    3.41  
    3.42 -void LLScriptEdCore::doSave( BOOL close_after_save )
    3.43 +// <FS:Ansariel> FIRE-7514: Script in external editor needs to be saved twice
    3.44 +//void LLScriptEdCore::doSave( BOOL close_after_save )
    3.45 +void LLScriptEdCore::doSave(BOOL close_after_save, bool sync /*= true*/)
    3.46 +// </FS:Ansariel>
    3.47  {
    3.48  	// NaCl - LSL Preprocessor
    3.49  	if (mLSLProc && gSavedSettings.getBOOL("_NACL_LSLPreprocessor"))
    3.50  	{
    3.51  		LL_INFOS() << "passing to preproc" << LL_ENDL;
    3.52 -		mLSLProc->preprocess_script(close_after_save);
    3.53 +		mLSLProc->preprocess_script(close_after_save, sync);
    3.54  	}
    3.55  	else
    3.56  	{
    3.57  		if( mSaveCallback )
    3.58  		{
    3.59 -			mSaveCallback( mUserdata, close_after_save );
    3.60 +			mSaveCallback( mUserdata, close_after_save, sync );
    3.61  		}
    3.62  	}
    3.63  	// NaCl End
    3.64  }
    3.65  
    3.66  // NaCl - LSL Preprocessor
    3.67 -void LLScriptEdCore::doSaveComplete( void* userdata, BOOL close_after_save )
    3.68 +void LLScriptEdCore::doSaveComplete( void* userdata, BOOL close_after_save, bool sync)
    3.69  {
    3.70  	add( LLStatViewer::LSL_SAVES,1 );
    3.71  
    3.72 @@ -1224,7 +1233,7 @@
    3.73  
    3.74  	if( mSaveCallback )
    3.75  	{
    3.76 -		mSaveCallback( mUserdata, close_after_save );
    3.77 +		mSaveCallback( mUserdata, close_after_save, sync );
    3.78  	}
    3.79  }
    3.80  // NaCl End
    3.81 @@ -1474,7 +1483,10 @@
    3.82  			std::ofstream fout(filename.c_str());
    3.83  			fout<<(scriptText);
    3.84  			fout.close();
    3.85 -			self->mSaveCallback( self->mUserdata, FALSE );
    3.86 +			// <FS:Ansariel> FIRE-7514: Script in external editor needs to be saved twice
    3.87 +			//self->mSaveCallback( self->mUserdata, FALSE );
    3.88 +			self->mSaveCallback( self->mUserdata, FALSE, true );
    3.89 +			// </FS:Ansariel>
    3.90  		}
    3.91  	}
    3.92  }
    3.93 @@ -1597,8 +1609,10 @@
    3.94  	}
    3.95  
    3.96  	// Disable sync to avoid recursive load->save->load calls.
    3.97 -	mScriptEd->doSave(FALSE);
    3.98 -	saveIfNeeded(false);
    3.99 +	// <FS> LSL preprocessor
   3.100 +	//saveIfNeeded(false);
   3.101 +	mScriptEd->doSave(FALSE, false);
   3.102 +	// </FS>
   3.103  	return true;
   3.104  }
   3.105  
   3.106 @@ -1801,11 +1815,17 @@
   3.107  }
   3.108  
   3.109  // static
   3.110 -void LLPreviewLSL::onSave(void* userdata, BOOL close_after_save)
   3.111 +// <FS:Ansariel> FIRE-7514: Script in external editor needs to be saved twice
   3.112 +//void LLPreviewLSL::onSave(void* userdata, BOOL close_after_save)
   3.113 +void LLPreviewLSL::onSave(void* userdata, BOOL close_after_save, bool sync)
   3.114 +// </FS:Ansariel>
   3.115  {
   3.116  	LLPreviewLSL* self = (LLPreviewLSL*)userdata;
   3.117  	self->mCloseAfterSave = close_after_save;
   3.118 -	self->saveIfNeeded();
   3.119 +	// <FS:Ansariel> FIRE-7514: Script in external editor needs to be saved twice
   3.120 +	//self->saveIfNeeded();
   3.121 +	self->saveIfNeeded(sync);
   3.122 +	// </FS:Ansariel>
   3.123  }
   3.124  
   3.125  // Save needs to compile the text in the buffer. If the compile
   3.126 @@ -2907,12 +2927,18 @@
   3.127  }
   3.128  
   3.129  // static
   3.130 -void LLLiveLSLEditor::onSave(void* userdata, BOOL close_after_save)
   3.131 +// <FS:Ansariel> FIRE-7514: Script in external editor needs to be saved twice
   3.132 +//void LLLiveLSLEditor::onSave(void* userdata, BOOL close_after_save)
   3.133 +void LLLiveLSLEditor::onSave(void* userdata, BOOL close_after_save, bool sync)
   3.134 +// </FS:Ansariel>
   3.135  {
   3.136  	LLLiveLSLEditor* self = (LLLiveLSLEditor*)userdata;
   3.137  
   3.138  	self->mCloseAfterSave = close_after_save;
   3.139 -	self->saveIfNeeded();
   3.140 +	// <FS:Ansariel> FIRE-7514: Script in external editor needs to be saved twice
   3.141 +	//self->saveIfNeeded();
   3.142 +	self->saveIfNeeded(sync);
   3.143 +	// </FS:Ansariel>
   3.144  }
   3.145  
   3.146  
     4.1 --- a/indra/newview/llpreviewscript.h	Tue Dec 30 21:26:54 2014 +0100
     4.2 +++ b/indra/newview/llpreviewscript.h	Mon Jan 05 10:10:28 2015 +0100
     4.3 @@ -77,7 +77,10 @@
     4.4  		const std::string& sample,
     4.5  		const LLHandle<LLFloater>& floater_handle,
     4.6  		void (*load_callback)(void* userdata),
     4.7 -		void (*save_callback)(void* userdata, BOOL close_after_save),
     4.8 +		// <FS:Ansariel> FIRE-7514: Script in external editor needs to be saved twice
     4.9 +		//void (*save_callback)(void* userdata, BOOL close_after_save),
    4.10 +		void (*save_callback)(void* userdata, BOOL close_after_save, bool sync),
    4.11 +		// </FS:Ansariel>
    4.12  		void (*search_replace_callback)(void* userdata),
    4.13  		void* userdata,
    4.14  		S32 bottom_pad = 0);	// pad below bottom row of buttons
    4.15 @@ -95,13 +98,16 @@
    4.16  	void            setScriptText(const std::string& text, BOOL is_valid);
    4.17  	// NaCL - LSL Preprocessor
    4.18  	std::string		getScriptText();
    4.19 -	void			doSaveComplete(void* userdata, BOOL close_after_save );
    4.20 +	void			doSaveComplete(void* userdata, BOOL close_after_save, bool sync);
    4.21  	// NaCl End
    4.22  	bool			loadScriptText(const std::string& filename);
    4.23  	bool			writeToFile(const std::string& filename, bool unprocessed);
    4.24  	void			sync();
    4.25  	
    4.26 -	void			doSave( BOOL close_after_save );
    4.27 +	// <FS:Ansariel> FIRE-7514: Script in external editor needs to be saved twice
    4.28 +	//void			doSave( BOOL close_after_save );
    4.29 +	void			doSave(BOOL close_after_save, bool sync = true);
    4.30 +	// </FS:Ansariel>
    4.31  
    4.32  	bool			handleSaveChangesDialog(const LLSD& notification, const LLSD& response);
    4.33  	bool			handleReloadFromServerDialog(const LLSD& notification, const LLSD& response);
    4.34 @@ -155,7 +161,10 @@
    4.35  	std::string		mSampleText;
    4.36  	LLTextEditor*	mEditor;
    4.37  	void			(*mLoadCallback)(void* userdata);
    4.38 -	void			(*mSaveCallback)(void* userdata, BOOL close_after_save);
    4.39 +	// <FS:Ansariel> FIRE-7514: Script in external editor needs to be saved twice
    4.40 +	//void			(*mSaveCallback)(void* userdata, BOOL close_after_save);
    4.41 +	void			(*mSaveCallback)(void* userdata, BOOL close_after_save, bool sync);
    4.42 +	// </FS:Ansariel>
    4.43  	void			(*mSearchReplaceCallback) (void* userdata);
    4.44  	void*			mUserdata;
    4.45  	LLComboBox		*mFunctions;
    4.46 @@ -254,7 +263,10 @@
    4.47  
    4.48  	static void onSearchReplace(void* userdata);
    4.49  	static void onLoad(void* userdata);
    4.50 -	static void onSave(void* userdata, BOOL close_after_save);
    4.51 +	// <FS:Ansariel> FIRE-7514: Script in external editor needs to be saved twice
    4.52 +	//static void onSave(void* userdata, BOOL close_after_save);
    4.53 +	static void onSave(void* userdata, BOOL close_after_save, bool sync);
    4.54 +	// </FS:Ansariel>
    4.55  	
    4.56  	static void onLoadComplete(LLVFS *vfs, const LLUUID& uuid,
    4.57  							   LLAssetType::EType type,
    4.58 @@ -327,7 +339,10 @@
    4.59  
    4.60  	static void onSearchReplace(void* userdata);
    4.61  	static void onLoad(void* userdata);
    4.62 -	static void onSave(void* userdata, BOOL close_after_save);
    4.63 +	// <FS:Ansariel> FIRE-7514: Script in external editor needs to be saved twice
    4.64 +	//static void onSave(void* userdata, BOOL close_after_save);
    4.65 +	static void onSave(void* userdata, BOOL close_after_save, bool sync);
    4.66 +	// </FS:Ansariel>
    4.67  
    4.68  	static void onLoadComplete(LLVFS *vfs, const LLUUID& asset_uuid,
    4.69  							   LLAssetType::EType type,

mercurial