virtualx-engine/core
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
..
config Rename iterations_per_second to physics_ticks_per_second 2021-08-11 02:37:02 +02:00
crypto [Crypto] Delete mbedtls ctx in deconstructor. 2021-07-03 16:12:55 +02:00
debugger Use doubles for time in many other places 2021-08-09 14:05:42 -05:00
error Add error_string function 2021-04-27 22:02:35 +02:00
extension Properly set up virtual calls for extensions 2021-08-17 22:11:11 -03:00
input Fix input methods returning zero strength when pressed status not requested 2021-08-16 00:53:01 -04:00
io [Net] MultiplayerReplicator with initial state. 2021-08-18 10:21:29 +01:00
math Merge pull request #51368 from TwistedTwigleg/GSOC_2020_Working_Branch_IK_SQUASHED 2021-08-16 15:37:17 +02:00
object Fix ClassDB API type mismatch bug between --editor and player 2021-08-31 22:35:32 +02:00
os Add partial support for Android scoped storage. 2021-08-16 23:11:56 -07:00
string String: Fix default decimals truncation in num and num_real 2021-08-18 00:48:03 +02:00
templates Add the possibility to initialize the classes allocated with the PagedAllocator 2021-08-14 09:04:31 +02:00
variant Merge pull request #51902 from vnen/variant-internal-constructor 2021-08-20 08:10:38 +02:00
core_bind.cpp Merge pull request #51627 from mhilbrunner/todo-for-neikeq 2021-08-18 20:13:50 +02:00
core_bind.h Namespaces instead of underscore prefix for binds 2021-08-17 16:10:09 +02:00
core_builders.py Update AUTHORS and DONORS list 2020-08-14 00:06:51 +02:00
core_constants.cpp Use Key enum instead of plain integers 2021-08-10 16:26:55 -05:00
core_constants.h Update copyright statements to 2021 2021-01-01 20:19:21 +01:00
core_string_names.cpp Removed _change_notify 2021-02-10 19:31:24 -03:00
core_string_names.h Removed _change_notify 2021-02-10 19:31:24 -03:00
doc_data.cpp Update copyright statements to 2021 2021-01-01 20:19:21 +01:00
doc_data.h Add theme item descriptions to the online documentation 2021-08-04 22:27:10 +03:00
register_core_types.cpp Merge pull request #51627 from mhilbrunner/todo-for-neikeq 2021-08-18 20:13:50 +02:00
register_core_types.h Implement native extension system 2021-06-25 17:32:45 -03:00
SCsub Implement native extension system 2021-06-25 17:32:45 -03:00
typedefs.h Implement the ability to disable classes 2021-07-13 09:25:14 -03:00
version.h Update copyright statements to 2021 2021-01-01 20:19:21 +01:00