changeset 1620:1151e25d7311

Unregistering emscripten wheel and key events in the ViewerViewport destructor, to prevent callbacks being executed after the object has been deleted.
author Benjamin Golinvaux <bgo@osimis.io>
date Mon, 02 Nov 2020 17:56:49 +0100
parents 4c9e68291467
children 575f512cdf48
files Applications/StoneWebViewer/WebAssembly/StoneWebViewer.cpp
diffstat 1 files changed, 7 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/Applications/StoneWebViewer/WebAssembly/StoneWebViewer.cpp	Mon Nov 02 17:55:35 2020 +0100
+++ b/Applications/StoneWebViewer/WebAssembly/StoneWebViewer.cpp	Mon Nov 02 17:56:49 2020 +0100
@@ -1738,6 +1738,13 @@
       }*/
   }
 
+  ~ViewerViewport()
+  {
+    emscripten_set_wheel_callback(viewport_->GetCanvasCssSelector().c_str(), this, true, NULL);
+    emscripten_set_keydown_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, this, false, NULL);
+    emscripten_set_keyup_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, this, false, NULL);
+  }
+
   static EM_BOOL OnKey(int eventType,
                        const EmscriptenKeyboardEvent *event,
                        void *userData)