#3496 closed defect (fixed)
[PATCH] Pressing Delete when nothing is selected throws a warning
Reported by: | AlThePhoenix | Owned by: | mimo |
---|---|---|---|
Priority: | If Time Permits | Milestone: | Alpha 19 |
Component: | UI & Simulation | Keywords: | patch |
Cc: | Patch: |
Description
Related to #2971
Start a game and the first thing you do is pressing delete.
WARNING: JavaScript warning: __internal(32) press line 0 reference to undefined property g_Selection.toList(...)[0]
Attachments (3)
Change History (7)
by , 9 years ago
Attachment: | misc.xml.patch added |
---|
comment:1 by , 9 years ago
Component: | Core engine → UI & Simulation |
---|---|
Keywords: | patch review added; warning removed |
Milestone: | Backlog → Alpha 20 |
Summary: | Pressing Delete when nothing is selected throws a warning → [PATCH] Pressing Delete when nothing is selected throws a warning |
by , 9 years ago
Attachment: | misc.xml_camera.xml.patch added |
---|
Different approach using only one line, credit goes to elexis. Changes the fix for #2971 as well for uniformity.
comment:2 by , 9 years ago
In fact, toList creates a temporary array from the selection object. That's a waste of resources (even if very small) when we are only interested in the first entry. So a more cleaner fix could be to add a new function getFirstSelected in selection.js which would return either the first entry (using toList way) or undefined if none. Iirc there are also a few other places in the gui where such a function could be used (when we only need the first selected or just want to be sure the selection is not empty).
by , 9 years ago
Attachment: | t3496_misc.xml_camera.xml_selection.js.patch added |
---|
Created a new function in selection.js which returns the first entity in the selection. Adjusted camera.xml and misc.xml accordingly.
comment:4 by , 9 years ago
Keywords: | review removed |
---|---|
Milestone: | Alpha 20 → Alpha 19 |
Thanks for the patch
Basically the exact same patch used in #2971. Credit goes to leper.