FIRE-10172: Fix LSL script editor error handling - by Sei Lisa; with slight modifications to meet our coding guidelines and let the comment textbox scroll to the end automatically

Ansariel 2015-03-17 13:47:50 +01:00
parent 1eb9a36618
commit ffbefc2749
4 changed files with 52 additions and 23 deletions

View File

@ -268,6 +268,9 @@ LLScrollListCtrl::LLScrollListCtrl(const LLScrollListCtrl::Params& p)
text_p.wrap(true);
// set up label text color for empty lists in a way it's always readable -Zi
text_p.text_color = mFgUnselectedColor;
// show scroll bar when applicable -Sei
text_p.allow_scroll(true);
text_p.track_end(true);
addChild(LLUICtrlFactory::create<LLTextBox>(text_p));
// </FS:Ansariel>
@ -1240,7 +1243,8 @@ void LLScrollListCtrl::setCommentText(const std::string& comment_text)
// <FS:Ansariel> Allow appending of comment text
void LLScrollListCtrl::addCommentText(const std::string& comment_text)
{
getChild<LLTextBox>("comment_text")->appendText(comment_text, true);
LLTextBox *ctrl = getChild<LLTextBox>("comment_text");
ctrl->appendText(comment_text, !ctrl->getText().empty()); // don't prepend newline if empty (Sei)
}
// </FS:Ansariel> Allow appending of comment text

View File

@ -553,8 +553,8 @@ public:
std::set<std::string>::iterator it = mProc->caching_files.find(cfilename);
if (it == mProc->caching_files.end())
{
if(not_cached)mProc->display_error(std::string("Caching ")+cfilename);
else /*if(changed)*/mProc->display_error(cfilename+std::string(" has changed, recaching..."));
if(not_cached)mProc->display_message(std::string("Caching ")+cfilename);
else /*if(changed)*/mProc->display_message(cfilename+std::string(" has changed, recaching..."));
//one is always true
mProc->caching_files.insert(cfilename);
ProcCacheInfo* info = new ProcCacheInfo;
@ -712,7 +712,7 @@ void FSLSLPreprocessor::FSProcCacheCallback(LLVFS *vfs, const LLUUID& iuuid, LLA
if (boost::filesystem::native(name))
{
LL_DEBUGS() << "native name of " << name << LL_ENDL;
self->display_error("Cached " + name);
self->display_message("Cached " + name);
cache_script(name, content);
std::set<std::string>::iterator loc = self->caching_files.find(name);
if (loc != self->caching_files.end())
@ -750,7 +750,7 @@ void FSLSLPreprocessor::preprocess_script(BOOL close, bool sync, bool defcache)
mSync = sync;
mDefinitionCaching = defcache;
caching_files.clear();
display_error("PreProc Starting...");
display_message("PreProc Starting...");
LLFile::mkdir(gDirUtilp->getExpandedFilename(LL_PATH_CACHE,"") + gDirUtilp->getDirDelimiter() + "lslpreproc");
std::string script = mCore->mEditor->getText();
@ -1190,10 +1190,10 @@ void FSLSLPreprocessor::start_process()
bool enable_hdd_include = gSavedSettings.getBOOL("_NACL_PreProcEnableHDDInclude");
bool use_compression = gSavedSettings.getBOOL("_NACL_PreProcLSLTextCompress");
std::string settings;
settings = "Settings: preproc ";
settings = "Settings: preproc";
if (lazy_lists)
{
settings = settings + " Lazy Lists";
settings = settings + " LazyLists";
}
if (use_switch)
{
@ -1212,7 +1212,7 @@ void FSLSLPreprocessor::start_process()
settings = settings + " Compress";
}
//display the settings
display_error(settings);
display_message(settings);
LL_DEBUGS() << settings << LL_ENDL;
bool errored = false;
@ -1330,7 +1330,7 @@ void FSLSLPreprocessor::start_process()
{
try
{
display_error("Applying lazy list set transform");
display_message("Applying lazy list set transform");
output = reformat_lazy_lists(output);
}
catch(...)
@ -1345,7 +1345,7 @@ void FSLSLPreprocessor::start_process()
{
try
{
display_error("Applying switch statement transform");
display_message("Applying switch statement transform");
output = reformat_switch_statements(output);
}
catch(...)
@ -1363,7 +1363,7 @@ void FSLSLPreprocessor::start_process()
{
if (use_optimizer)
{
display_error("Optimizing out unreferenced user-defined functions and global variables");
display_message("Optimizing out unreferenced user-defined functions and global variables");
try
{
output = lslopt(output);
@ -1380,7 +1380,7 @@ void FSLSLPreprocessor::start_process()
{
if (use_compression)
{
display_error("Compressing lsltext by removing unnecessary space");
display_message("Compressing lsltext by removing unnecessary space");
try
{
output = lslcomp(output);
@ -1443,9 +1443,17 @@ void FSLSLPreprocessor::preprocess_script(BOOL close, bool sync, bool defcache)
#endif
void FSLSLPreprocessor::display_message(const std::string& err)
{
mCore->mErrorList->addCommentText(err);
}
void FSLSLPreprocessor::display_error(const std::string& err)
{
mCore->mErrorList->setCommentText(err);
LLSD row;
row["columns"][0]["value"] = err;
row["columns"][0]["font"] = "SANSSERIF_SMALL";
mCore->mErrorList->addElement(row);
}

View File

@ -61,6 +61,7 @@ public:
void *userdata, S32 result, LLExtStat extstat);
void preprocess_script(BOOL close = FALSE, bool sync = false, bool defcache = false);
void start_process();
void display_message(const std::string& err);
void display_error(const std::string& err);
std::string uncollide_string_literals(std::string script);

View File

@ -1232,6 +1232,10 @@ void LLScriptEdCore::doSave(BOOL close_after_save, bool sync /*= true*/)
// </FS:Ansariel>
{
// NaCl - LSL Preprocessor
// Clear status list *before* running the preprocessor (FIRE-10172) -Sei
mErrorList->deleteAllItems();
mErrorList->setCommentText(std::string());
if (mLSLProc && gSavedSettings.getBOOL("_NACL_LSLPreprocessor"))
{
LL_INFOS() << "passing to preproc" << LL_ENDL;
@ -1706,10 +1710,12 @@ BOOL LLPreviewLSL::postBuild()
void LLPreviewLSL::callbackLSLCompileSucceeded()
{
LL_INFOS() << "LSL Bytecode saved" << LL_ENDL;
// ## Zi: setCommentText() only allows one line anyway, so we just remove the compile
// successful message here, since it's meaningless anyway.
// mScriptEd->mErrorList->setCommentText(LLTrans::getString("CompileSuccessful"));
mScriptEd->mErrorList->setCommentText(LLTrans::getString("SaveComplete"));
// <FS> Append comment text
//mScriptEd->mErrorList->setCommentText(LLTrans::getString("CompileSuccessful"));
//mScriptEd->mErrorList->setCommentText(LLTrans::getString("SaveComplete"));
mScriptEd->mErrorList->addCommentText(LLTrans::getString("CompileSuccessful"));
mScriptEd->mErrorList->addCommentText(LLTrans::getString("SaveComplete"));
// </FS>
// [SL:KB] - Patch: Build-ScriptRecover | Checked: 2011-11-23 (Catznip-3.2.0) | Added: Catznip-3.2.0
// Script was successfully saved so delete our backup copy if we have one and the editor is still pristine
@ -1870,9 +1876,9 @@ void LLPreviewLSL::saveIfNeeded(bool sync /*= true*/)
}
mPendingUploads = 0;
mScriptEd->mErrorList->deleteAllItems();
// <FS> FIRE-10172: Fix LSL editor error display
//mScriptEd->mErrorList->deleteAllItems();
mScriptEd->mEditor->makePristine();
mScriptEd->mErrorList->setCommentText(std::string()); // ## Zi: Clear out comment overlay, too.
// save off asset into file
LLTransactionID tid;
@ -2251,8 +2257,12 @@ void LLLiveLSLEditor::callbackLSLCompileSucceeded(const LLUUID& task_id,
bool is_script_running)
{
LL_DEBUGS() << "LSL Bytecode saved" << LL_ENDL;
mScriptEd->mErrorList->setCommentText(LLTrans::getString("CompileSuccessful"));
mScriptEd->mErrorList->setCommentText(LLTrans::getString("SaveComplete"));
// <FS> Append comment text
//mScriptEd->mErrorList->setCommentText(LLTrans::getString("CompileSuccessful"));
//mScriptEd->mErrorList->setCommentText(LLTrans::getString("SaveComplete"));
mScriptEd->mErrorList->addCommentText(LLTrans::getString("CompileSuccessful"));
mScriptEd->mErrorList->addCommentText(LLTrans::getString("SaveComplete"));
// </FS>
// [SL:KB] - Patch: Build-ScriptRecover | Checked: 2011-11-23 (Catznip-3.2.0) | Added: Catznip-3.2.0
// Script was successfully saved so delete our backup copy if we have one and the editor is still pristine
@ -2675,8 +2685,8 @@ void LLLiveLSLEditor::saveIfNeeded(bool sync /*= true*/)
// save the script
mScriptEd->enableSave(FALSE);
mScriptEd->mEditor->makePristine();
mScriptEd->mErrorList->deleteAllItems();
mScriptEd->mErrorList->setCommentText(std::string()); // ## Zi: Clear out comment overlay, too.
// <FS> FIRE-10172: Fix LSL editor error display
//mScriptEd->mErrorList->deleteAllItems();
// set up the save on the local machine.
mScriptEd->mEditor->makePristine();
@ -2850,6 +2860,8 @@ void LLLiveLSLEditor::uploadAssetLegacy(const std::string& filename,
void LLLiveLSLEditor::onSaveTextComplete(const LLUUID& asset_uuid, void* user_data, S32 status, LLExtStat ext_status) // StoreAssetData callback (fixed)
{
// <FS> Remove more legacy stuff -Sei
#if 0
LLLiveLSLSaveData* data = (LLLiveLSLSaveData*)user_data;
if (status)
@ -2878,11 +2890,14 @@ void LLLiveLSLEditor::onSaveTextComplete(const LLUUID& asset_uuid, void* user_da
}
delete data;
data = NULL;
#endif
}
void LLLiveLSLEditor::onSaveBytecodeComplete(const LLUUID& asset_uuid, void* user_data, S32 status, LLExtStat ext_status) // StoreAssetData callback (fixed)
{
// <FS> Remove more legacy stuff -Sei
#if 0
LLLiveLSLSaveData* data = (LLLiveLSLSaveData*)user_data;
if(!data)
return;
@ -2929,6 +2944,7 @@ void LLLiveLSLEditor::onSaveBytecodeComplete(const LLUUID& asset_uuid, void* use
std::string dst_filename = llformat("%s.lso", filepath.c_str());
LLFile::remove(dst_filename);
delete data;
#endif
}
BOOL LLLiveLSLEditor::canClose()