wasm: improve the specialHtmlTargets test
It can actually be undefined, so test for that before checking the object type. This fixes the asyncify build. Pick-to: 6.4 Change-Id: I5a6a0bc60c153290c35c20242400c59cd1312403 Reviewed-by: Aleksandr Reviakin <aleksandr.reviakin@qt.io> Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
This commit is contained in:
parent
45de3fedba
commit
492b338f57
@ -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