diff options
Diffstat (limited to 'indra/newview/llsyntaxid.cpp')
| -rw-r--r-- | indra/newview/llsyntaxid.cpp | 66 |
1 files changed, 61 insertions, 5 deletions
diff --git a/indra/newview/llsyntaxid.cpp b/indra/newview/llsyntaxid.cpp index f89ae00c5b..16274f59bc 100644 --- a/indra/newview/llsyntaxid.cpp +++ b/indra/newview/llsyntaxid.cpp @@ -40,7 +40,8 @@ //----------------------------------------------------------------------------- const std::string SYNTAX_ID_CAPABILITY_NAME = "LSLSyntax"; const std::string SYNTAX_ID_SIMULATOR_FEATURE = "LSLSyntaxId"; -const std::string FILENAME_DEFAULT = "keywords_lsl_default.xml"; +const std::string FILENAME_DEFAULT_LSL = "keywords_lsl_default.xml"; +const std::string FILENAME_DEFAULT_LUA = "keywords_lua_default.xml"; /** * @brief LLSyntaxIdLSL constructor @@ -60,7 +61,7 @@ LLSyntaxIdLSL::LLSyntaxIdLSL() void LLSyntaxIdLSL::buildFullFileSpec() { ELLPath path = mSyntaxId.isNull() ? LL_PATH_APP_SETTINGS : LL_PATH_CACHE; - const std::string filename = mSyntaxId.isNull() ? FILENAME_DEFAULT : "keywords_lsl_" + mSyntaxId.asString() + ".llsd.xml"; + const std::string filename = mSyntaxId.isNull() ? FILENAME_DEFAULT_LSL : "keywords_lsl_" + mSyntaxId.asString() + ".llsd.xml"; mFullFileSpec = gDirUtilp->getExpandedFilename(path, filename); } @@ -147,9 +148,14 @@ void LLSyntaxIdLSL::fetchKeywordsFileCoro(std::string url, std::string fileSpec) if (isSupportedVersion(result)) { - setKeywordsXml(result); - cacheFile(fileSpec, result); - loadKeywordsIntoLLSD(); + // Shuttle this task to the main coro/worker. + // loadKeywordsIntoLLSD will attempt to get a mutex which is not coro aware. + LLAppViewer::instance()->postToMainCoro([this, result, fileSpec]() + { + setKeywordsXml(result); + cacheFile(fileSpec, result); + loadKeywordsIntoLLSD(); + }); } else { @@ -325,3 +331,53 @@ boost::signals2::connection LLSyntaxIdLSL::addSyntaxIDCallback(const syntax_id_c { return mSyntaxIDChangedSignal.connect(cb); } + + + +//----------------------------------------------------------------------------- +// LLSyntaxLua +//----------------------------------------------------------------------------- +LLSyntaxLua::LLSyntaxLua() + : mKeywordsXml(LLSD()) + , mInitialized(false) +{ +} + +void LLSyntaxLua::initialize() +{ + if (mInitialized) return; + + loadDefaultKeywordsIntoLLSD(); + loadLuaTypesIntoLLSD(); + mInitialized = true; +} + +void LLSyntaxLua::loadDefaultKeywordsIntoLLSD() +{ + std::string fullFileSpec = gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, FILENAME_DEFAULT_LUA); + llifstream file(fullFileSpec.c_str()); + + if (file.good()) + { + LLSD content; + if (LLSDSerialize::fromXML(content, file) != LLSDParser::PARSE_FAILURE) + { + mKeywordsXml = content; + } + } +} + +void LLSyntaxLua::loadLuaTypesIntoLLSD() +{ + std::string fullFileSpec = gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "types_lua_default.xml"); + llifstream file(fullFileSpec.c_str()); + + if (file.good()) + { + LLSD content; + if (LLSDSerialize::fromXML(content, file) != LLSDParser::PARSE_FAILURE) + { + mTypesXml = content; + } + } +} |
