diff --git a/DesktopEditor/doctrenderer/docbuilder_p.cpp b/DesktopEditor/doctrenderer/docbuilder_p.cpp index 6abc4f0684..c7ac57a225 100644 --- a/DesktopEditor/doctrenderer/docbuilder_p.cpp +++ b/DesktopEditor/doctrenderer/docbuilder_p.cpp @@ -203,21 +203,11 @@ std::string GetCorrectArgument(const std::string& sInput) return sResult; } -bool CV8RealTimeWorker::OpenFile(const std::wstring& sBasePath, const std::wstring& path, const std::string& sString, const std::wstring& sCachePath, CV8Params* pParams) +bool CV8RealTimeWorker::InitVariables() { - LOGGER_SPEED_START(); - CJSContextScope scope(m_context); JSSmart try_catch = m_context->GetExceptions(); - LOGGER_SPEED_LAP("compile"); - - m_context->runScript(sString, try_catch, sCachePath); - if(try_catch->Check()) - return false; - - LOGGER_SPEED_LAP("run"); - if (true) { std::string sArg = GetCorrectArgument(m_sUtf8ArgumentJSON); @@ -245,6 +235,26 @@ bool CV8RealTimeWorker::OpenFile(const std::wstring& sBasePath, const std::wstri if (try_catch->Check()) return false; } + return true; +} + +bool CV8RealTimeWorker::OpenFile(const std::wstring& sBasePath, const std::wstring& path, const std::string& sString, const std::wstring& sCachePath, CV8Params* pParams) +{ + LOGGER_SPEED_START(); + + CJSContextScope scope(m_context); + JSSmart try_catch = m_context->GetExceptions(); + + LOGGER_SPEED_LAP("compile"); + + m_context->runScript(sString, try_catch, sCachePath); + if(try_catch->Check()) + return false; + + LOGGER_SPEED_LAP("run"); + + if (!InitVariables()) + return false; NSNativeControl::CNativeControl* pNative = NULL; bool bIsBreak = false; diff --git a/DesktopEditor/doctrenderer/docbuilder_p.h b/DesktopEditor/doctrenderer/docbuilder_p.h index c33fa298d4..f4cb3affb0 100644 --- a/DesktopEditor/doctrenderer/docbuilder_p.h +++ b/DesktopEditor/doctrenderer/docbuilder_p.h @@ -427,6 +427,7 @@ public: bool OpenFile(const std::wstring& sBasePath, const std::wstring& path, const std::string& sString, const std::wstring& sCachePath, CV8Params* pParams = NULL); bool SaveFileWithChanges(int type, const std::wstring& _path, const std::wstring& sJsonParams = L""); + bool InitVariables(); }; namespace NSDoctRenderer @@ -1291,7 +1292,11 @@ namespace NSDoctRenderer Init(); - CheckWorker(); + bool bRes = CheckWorker(); + + if (!bRes && m_pWorker && m_bJavascriptBeforeEditor) + m_pWorker->InitVariables(); + return m_pWorker->ExecuteCommand(command, retValue); }