Index: src/Platform.cpp |
diff --git a/src/Platform.cpp b/src/Platform.cpp |
index 9369d0c78988445ea3869bbfd8e4ebe9dea6681d..ede0dca6b0af370648a1a9b3fb5e80c09431e745 100644 |
--- a/src/Platform.cpp |
+++ b/src/Platform.cpp |
@@ -72,32 +72,33 @@ void Platform::SetUpJsEngine(const AppInfo& appInfo) |
jsEngine = JsEngine::New(appInfo, *this); |
} |
-std::shared_ptr<JsEngine> Platform::GetJsEngine() |
+JsEngine& Platform::GetJsEngine() |
{ |
SetUpJsEngine(); |
- return jsEngine; |
+ return *jsEngine; |
} |
-void Platform::CreateFilterEngineAsync(const FilterEngine::CreationParameters& parameters, |
- const OnFilterEngineCreatedCallback& onCreated) |
-{ |
- std::shared_ptr<std::promise<FilterEnginePtr>> filterEnginePromise; |
- { |
+void Platform::CreateFilterEngineAsync(const FilterEngine::CreationParameters& parameters, |
+ const OnFilterEngineCreatedCallback& onCreated) |
+{ |
+ std::shared_ptr<std::promise<FilterEnginePtr>> filterEnginePromise; |
+ { |
std::lock_guard<std::mutex> lock(modulesMutex); |
if (filterEngine.valid()) |
return; |
filterEnginePromise = std::make_shared<std::promise<FilterEnginePtr>>(); |
- filterEngine = filterEnginePromise->get_future(); |
- } |
+ filterEngine = filterEnginePromise->get_future(); |
+ } |
- FilterEngine::CreateAsync(GetJsEngine(), [this, onCreated, filterEnginePromise](const FilterEnginePtr& filterEngine) |
- { |
+ GetJsEngine(); // ensures that JsEngine is instantiated |
+ FilterEngine::CreateAsync(jsEngine, [this, onCreated, filterEnginePromise](const FilterEnginePtr& filterEngine) |
+ { |
filterEnginePromise->set_value(filterEngine); |
- if (onCreated) |
- onCreated(filterEngine); |
- }, parameters); |
-} |
- |
+ if (onCreated) |
+ onCreated(filterEngine); |
+ }, parameters); |
+} |
+ |
FilterEnginePtr Platform::GetFilterEngine() |
{ |
CreateFilterEngineAsync(); |