diff options
author | Ima Mechanique <ima.mechanique@secondlife.com> | 2014-02-06 16:48:22 +0000 |
---|---|---|
committer | Ima Mechanique <ima.mechanique@secondlife.com> | 2014-02-06 16:48:22 +0000 |
commit | 4514d8c5c3bd5e16ba8d84214ecd164cd0740864 (patch) | |
tree | cf1164d17acede8c7cdfa1d2a711ca3fca5e60ab | |
parent | 00a99d9097131c02c6486112b32e57f534bf61be (diff) |
Refactoring to better check state of loading and to allow clearing of highlighting if we don't have a valid keywords file.
-rwxr-xr-x | indra/newview/llpreviewscript.cpp | 71 |
1 files changed, 46 insertions, 25 deletions
diff --git a/indra/newview/llpreviewscript.cpp b/indra/newview/llpreviewscript.cpp index 979074b453..904b56b436 100755 --- a/indra/newview/llpreviewscript.cpp +++ b/indra/newview/llpreviewscript.cpp @@ -417,45 +417,66 @@ BOOL LLScriptEdCore::postBuild() void LLScriptEdCore::onRegionChangeInitialiseKeywords() { - mEditor->mKeywords.clearLoaded(); + LL_DEBUGS("SyntaxLSL") << "Pre Initialise!" << LL_ENDL; mSyntaxIdLSL.initialise(); + LL_DEBUGS("SyntaxLSL") << "Post Initialise!" << LL_ENDL; + // Nasty Hack to get started, needs to replaced with a callback or similar. + if (mSyntaxIdLSL.fetching()) + { + LL_WARNS("SyntaxLSL") << "No Response in Time, still fetching!" << LL_ENDL; + } - if (mSyntaxIdLSL.isLoaded()) + if (mSyntaxIdLSL.isDifferentVersion()) { - mEditor->mKeywords.initialise(mSyntaxIdLSL.getKeywordsXML()); + LL_INFOS("SyntaxLSL") + << "Hashes are different, updating highlighter." << LL_ENDL; - mEditor->loadKeywords(); + mEditor->mKeywords.clearLoaded(); + mEditor->clearSegments(); + mEditor->mKeywords.clear(); - std::vector<std::string> primary_keywords; - std::vector<std::string> secondary_keywords; - LLKeywordToken *token; - LLKeywords::keyword_iterator_t token_it; - for (token_it = mEditor->keywordsBegin(); token_it != mEditor->keywordsEnd(); ++token_it) + if (mSyntaxIdLSL.isLoaded()) { - token = token_it->second; - if (token->getType() == LLKeywordToken::TT_FUNCTION) + mEditor->mKeywords.initialise(mSyntaxIdLSL.getKeywordsXML()); + + mEditor->loadKeywords(); + + std::vector<std::string> primary_keywords; + std::vector<std::string> secondary_keywords; + LLKeywordToken *token; + LLKeywords::keyword_iterator_t token_it; + for (token_it = mEditor->keywordsBegin(); token_it != mEditor->keywordsEnd(); ++token_it) { - primary_keywords.push_back( wstring_to_utf8str(token->getToken()) ); + token = token_it->second; + if (token->getType() == LLKeywordToken::TT_FUNCTION) + { + primary_keywords.push_back( wstring_to_utf8str(token->getToken()) ); + } + else + { + secondary_keywords.push_back( wstring_to_utf8str(token->getToken()) ); + } } - else + + for (std::vector<std::string>::const_iterator iter= primary_keywords.begin(); + iter!= primary_keywords.end(); ++iter) { - secondary_keywords.push_back( wstring_to_utf8str(token->getToken()) ); + mFunctions->add(*iter); } - } - - for (std::vector<std::string>::const_iterator iter= primary_keywords.begin(); - iter!= primary_keywords.end(); ++iter) - { - mFunctions->add(*iter); - } - for (std::vector<std::string>::const_iterator iter= secondary_keywords.begin(); - iter!= secondary_keywords.end(); ++iter) - { - mFunctions->add(*iter); + for (std::vector<std::string>::const_iterator iter= secondary_keywords.begin(); + iter!= secondary_keywords.end(); ++iter) + { + mFunctions->add(*iter); + } } } + else + { + LL_INFOS("SyntaxLSL") + << "Hashes are the same, no need to update highlighter." << LL_ENDL; + } } void LLScriptEdCore::initMenu() |