From d300a88bcc0ecb4a097069788d83cffe7197601b Mon Sep 17 00:00:00 2001 From: Ansariel Date: Wed, 21 Oct 2015 09:12:29 +0200 Subject: [PATCH] Fix preprocessor memory leak and make string introduced in previous two commits localizable --- indra/newview/fslslpreproc.cpp | 3 +- indra/newview/llcompilequeue.cpp | 33 +++++++++++-------- indra/newview/llpreviewscript.cpp | 22 ++++++++----- .../newview/skins/default/xui/de/strings.xml | 6 ++++ .../newview/skins/default/xui/en/strings.xml | 2 ++ 5 files changed, 44 insertions(+), 22 deletions(-) diff --git a/indra/newview/fslslpreproc.cpp b/indra/newview/fslslpreproc.cpp index 0ec5815599..be39e1aa2f 100644 --- a/indra/newview/fslslpreproc.cpp +++ b/indra/newview/fslslpreproc.cpp @@ -1565,7 +1565,8 @@ void FSLSLPreprocessor::start_process() { LLFloaterCompileQueue::scriptPreprocComplete(mAssetID, mData, mType, output); } - else{ + else + { LLTextEditor* outfield = mCore->mPostEditor; if (outfield) { diff --git a/indra/newview/llcompilequeue.cpp b/indra/newview/llcompilequeue.cpp index f06e146d31..1e92c6ab3f 100755 --- a/indra/newview/llcompilequeue.cpp +++ b/indra/newview/llcompilequeue.cpp @@ -343,6 +343,7 @@ private: LLFloaterCompileQueue::LLFloaterCompileQueue(const LLSD& key) : LLFloaterScriptQueue(key) + , mLSLProc(NULL) // Script Proprocessor { setTitle(LLTrans::getString("CompileQueueTitle")); setStartString(LLTrans::getString("CompileQueueStart")); @@ -350,7 +351,7 @@ LLFloaterCompileQueue::LLFloaterCompileQueue(const LLSD& key) mUploadQueue = new LLAssetUploadQueue(new LLCompileFloaterUploadQueueSupplier(key.asUUID())); // Script Preprocessor - static LLCachedControl _NACL_LSLPreprocessor(gSavedSettings,"_NACL_LSLPreprocessor", 0); + static LLCachedControl _NACL_LSLPreprocessor(gSavedSettings, "_NACL_LSLPreprocessor"); if(_NACL_LSLPreprocessor) { mLSLProc = new FSLSLPreprocessor(); @@ -359,7 +360,9 @@ LLFloaterCompileQueue::LLFloaterCompileQueue(const LLSD& key) } LLFloaterCompileQueue::~LLFloaterCompileQueue() -{ +{ + // Script Proprocessor + delete mLSLProc; } void LLFloaterCompileQueue::experienceIdsReceived( const LLSD& content ) @@ -497,8 +500,8 @@ void LLFloaterCompileQueue::scriptArrived(LLVFS *vfs, const LLUUID& asset_id, if(!url.empty()) { // LSL Preprocessor - static LLCachedControl _NACL_LSLPreprocessor(gSavedSettings,"_NACL_LSLPreprocessor", 0); - if(queue->mLSLProc && _NACL_LSLPreprocessor) + static LLCachedControl _NACL_LSLPreprocessor(gSavedSettings, "_NACL_LSLPreprocessor"); + if (_NACL_LSLPreprocessor && queue->mLSLProc) { U32 script_size = file.getSize(); std::string script_data; @@ -507,7 +510,9 @@ void LLFloaterCompileQueue::scriptArrived(LLVFS *vfs, const LLUUID& asset_id, script_data = queue->mLSLProc->decode(script_data); - LLFloaterCompileQueue::scriptLogMessage(data, "Preprocessing: " + data->mItem->getName()); + LLStringUtil::format_map_t args; + args["SCRIPT"] = data->mItem->getName(); + LLFloaterCompileQueue::scriptLogMessage(data, LLTrans::getString("CompileQueuePreprocessing", args)); queue->mLSLProc->preprocess_script(asset_id, data, type, script_data); return; } @@ -567,14 +572,13 @@ void LLFloaterCompileQueue::scriptArrived(LLVFS *vfs, const LLUUID& asset_id, void LLFloaterCompileQueue::scriptPreprocComplete(const LLUUID& asset_id, LLScriptQueueData* data, LLAssetType::EType type, const std::string& script_text) { LL_INFOS() << "LLFloaterCompileQueue::scriptPreprocComplete()" << LL_ENDL; - if(!data) + if (!data) { return; } LLFloaterCompileQueue* queue = LLFloaterReg::findTypedInstance("compile_queue", data->mQueueID); - std::string buffer; - if(queue) + if (queue) { std::string filename; std::string uuid_str; @@ -586,14 +590,16 @@ void LLFloaterCompileQueue::scriptPreprocComplete(const LLUUID& asset_id, LLScri if (object) { std::string url = object->getRegion()->getCapability("UpdateScriptTask"); - if(!url.empty()) + if (!url.empty()) { // Read script source in to buffer. U32 script_size = script_text.length(); U8* script_data = new U8[script_text.length()+1]; strcpy((char *)script_data, script_text.c_str()); - LLFloaterCompileQueue::scriptLogMessage(data, "Preprocessing complete of " + data->mItem->getName()); + LLStringUtil::format_map_t args; + args["SCRIPT"] = data->mItem->getName(); + LLFloaterCompileQueue::scriptLogMessage(data, LLTrans::getString("CompileQueuePreprocessingComplete", args)); queue->mUploadQueue->queue(filename, data->mTaskId, data->mItem->getUUID(), is_running, queue->mMono, queue->getKey().asUUID(), @@ -601,21 +607,22 @@ void LLFloaterCompileQueue::scriptPreprocComplete(const LLUUID& asset_id, LLScri } else { - buffer = LLTrans::getString("CompileQueueServiceUnavailable") + (": ") + data->mItem->getName(); + LLFloaterCompileQueue::scriptLogMessage(data, LLTrans::getString("CompileQueueServiceUnavailable") + (": ") + data->mItem->getName()); } } } delete data; } + // static void LLFloaterCompileQueue::scriptLogMessage(LLScriptQueueData* data, std::string message) { - if(!data) + if (!data) { return; } LLFloaterCompileQueue* queue = LLFloaterReg::findTypedInstance("compile_queue", data->mQueueID); - if(queue) + if (queue) { queue->getChild("queue output")->addSimpleElement(message, ADD_BOTTOM); } diff --git a/indra/newview/llpreviewscript.cpp b/indra/newview/llpreviewscript.cpp index 3ad2d9038e..51cfaea5c3 100755 --- a/indra/newview/llpreviewscript.cpp +++ b/indra/newview/llpreviewscript.cpp @@ -455,15 +455,15 @@ LLScriptEdCore::LLScriptEdCore( setBorderVisible(FALSE); // NaCl - Script Preprocessor - static LLCachedControl _NACL_LSLPreprocessor(gSavedSettings,"_NACL_LSLPreprocessor", 0); - BOOL preproc = _NACL_LSLPreprocessor; - if(preproc) + if (gSavedSettings.getBOOL("_NACL_LSLPreprocessor")) { setXMLFilename("panel_script_ed_preproc.xml"); mLSLProc = new FSLSLPreprocessor(this); } else + { setXMLFilename("panel_script_ed.xml"); + } // NaCl End llassert_always(mContainer != NULL); } @@ -491,6 +491,9 @@ LLScriptEdCore::~LLScriptEdCore() { mSyntaxIDConnection.disconnect(); } + + // NaCl - Script Preprocessor + delete mLSLProc; } void LLLiveLSLEditor::experienceChanged() @@ -849,9 +852,12 @@ void LLScriptEdCore::setScriptText(const std::string& text, BOOL is_valid) { // NaCl - LSL Preprocessor std::string ntext = text; - if(gSavedSettings.getBOOL("_NACL_LSLPreprocessor")) + if (gSavedSettings.getBOOL("_NACL_LSLPreprocessor") && mLSLProc) { - if(mPostEditor)mPostEditor->setText(ntext); + if (mPostEditor) + { + mPostEditor->setText(ntext); + } ntext = mLSLProc->decode(ntext); } LLStringUtil::replaceTabsWithSpaces(ntext, mEditor->spacesPerTab()); @@ -864,7 +870,7 @@ void LLScriptEdCore::setScriptText(const std::string& text, BOOL is_valid) // NaCl - LSL Preprocessor std::string LLScriptEdCore::getScriptText() { - if(gSavedSettings.getBOOL("_NACL_LSLPreprocessor") && mPostEditor) + if (gSavedSettings.getBOOL("_NACL_LSLPreprocessor") && mPostEditor) { //return mPostEditor->getText(); return mPostScript; @@ -1345,7 +1351,7 @@ void LLScriptEdCore::doSave(BOOL close_after_save, bool sync /*= true*/) updateIndicators(true, false); // Compile Indicators - if (mLSLProc && gSavedSettings.getBOOL("_NACL_LSLPreprocessor")) + if (gSavedSettings.getBOOL("_NACL_LSLPreprocessor") && mLSLProc) { LL_INFOS() << "passing to preproc" << LL_ENDL; mLSLProc->preprocess_script(close_after_save, sync); @@ -1448,7 +1454,7 @@ void LLScriptEdCore::onErrorList(LLUICtrl*, void* user_data) //LL_INFOS() << "LLScriptEdCore::onErrorList() - " << row << ", " //<< column << LL_ENDL; // NaCl - LSL Preprocessor - if(gSavedSettings.getBOOL("_NACL_LSLPreprocessor") && self->mPostEditor) + if (gSavedSettings.getBOOL("_NACL_LSLPreprocessor") && self->mPostEditor) { LLPanel* tab = self->getChild("Preprocessed"); LLTabContainer* tabset = self->getChild("Tabset"); diff --git a/indra/newview/skins/default/xui/de/strings.xml b/indra/newview/skins/default/xui/de/strings.xml index baf38dd90f..059617bfad 100755 --- a/indra/newview/skins/default/xui/de/strings.xml +++ b/indra/newview/skins/default/xui/de/strings.xml @@ -2175,6 +2175,12 @@ Warten Sie kurz und versuchen Sie dann noch einmal, sich anzumelden. Rekompilieren + + Präprozessieren: [SCRIPT] + + + Präprozessieren von Skript [SCRIPT] beendet + Skripte zurücksetzen diff --git a/indra/newview/skins/default/xui/en/strings.xml b/indra/newview/skins/default/xui/en/strings.xml index 88c6eb55bc..bf8f874395 100755 --- a/indra/newview/skins/default/xui/en/strings.xml +++ b/indra/newview/skins/default/xui/en/strings.xml @@ -994,6 +994,8 @@ This feature is currently in Beta. Please add your name to this [http://goo.gl/f Skipping script [SCRIPT] with Experience [EXPERIENCE]. Recompilation Progress recompile + Proprocessing: [SCRIPT] + Proprocessing of script [SCRIPT] complete Reset Progress reset Set Running Progress