From 4514d8c5c3bd5e16ba8d84214ecd164cd0740864 Mon Sep 17 00:00:00 2001 From: Ima Mechanique Date: Thu, 6 Feb 2014 16:48:22 +0000 Subject: Refactoring to better check state of loading and to allow clearing of highlighting if we don't have a valid keywords file. --- indra/newview/llpreviewscript.cpp | 71 +++++++++++++++++++++++++-------------- 1 file changed, 46 insertions(+), 25 deletions(-) (limited to 'indra/newview/llpreviewscript.cpp') 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 primary_keywords; - std::vector 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 primary_keywords; + std::vector 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::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::const_iterator iter= primary_keywords.begin(); - iter!= primary_keywords.end(); ++iter) - { - mFunctions->add(*iter); - } - for (std::vector::const_iterator iter= secondary_keywords.begin(); - iter!= secondary_keywords.end(); ++iter) - { - mFunctions->add(*iter); + for (std::vector::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() -- cgit v1.2.3