From e8a4e766efc3ea9efeb3dedee1493ca9b9d0fbc9 Mon Sep 17 00:00:00 2001 From: Andrew Dunai Date: Thu, 22 Sep 2022 13:52:05 +0300 Subject: [PATCH] Fix "!script_data is true" when updating placeholder scripts for GDNative libraries Co-authored-by: geekrelief (cherry picked from commit 1af4ba04cd5c85c6e26aff711a471ac3c57e6022) --- modules/gdnative/nativescript/nativescript.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/modules/gdnative/nativescript/nativescript.cpp b/modules/gdnative/nativescript/nativescript.cpp index 5afa4b74801..e1630ab3e03 100644 --- a/modules/gdnative/nativescript/nativescript.cpp +++ b/modules/gdnative/nativescript/nativescript.cpp @@ -1757,6 +1757,15 @@ void NativeReloadNode::_notification(int p_what) { } for (Map>::Element *U = NSL->library_script_users.front(); U; U = U->next()) { + // Multiple GDNative libraries may be reloaded. The library and script + // path should match to prevent failing `NSL->library_classes` lookup + // from `get_script_desc()` in `script->_update_placeholder` below. + // This check also prevents "!script_data is true" error from occuring + // when e. g. re-focusing editor window. + if (L->key() != U->key()) { + continue; + } + for (Set::Element *S = U->get().front(); S; S = S->next()) { NativeScript *script = S->get();