changeset 1687:cc5a2e076746

Added error check to emscripten_get_element_css_size
author Benjamin Golinvaux <bgo@osimis.io>
date Wed, 25 Nov 2020 17:02:43 +0100
parents 7896aac14587
children c14dd6e11ddd
files Applications/Platforms/WebAssembly/WebAssemblyViewport.cpp
diffstat 1 files changed, 9 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/Applications/Platforms/WebAssembly/WebAssemblyViewport.cpp	Wed Nov 25 12:16:53 2020 +0100
+++ b/Applications/Platforms/WebAssembly/WebAssemblyViewport.cpp	Wed Nov 25 17:02:43 2020 +0100
@@ -420,8 +420,15 @@
 
   void WebAssemblyViewport::RefreshCanvasSize()
   {
-    double w, h;
-    emscripten_get_element_css_size(GetCanvasCssSelector().c_str(), &w, &h);
+    double w = -1, h = -1;
+    EMSCRIPTEN_RESULT result = 
+      emscripten_get_element_css_size(GetCanvasCssSelector().c_str(), &w, &h);
+
+    if (result != EMSCRIPTEN_RESULT_SUCCESS)
+    {
+      LOG(WARNING) << "WebAssemblyViewport::RefreshCanvasSize failed to "
+        << "retrieve CSS size for " << GetCanvasCssSelector();
+    }
 
     /**
      * Emscripten has the function emscripten_get_element_css_size()