Merge pull request #77757 from aaronfranke/fix-spinbox-remove-crash

Fix crash when removing SpinBox during text submit
This commit is contained in:
Rémi Verschelde 2023-06-05 13:42:50 +02:00
commit d7a0170971
No known key found for this signature in database
GPG Key ID: C3336907360768E1
5 changed files with 13 additions and 4 deletions

View File

@ -115,7 +115,7 @@
Returns the drag data from the GUI, that was previously returned by [method Control._get_drag_data].
</description>
</method>
<method name="gui_get_focus_owner">
<method name="gui_get_focus_owner" qualifiers="const">
<return type="Control" />
<description>
Returns the [Control] having the focus within this viewport. If no [Control] has the focus, returns null.

View File

@ -6,6 +6,14 @@ should instead be used to justify these changes and describe how users should wo
========================================================================================================================
GH-77757
--------
Validate extension JSON: Error: Field 'classes/Viewport/methods/gui_get_focus_owner': is_const changed value in new API, from false to true.
Validate extension JSON: Error: Hash changed for 'classes/Viewport/methods/gui_get_focus_owner', from 31757941 to A5E188F5. This means that the function has changed and no compatibility function was provided.
This method does not affect the state of Viewport so it should be const.
GH-74736
--------
Validate extension JSON: Error: Field 'classes/MenuBar/properties/start_index': type changed value in new API, from "bool" to "int".

View File

@ -202,7 +202,8 @@ void SpinBox::_line_edit_focus_enter() {
void SpinBox::_line_edit_focus_exit() {
// Discontinue because the focus_exit was caused by left-clicking the arrows.
if (get_viewport()->gui_get_focus_owner() == get_line_edit()) {
const Viewport *viewport = get_viewport();
if (!viewport || viewport->gui_get_focus_owner() == get_line_edit()) {
return;
}
// Discontinue because the focus_exit was caused by right-click context menu.

View File

@ -3156,7 +3156,7 @@ void Viewport::gui_release_focus() {
}
}
Control *Viewport::gui_get_focus_owner() {
Control *Viewport::gui_get_focus_owner() const {
ERR_READ_THREAD_GUARD_V(nullptr);
return gui.key_focus;
}

View File

@ -599,7 +599,7 @@ public:
int gui_get_canvas_sort_index();
void gui_release_focus();
Control *gui_get_focus_owner();
Control *gui_get_focus_owner() const;
PackedStringArray get_configuration_warnings() const override;