From bdac806e49c277de23ffda8bceede0bf1fee5f67 Mon Sep 17 00:00:00 2001 From: jsteemann Date: Mon, 22 May 2017 15:57:08 +0200 Subject: [PATCH] slightly optimize context destruction --- lib/ApplicationFeatures/V8PlatformFeature.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/ApplicationFeatures/V8PlatformFeature.cpp b/lib/ApplicationFeatures/V8PlatformFeature.cpp index 778324677b..910e5468a6 100644 --- a/lib/ApplicationFeatures/V8PlatformFeature.cpp +++ b/lib/ApplicationFeatures/V8PlatformFeature.cpp @@ -176,13 +176,19 @@ v8::Isolate* V8PlatformFeature::createIsolate() { isolate->AddGCEpilogueCallback(gcEpilogueCallback); auto data = std::make_unique(); + isolate->SetData(V8_INFO, data.get()); { MUTEX_LOCKER(guard, _lock); - _isolateData.emplace(isolate, std::move(data)); + try { + _isolateData.emplace(isolate, std::move(data)); + } catch (...) { + isolate->SetData(V8_INFO, nullptr); + isolate->Dispose(); + throw; + } } - isolate->SetData(V8_INFO, _isolateData.back().get()); return isolate; }