[NativeScript] fix double initialization in editor
This commit is contained in:
parent
3f1e75e89c
commit
cdf1212bee
|
@ -958,7 +958,8 @@ void NativeReloadNode::_notification(int p_what) {
|
||||||
switch (p_what) {
|
switch (p_what) {
|
||||||
case MainLoop::NOTIFICATION_WM_FOCUS_OUT: {
|
case MainLoop::NOTIFICATION_WM_FOCUS_OUT: {
|
||||||
|
|
||||||
print_line("unload");
|
if (unloaded)
|
||||||
|
break;
|
||||||
|
|
||||||
NSL->_unload_stuff();
|
NSL->_unload_stuff();
|
||||||
for (Map<String, Ref<GDNative> >::Element *L = NSL->library_gdnatives.front(); L; L = L->next()) {
|
for (Map<String, Ref<GDNative> >::Element *L = NSL->library_gdnatives.front(); L; L = L->next()) {
|
||||||
|
@ -967,11 +968,14 @@ void NativeReloadNode::_notification(int p_what) {
|
||||||
NSL->library_classes.erase(L->key());
|
NSL->library_classes.erase(L->key());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unloaded = true;
|
||||||
|
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case MainLoop::NOTIFICATION_WM_FOCUS_IN: {
|
case MainLoop::NOTIFICATION_WM_FOCUS_IN: {
|
||||||
|
|
||||||
print_line("load");
|
if (!unloaded)
|
||||||
|
break;
|
||||||
|
|
||||||
Set<StringName> libs_to_remove;
|
Set<StringName> libs_to_remove;
|
||||||
|
|
||||||
|
@ -1010,6 +1014,8 @@ void NativeReloadNode::_notification(int p_what) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unloaded = false;
|
||||||
|
|
||||||
for (Set<StringName>::Element *R = libs_to_remove.front(); R; R = R->next()) {
|
for (Set<StringName>::Element *R = libs_to_remove.front(); R; R = R->next()) {
|
||||||
NSL->library_gdnatives.erase(R->get());
|
NSL->library_gdnatives.erase(R->get());
|
||||||
}
|
}
|
||||||
|
|
|
@ -259,6 +259,8 @@ inline NativeScriptDesc *NativeScript::get_script_desc() const {
|
||||||
|
|
||||||
class NativeReloadNode : public Node {
|
class NativeReloadNode : public Node {
|
||||||
GDCLASS(NativeReloadNode, Node)
|
GDCLASS(NativeReloadNode, Node)
|
||||||
|
bool unloaded = false;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static void _bind_methods();
|
static void _bind_methods();
|
||||||
void _notification(int p_what);
|
void _notification(int p_what);
|
||||||
|
|
Loading…
Reference in a new issue