diff --git a/editor/js/state.js b/editor/js/state.js
index 9e36c27a5eea4ba9c0b554faa72374fa4cc4cdc5..553509df6f4643160c0b1bd30c0cfb08dd79a10d 100644
--- a/editor/js/state.js
+++ b/editor/js/state.js
@@ -34,13 +34,17 @@ class State extends Tool {
             return;
         }
 
-        this.tool.onToolDeactivate(tool);
+        if (this.tool !== undefined) {
+            this.tool.onToolDeactivate(tool);
+        }
 
         this.previousTool = this.tool;
         this.tool = tool;
         this.display.setSelectedTool(tool);
 
-        this.tool.onToolActivate();
+        if (this.tool !== undefined) {
+            this.tool.onToolActivate();
+        }
     }
 
     setSelectedItem(item) {