wasm: improve the specialHtmlTargets test
It can actually be undefined, so test for that before checking the object type. This fixes the asyncify build. Change-Id: I5a6a0bc60c153290c35c20242400c59cd1312403 Reviewed-by: Aleksandr Reviakin <aleksandr.reviakin@qt.io> Reviewed-by: Lorn Potter <lorn.potter@gmail.com> (cherry picked from commit 492b338f570afce3fbadb518bb0b9ab7fdf67e03) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
00d8c8114f
commit
c320b61424
@ -172,10 +172,14 @@ std::string QWasmScreen::canvasSpecialHtmlTargetId() const
|
||||
bool QWasmScreen::hasSpecialHtmlTargets() const
|
||||
{
|
||||
static bool gotIt = []{
|
||||
// specialHTMLTargets is a JavaScript Array if available. Note that it is
|
||||
// an abort() function if not, so a simple isUndefined() test won't work here.
|
||||
return emscripten::val::module_property("specialHTMLTargets")
|
||||
["constructor"]["name"].as<std::string>() == std::string("Array");
|
||||
// Enable use of specialHTMLTargets, if available
|
||||
emscripten::val htmlTargets = emscripten::val::module_property("specialHTMLTargets");
|
||||
if (htmlTargets.isUndefined())
|
||||
return false;
|
||||
|
||||
// Check that the object has the expected type - it can also be
|
||||
// defined as an abort() function which prints an error on usage.
|
||||
return htmlTargets["constructor"]["name"].as<std::string>() == std::string("Array");
|
||||
}();
|
||||
return gotIt;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user