You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
godot-cpp compiled without a part of all classes existing in Godot can lead to errors and crashes #1163
As I described in my comment, if I build godot-cpp without part of the classes, for example, ignore building of FontVariation and trying to call this code:
Control *c = memnew(Control);
(Object::cast_to<SceneTree>(Engine::get_singleton()->get_main_loop())->get_root())->add_child(c);
_font = c->get_theme_default_font();
c->queue_free();
get_theme_default_font will output an error even if I don't need to cast the obtained Ref<Font> to Ref<FontVariation>.
Example output:
ERROR: Cannot find instance binding callbacks for class 'FontVariation'.
at: (src\core\class_db.cpp:321)
ERROR: Cannot find instance binding callbacks for class 'Timer'.
at: (src\core\class_db.cpp:321)
ERROR: Cannot find instance binding callbacks for class 'Panel'.
at: (src\core\class_db.cpp:321)
ERROR: Cannot find instance binding callbacks for class 'HBoxContainer'.
at: (src\core\class_db.cpp:321)
ERROR: Cannot find instance binding callbacks for class 'MenuBar'.
at: (src\core\class_db.cpp:321)
ERROR: Cannot find instance binding callbacks for class 'HBoxContainer'.
at: (src\core\class_db.cpp:321)
ERROR: Cannot find instance binding callbacks for class 'HBoxContainer'.
at: (src\core\class_db.cpp:321)
...
Also, for some reason, calling a signal with an argument whose class is not in the library results in nullptr.
For example, a method is called here that connects to the draw signal of the SubViewportContainer class and gets the same SubViewportContainer as an argument, causes Control *ci to be nullptr.
If I build a library with all classes, then everything is fine. If I apply my patch and ignore most of the classes, then it results in nullptr.
As I understand it, the errors themselves do not affect the functioning of the library, but at the same time nullptr appears in the arguments from somewhere.
I haven't had a chance to do much testing, but draft PR #1165 should help with the error spam.
It's possible it could help with the crash too, but I'm not exactly sure what's causing the crash. When we return nullptr, it should fallback on wrapping in Object, which isn't correct, but I wouldn't have expected it to crash.
Activity
dsnopek commentedon Jul 7, 2023
I haven't had a chance to do much testing, but draft PR #1165 should help with the error spam.
It's possible it could help with the crash too, but I'm not exactly sure what's causing the crash. When we return
nullptr, it should fallback on wrapping inObject, which isn't correct, but I wouldn't have expected it to crash.DmitriySalnikov commentedon Jul 7, 2023
I tried debugging it, and it seemed to me that the main magic is happening, somewhere here
godot-cpp/include/godot_cpp/core/binder_common.hpp
Lines 236 to 240 in d627942
Because up to this point and getting inside the
_on_canvas_item_drawmethod, the pointer to theSubViewportContainerwas notnullptr.