Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#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)

misc.xml.patch (671 bytes ) - added by AlThePhoenix 9 years ago.
Basically the exact same patch used in #2971. Credit goes to leper.
misc.xml_camera.xml.patch (1.3 KB ) - added by AlThePhoenix 9 years ago.
Different approach using only one line, credit goes to elexis. Changes the fix for #2971 as well for uniformity.
t3496_misc.xml_camera.xml_selection.js.patch (1.9 KB ) - added by AlThePhoenix 9 years ago.
Created a new function in selection.js which returns the first entity in the selection. Adjusted camera.xml and misc.xml accordingly.

Download all attachments as: .zip

Change History (7)

by AlThePhoenix, 9 years ago

Attachment: misc.xml.patch added

Basically the exact same patch used in #2971. Credit goes to leper.

comment:1 by Stan, 9 years ago

Component: Core engineUI & Simulation
Keywords: patch review added; warning removed
Milestone: BacklogAlpha 20
Summary: Pressing Delete when nothing is selected throws a warning[PATCH] Pressing Delete when nothing is selected throws a warning

by AlThePhoenix, 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 mimo, 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 AlThePhoenix, 9 years ago

Created a new function in selection.js which returns the first entity in the selection. Adjusted camera.xml and misc.xml accordingly.

comment:3 by mimo, 9 years ago

Owner: set to mimo
Resolution: fixed
Status: newclosed

In 17114:

fix JS undefined property warning, patch by Evulant (AlThePhoenix), fixes #3496

comment:4 by mimo, 9 years ago

Keywords: review removed
Milestone: Alpha 20Alpha 19

Thanks for the patch

Note: See TracTickets for help on using tickets.