godot/core/object
Ignacio Roldán Etcheverry cca26cc83f Fix ClassDB API type mismatch bug between --editor and player
There are two ways a class can be added to ClassDB:

- `A`: When an instance of the class is created for the first time. When
  this happends the class is not registered/exposed to scripts.
- `B`: When calling `GDREGISTER_CLASS(ClassName)` or similar. When this
  happens the class is registered/exposed to scripts.

ClassDB has an API type property to differentiate between the core
and editor APIs. Up until now the API type was determined whenever
the class is added to ClassDB (either `A` or `B`).

The problem comes when a class is instantiated (`A`) before
being registered (`B`).
If at this point the current defined API is not the same as when the
class is later registered, this will result in a mismatch between
`--editor` and non-editor apps.
This is specially bad for C# as it makes the editor player abort.

This was happening with `EditorPaths` which, while being registered
during the editor API classes registrations, it was also being
instantiated earlier when running the editor or the project manager,
via a call to `EditorPaths::create()`. This regression was introduced
in 1074017f04.

This commit fixes this simply by re-assigning the class API type when
the class is registered (`B`).
This is correct because API type describes registered/exposed classes.
It shouldn't cause any regressions as the API type should not be
accessed of classes that are not (or not yet) registered/exposed.

Code locations for reference:
- Method to add a class to ClassDB: `ClassDB::_add_class2`
- Code that adds classes to ClassDB post first initialization (`A`):
  `memnew` macros -> `Object::_postinitialize` ->
  `Object::initialize_class` -> `ClassDB::_add_class2`.
- Code adds class to ClassDB and registers/exposes it to scripts:
  `GDREGISTER_CLASS` macros -> `ClassDB::register_class<T>` ->
  `Object::initialize_class` -> `ClassDB::_add_class2`.
2021-08-31 22:35:32 +02:00
..
callable_method_pointer.cpp Update copyright statements to 2021 2021-01-01 20:19:21 +01:00
callable_method_pointer.h Core: Drop custom copymem/zeromem defines 2021-04-27 16:26:27 +02:00
class_db.cpp Fix capsule height/radius setters with linked properties 2021-08-19 10:31:19 -07:00
class_db.h Fix ClassDB API type mismatch bug between --editor and player 2021-08-31 22:35:32 +02:00
make_virtuals.py Properly set up virtual calls for extensions 2021-08-17 22:11:11 -03:00
message_queue.cpp Update copyright statements to 2021 2021-01-01 20:19:21 +01:00
message_queue.h Update copyright statements to 2021 2021-01-01 20:19:21 +01:00
method_bind.cpp Implement native extension system 2021-06-25 17:32:45 -03:00
method_bind.h Implement native extension system 2021-06-25 17:32:45 -03:00
object_id.h Rename Reference to RefCounted 2021-06-11 18:48:42 +02:00
object.cpp Fix C# native instance bindings after recent re-write 2021-08-16 17:16:36 +02:00
object.h Fix capsule height/radius setters with linked properties 2021-08-19 10:31:19 -07:00
ref_counted.cpp Redo how instance bindings work 2021-07-08 17:08:12 -03:00
ref_counted.h Implement native extension system 2021-06-25 17:32:45 -03:00
script_language.cpp Use const references where possible for List range iterators 2021-07-25 12:22:25 +02:00
script_language.h Implement didSave notification and rename request 2021-07-17 11:50:00 -04:00
SCsub Implement native extension system 2021-06-25 17:32:45 -03:00
undo_redo.cpp Improve Undo/Redo menu items 2021-08-17 21:11:10 +08:00
undo_redo.h Improve Undo/Redo menu items 2021-08-17 21:11:10 +08:00