Commit Graph

601 Commits

Author SHA1 Message Date
Rémi Verschelde 306dd5be3f
Merge pull request #87758 from dsnopek/gdextension-register-virtual-method
Allow GDExtensions to register virtual methods and call them on scripts
2024-02-12 23:29:37 +01:00
David Snopek be11002e41 Allow GDExtensions to register virtual methods and call them on scripts 2024-02-12 13:29:18 -06:00
Thaddeus Crews b3cac9c092
Allow Ref `instantiate` to accept constructor args 2024-02-10 13:19:14 -06:00
Rémi Verschelde 1774c17b64
Merge pull request #87625 from YuriSizov/editor-lightweight-script-previews
Generate script resource preview without parsing
2024-02-09 12:34:36 +01:00
Rémi Verschelde 63d6bda8e9
Merge pull request #87871 from vittorioromeo/use_v_shorthand
Use `_v` shorthand for type traits and `if constexpr` where appropriate
2024-02-05 15:00:23 +01:00
EterDelta fee70558f8 Expose NOTIFICATION_EXTENSION_RELOADED to ClassDB 2024-02-02 14:57:00 -05:00
vittorioromeo 55ed34e37c Use '_v' shorthand for type traits and 'if constexpr' where appropriate 2024-02-02 15:43:21 +01:00
A Thousand Ships 15369fdb1d
Remove unnecessary `this->` expressions 2024-01-29 09:59:18 +01:00
Yuri Sizov 9c919ea285 Generate script resource preview without parsing 2024-01-26 19:04:10 +01:00
Yuri Sizov 412f5b3422 Merge pull request #87353 from OverloadedOrama/max-undo-steps
Implement maximum undo steps in UndoRedo
2024-01-24 14:08:25 +01:00
Emmanouil Papadeas c73bfd5d81 Implement maximum undo steps in UndoRedo 2024-01-22 21:38:10 +02:00
Rémi Verschelde 266ae93291
Merge pull request #87331 from KoBeWi/you_can_ref_count_on_that
Simplify RefCounted check in `free()`
2024-01-18 16:35:38 +01:00
Rémi Verschelde baf87e2717
Merge pull request #87294 from vnen/allow-free-callable
Allow `free()` to be used as Callable
2024-01-18 16:35:14 +01:00
George Marques b4e08eb752
Allow `free()` to be used as Callable
This method is registered in a special way so ClassDB doesn't naturally
know about its existence. Here it is hardcoded if any other option fail
to check if it is about the `free()` method and, if so, say it exists
and return a Callable.
2024-01-18 09:33:44 -03:00
kobewi 2de8bc00a1 Simplify RefCounted check in free() 2024-01-18 12:29:58 +01:00
Rémi Verschelde fa81059b9d
Merge pull request #85939 from adamscott/single-threaded-godot-4
Add `THREADS_ENABLED` macro in order to compile Godot to run on the main thread
2024-01-18 09:33:52 +01:00
Adam Scott bd70b8e1f6
Add THREADS_ENABLED macro in order to compile Godot to run on the main thread 2024-01-17 13:58:29 -05:00
Yuri Sizov c027aecc2e Merge pull request #86676 from rune-scape/sparse-script-reload
GDScript: Hot-reload changed scripts only
2024-01-17 18:52:54 +01:00
Pedro J. Estébanez a04a67ead6 Fix inaccuracies in the report of leaked objects 2024-01-15 19:35:14 +01:00
Rémi Verschelde dc79e956b6
Merge pull request #86587 from RandomShaper/wtp_enhance
Enhance & fix `WorkerThreadPool`
2024-01-11 17:38:09 +01:00
Pedro J. Estébanez a731774813 WorkerThreadPool: Avoid most runtime allocations
Just a little optimization.

**NOTE:**
With `RID_Owner` we could replace each pair of `PagedAllocator` and
`HashMap`-of-ids-to-pointers. However, that would force us to expose
`RID` as the task/group id, instead of `int`, which would break the
API. Too bad. Let's wait until Godot 5.0.
2024-01-08 12:46:31 +01:00
Pedro J. Estébanez ae418f9469 WorkerThreadPool: Avoid deadlocks when CommandQueueMT is involved
This commit lets CommandQueueMT play nicely with the WorkerThreadPool to avoid
non-progressable situations caused by an interdependence between both. While a
command queue is being flushed, it allows the WTP to release its lock while tasks
are being awaited so they can make progress in case they need in turn to post
to the command queue.
2024-01-08 12:45:43 +01:00
Pedro J. Estébanez 9444d297ed WorkerThreadPool: Overhaul scheduling and synchronization
This commits rewrites the sync logic in a way that the
`use_system_threads_for_low_priority_tasks` setting, which was added due to
the lack of a cross-platform wait-for-multiple-objects functionality, can be
removed (it's as if it was effectively hardcoded to `false`).

With the new implementation, we have the best of both worlds: threads don't
have to poll, plus no bespoke threads are used.

In addition, regarding deadlock prevention, since not every possible case of
wait-deadlock could be avoided, this commits removes the current best-effort
avoidance mechanisms and keeps only a simple, pessimistic way of detection.

It turns out that the only current user of deadlock prevention, ResourceLoader,
works fine with it and so every possible situation in resource loading is now
properly handled, with no possibilities of deadlocking. There's a comment in
the code with further details.

Lastly, a potential for load tasks never being awaited/disposed is cleared.
2024-01-08 12:45:42 +01:00
Muller-Castro 96a95cb974 Add const lvalue ref to container parameters 2024-01-05 14:49:57 -03:00
rune-scape cde478bda6 Hot-reload only changed scripts 2024-01-02 17:56:52 -08:00
Rémi Verschelde 3dae50aa4f
Merge pull request #86520 from touilleMan/fix-ScriptLanguageExtension-_find_function-documentation
Fix `ScriptLanguageExtension::_find_function` documentation
2024-01-02 18:05:26 +01:00
Rémi Verschelde 35d1ffb8de
Merge pull request #86259 from TitanNano/jovan/fix_MethodInfo_eq
Include `name` field in MethodInfo operator ==
2024-01-02 15:09:02 +01:00
Emmanuel Leblond 0124b513cd
Fix `ScriptLanguageExtension::_find_function` documentation 2023-12-26 14:05:53 +01:00
msreis f1cc14d525 Fix missing time for some script functions in profiler
Fixes the issue by adding a mechanism by which the functions that were
previously disappearing can be profiled too. This is optional with
an editor setting, since collecting more information naturally slows the engine
further while profiling.

Fixes #23715, #40251, #29049
2023-12-19 19:42:21 +01:00
Alfonso J. Ramos e7e35e8366 Expose `Script.get_global_name()` 2023-12-18 15:13:09 +01:00
Jovan Gerodetti 179c92eb0b Include name field in MethodInfo operator == 2023-12-17 12:42:14 +01:00
Wilson E. Alvarez 80fb8db31f
Remove unnecessary assignments
Co-authored-by: A Thousand Ships <96648715+AThousandShips@users.noreply.github.com>
2023-12-13 11:06:26 -05:00
Rémi Verschelde 41365c6c8b
Merge pull request #70315 from RandomShaper/d3d12_mesa
Direct3D 12 Rendering Driver (Mesa NIR approach)
2023-12-12 21:58:57 +01:00
Yuri Sizov f16057522e Merge pull request #85770 from Repiteo/make-virtuals-refactor-and-fix
Refactor and fix `make_virtuals.py`
2023-12-08 16:58:44 +01:00
Thaddeus Crews c9a4086da6
Fix EncodeT assignment in make_virtuals.py
• Adding EncodeT type casting allows generated code to support enum classes.
2023-12-05 10:37:04 -06:00
Thaddeus Crews ceb6dadf4e
Refactor make_virtuals.py
Output reformatted to be comparable to clang-formatted code, without compromising readability
2023-12-05 10:37:03 -06:00
Rémi Verschelde 75d7aab015
Merge pull request #85486 from paulloz/fix/property-groups-shadowing
Fix property groups overriding real properties
2023-12-05 13:05:28 +01:00
Pedro J. Estébanez cba15cd625 Add WorkerThreadPool::get_thread_index() 2023-12-01 16:42:26 +01:00
Paul Joannon decf3b21ae
Fix property groups overriding real properties 2023-11-28 21:34:18 +01:00
A Thousand Ships d10617bb3b [Core] Prevent infinite recursion when printing errors 2023-11-26 18:53:28 +01:00
bruvzg eb81e8b2dc
Prevent read-after-free in the queued CallableCustomStaticMethodPointer. 2023-11-23 23:22:08 +02:00
Pedro J. Estébanez fe4850c0d0 Use mingw-std-threads in MinGW builds 2023-11-18 11:56:05 +01:00
Rémi Verschelde a28476d1cd
Merge pull request #84847 from RandomShaper/lang_init_term
Let languages init & finish run without locks held
2023-11-14 19:31:37 +01:00
Pedro J. Estébanez f05f8c399e Let languages init & finish run without locks held 2023-11-13 16:06:48 +01:00
kobewi 4296f0a771 Fill remaining global scope constant descriptions 2023-11-13 15:17:10 +01:00
Sofox 4006397339 Reduced output spam from rapid property changes 2023-11-12 14:49:51 +00:00
Rémi Verschelde 96fa86f9a0
Merge pull request #84557 from TheSofox/undo-history-sync-fix
Fix for stopping the Undo History being desynchronised from actual Undo queue
2023-11-10 21:55:46 +01:00
Sofox 662522ae5a Fix for stopping the Undo History being desynchronised from actual Undo queue. 2023-11-10 13:04:12 +00:00
Rémi Verschelde 19db9308ff
Merge pull request #84657 from RandomShaper/lang_srv_threading
Make languages bookkeeping thread-safe
2023-11-09 18:09:01 +01:00
Pedro J. Estébanez f3e96a8548 Make languages bookkeeping thread-safe 2023-11-09 18:03:43 +01:00
Rémi Verschelde ce53362f98
Merge pull request #83670 from raulsntos/notification-predelete-cleanup
Add `NOTIFICATION_PREDELETE_CLEANUP` notification to fix C# `Dispose()`
2023-11-09 11:45:49 +01:00
Pedro J. Estébanez a1d8fc1af9 Polish & fix editor help cache generation
- Isolated the generation of extensions's docs. They're now not cached and refreshed as needed.
- Removed superfluous sorting of the class list.
- Removed some superfluous/unused elements.
- Renamed some items for clarity.
2023-11-02 13:46:37 +01:00
Rémi Verschelde bc5d5978ea
Merge pull request #83695 from YuriSizov/core-lock-and-key
Improve threading in ClassDB and EditorHelp
2023-10-24 10:54:19 +02:00
Rémi Verschelde 792afd2cad
Merge pull request #83588 from voidedWarranties/fix_sle_validate
Add `path` option to `ScriptLanguageExtension::_validate`
2023-10-24 10:54:11 +02:00
voidedWarranties e8309dd192 Add `path` option to `ScriptLanguageExtension::_validate` 2023-10-22 21:49:34 -07:00
Yuri Sizov 9b03fb36f9 Improve threading in ClassDB and EditorHelp 2023-10-20 22:14:04 +02:00
Raul Santos 9750e49c57
Add `NOTIFICATION_PREDELETE_CLEANUP` notification
New notification sent after `NOTIFICATION_PREDELETE` to let Objects cleanup at the very end, it should be the last notification sent.
2023-10-20 13:43:42 +02:00
anrp 4c33c60500 Allow coexistance of GDScript and GDExtension virtual methods in the same object
Resolves https://github.com/godotengine/godot-cpp/issues/1224
2023-10-19 10:21:26 -04:00
pancelor d66b1752b8 Fix tilemap live editing while game is running 2023-10-14 18:54:03 -07:00
Rémi Verschelde 71a8ac41fb
Merge pull request #72751 from dalexeev/doc-comment-color
Highlight doc comments in a different color
2023-10-09 23:21:54 +02:00
Rémi Verschelde a1d7c62df7
Merge pull request #83003 from AThousandShips/null_check_extra
Replace `ERR_FAIL_COND` with `ERR_FAIL_NULL` where applicable
2023-10-09 15:37:14 +02:00
Rémi Verschelde 336260b7b3
Merge pull request #83002 from AThousandShips/safety_check
Replace `sanity` with `safety` for checks
2023-10-09 15:36:49 +02:00
Danil Alexeev de7cbe8789
Highlight doc comments in a different color 2023-10-08 19:26:10 +03:00
A Thousand Ships f18aa00e85 Replace `ERR_FAIL_COND` with `ERR_FAIL_NULL` where applicable 2023-10-08 17:23:33 +02:00
A Thousand Ships 034c0f1624 Replace `sanity` with `safety` for checks 2023-10-08 16:22:24 +02:00
Mai Lavelle 5e15586ec2 Fixes to allow object-less callables throughout Godot
This fixes #81887
2023-10-06 16:31:35 -04:00
kobewi 09b30be86d Add vararg call() method to C++ Callable 2023-10-05 11:35:29 +02:00
Rémi Verschelde c7ed5d795e
Merge pull request #82799 from CedNaru/feature/expose_free_instance_binding
Expose `Object::free_instance_binding()` to GDExtension
2023-10-05 10:10:58 +02:00
Ced Naru 0a246e9b54 expose Object::free_instance_binding to GDExtension 2023-10-04 19:24:37 +02:00
Danil Alexeev ed0b3c08e1
Core: Fix `Object::has_method()` for script static methods 2023-10-04 19:44:32 +03:00
Rémi Verschelde dbd4c79c38
Merge pull request #82682 from dsnopek/gdextension-dont-deprecate-script-category
GDExtension: Don't deprecate old method of getting script category
2023-10-03 17:26:41 +02:00
David Snopek cbf939e121 GDExtension: Don't deprecate old method of getting script category 2023-10-02 09:23:27 -05:00
Danil Alexeev aff767ef07
Fix expected argument count for `Callable` call errors 2023-09-29 20:00:10 +03:00
David Cambré 531f56e830 add GDExtensionScriptInstanceGetClassCategory
Change GetClassCategory so it is handled in native directly
2023-09-27 17:45:48 +02:00
Rémi Verschelde 017541bcec
Merge pull request #80527 from raulsntos/dotnet/generate-compat-methods-from-classdb
C#: Generate and use compat methods
2023-09-26 13:44:52 +02:00
Rémi Verschelde 7e67b496ff
Merge pull request #82332 from Sauermann/fix-struct-type
Fix type of `notification_func`
2023-09-26 08:32:15 +02:00
Rémi Verschelde 55dfbd7761
Merge pull request #80284 from dsnopek/gdextension-hot-reload
Implement reloading of GDExtensions
2023-09-26 08:17:28 +02:00
David Snopek 2733a6f762 Implement reloading of GDExtensions 2023-09-25 22:10:17 -05:00
Markus Sauermann d2bcde0407 Fix type of notification_func 2023-09-25 23:37:13 +02:00
Rémi Verschelde e4cfd4e26a
Merge pull request #82195 from AThousandShips/radian_fix
Replace `radians` range hint with `radians_as_degrees`
2023-09-25 17:18:38 +02:00
Rémi Verschelde d759f91f8d
Merge pull request #81101 from 398utubzyt/dotnet/abstract-class-support
C#: Add abstract class support
2023-09-25 17:18:05 +02:00
Rémi Verschelde 1a0e653d7f
Merge pull request #78573 from dalexeev/editor-create-script-class-name
Editor: Remove unused Class Name field from Create Script dialog
2023-09-25 17:17:46 +02:00
A Thousand Ships e45927b2f2 Replace `radians` range hint with `radians_as_degrees` 2023-09-25 08:50:19 +02:00
Rémi Verschelde 6fc1d50db3
Merge pull request #81521 from dsnopek/method-bind-default-argument-hash-fix
Fix method hashes with default arguments
2023-09-22 22:03:30 +02:00
David Snopek 0d13727c97 Fix method hashes with default arguments 2023-09-21 12:39:04 -05:00
Jeff Ward 60851af4da Add functions for non-ptr style virtual calls in GDExtension
This adds two functions to `GDExtensionClassCreationInfo` that allow for developers to supply a generic virtual call function along with user data to be sent to that call.

If `get_virutal_call_data_func` is not null, extensions call this function to get user data to pass to a supplied `call_virtual_with_data_func`. Both must be provided is one is provided.

If `get_virtual_call_data_func` is null, Godot falls back to the old `get_virtual_func` logic.

Fixes #63275

Co-authored-by: David Snopek <dsnopek@gmail.com>
2023-09-19 22:33:32 -04:00
Raul Santos 5f6082a96b
C#: Generate and use compat methods
- Implements `ClassDB::get_method_list_with_compatibility` to retrieve all methods from a class including compat methods.
- C# bindings generator now also generates compat methods.
- All generated C# methods now use `ClassDB::get_method_with_compatibility`.
2023-09-19 20:35:11 +02:00
398utubzyt 2df37a237a C#: Abstract script class support 2023-09-15 20:35:25 -07:00
Danil Alexeev 26ce861910
Editor: Remove unused Class Name field from Create Script dialog 2023-09-12 12:49:56 +03:00
A Thousand Ships 893f889d74 [Core] Replace `ERR_FAIL_COND` with `ERR_FAIL_NULL` where applicable 2023-09-11 19:45:49 +02:00
Rémi Verschelde 43c7e8d3b5
Merge pull request #81515 from dsnopek/gdextension-validate-property-object
Allow implementing `Object::_validate_property()` from GDExtension
2023-09-11 15:40:05 +02:00
Rémi Verschelde 786dab42fd
Merge pull request #70329 from Daylily-Zeleen/daylily-zeleen/register_internal_class
Allow GDExtension to register unexposed classes.
2023-09-11 15:35:31 +02:00
David Snopek abef8e3874 Allow implementing `Object::_validate_property()` from GDExtension 2023-09-10 11:17:59 -05:00
Rémi Verschelde 7663c69922
Merge pull request #81388 from YuriSizov/core-gdvirtual-but-less-confused-about-itself
Extract `ScriptInstance` into its own file to simplify includes
2023-09-07 13:53:45 +02:00
Rémi Verschelde d013fc3f03
Merge pull request #81304 from ajreckof/Change-precedence-in-rules-to-make-location-after-proper-casing-
Change precedence in rules to make location after proper casing.
2023-09-07 13:52:08 +02:00
Rémi Verschelde d1c94eef06
Merge pull request #81261 from dsnopek/gdextension-validate-property
Allow implementing `ScriptInstance::validate_property()` from GDExtension
2023-09-07 13:51:44 +02:00
Yuri Sizov d8ff69d53c Extract ScriptInstance to simplify includes
This allows to include script_instance.h directly in the
generated gdvirtual.gen.inc, and remove excessive includes
from the codebase.

This should also allow Resource to use GDVIRTUAL macros,
which wasn't possible previously due to a circular dependency.
2023-09-06 22:54:38 +02:00
ajreckof 19632eaf50 Change precedence in rules to make location after proper casing. 2023-09-05 16:16:21 +02:00
David Snopek 3e7a6e058a Allow implementing `ScriptInstance::validate_property()` from GDExtension 2023-09-04 13:55:48 -05:00
Rémi Verschelde dd4fae6162
Merge pull request #74809 from Chaosus/completion_color_xyzw
Add coloring for completion of vector components
2023-09-04 09:06:57 +02:00
Daylily-Zeleen 41ffe5461f Allow GDExtension to register unexposed class. 2023-09-04 10:18:20 +08:00
Rémi Verschelde fa3428ff25
Merge pull request #81221 from dalexeev/editor-inspector-and-signal-dock-improvements
Editor: Inspector and Signal docks improvements
2023-09-03 00:21:04 +02:00
Jan Haller 4e202bcec7 GDExtension: fix `bool` unknown in C 2023-09-02 21:04:49 +02:00
Danil Alexeev c33ca26e17
Editor: Inspector and Signal docks improvements 2023-09-02 08:50:28 +03:00
David Snopek 83faf84ec9 GDExtension: Allocate `GDExtensionScriptInstanceInfo2` for compatibility on the heap to prevent crash 2023-08-31 15:19:31 -05:00
Yuri Rubinsky 35802374ac Add coloring for completion of vector components 2023-08-30 21:13:25 +03:00
Markus Sauermann c4705a590b Fix Object::notification order
Previously the `p_reversed` parameter didn't influence the order
in a correct way.
Also script overridden _notification functions were not called in
the correct order.

To fix this some `notification` functions had to add a `p_reversed`
parameter.

This made it necessary to adjust cpp-bindings.

Co-authored-by: David Snopek <dsnopek@gmail.com>
2023-08-30 00:15:55 +02:00
Rémi Verschelde 7e083e53c3
Merge pull request #81020 from AThousandShips/object_register_fix
Add check to ensure registered classes are declared
2023-08-29 12:45:33 +02:00
Rémi Verschelde 76d318dbd1
Merge pull request #75778 from KoBeWi/_vp
Expose `_validate_property()` for scripting
2023-08-29 12:41:27 +02:00
Rémi Verschelde 91c5273ec5
Merge pull request #75656 from YuriSizov/core-iconic-builtins
Add a script method to get its class icon
2023-08-29 12:41:03 +02:00
kobewi 67db4693eb Expose _validate_property() for scripting 2023-08-28 15:18:48 +02:00
A Thousand Ships c638238fae Add check to ensure registered classes are declared
Checks that all classes registered to `ClassDB` have been properly
declared with `GDCLASS`
2023-08-28 12:16:49 +02:00
Yuri Sizov 2c77f07aaa Add a script method to get its class icon
Co-authored-by: Danil Alexeev <danil@alexeev.xyz>
2023-08-24 13:05:41 +02:00
Ricardo Buring acf9d4e4de Fix GDExtension classes derived from abstract GDExtension classes always being registered as abstract 2023-08-22 09:53:03 +02:00
clayjohn fcc6c6a697 Revert "Let user know about dead instances in deferred calls"
This reverts commit 3a6527d6d3.
2023-07-31 10:45:20 +02:00
Pedro J. Estébanez f34d580861 Revert "Implement parallel foreach() for easier multithreading"
This reverts commit e28868e30c.
2023-07-27 13:41:27 +02:00
Yuri Sizov a68137bf18 Merge pull request #79683 from Zylann/fix_gdext_get_property_list
GDExtension: Fix `_get_property_list` not working correctly in parent classes
2023-07-26 18:40:18 +02:00
Yuri Sizov 2c8cbcd1a0 Merge pull request #78987 from RandomShaper/err_bad_deferred_target
Let user know about dead instances in deferred calls
2023-07-26 18:39:38 +02:00
Yuri Sizov 92960b7a22 Merge pull request #78615 from RandomShaper/fix_doc_cache
Re-enable docs cache with fixes
2023-07-26 18:39:22 +02:00
Yuri Sizov 53ba9ccb19 Merge pull request #72346 from myaaaaaaaaa/disconnect-order
Avoid sorting CallableCustomMethodPointers by their actual address values
2023-07-26 18:39:08 +02:00
rune-scape 83b01708b2 Script editor: Show depended script errors 2023-07-24 15:49:39 +02:00
Gilles Roudière b4d86cb42a Add _get_bind_compatibility_methods to Object
Co-authored-by: RedworkDE <10944644+RedworkDE@users.noreply.github.com>
2023-07-20 12:55:00 +02:00
Marc Gilleron e8731f4821 GDExtension: fix _get_property_list not working correctly in parent classes 2023-07-20 02:24:04 +01:00
Yuri Sizov acd34153ba Merge pull request #78612 from RandomShaper/mq_flush_ref
Refactor CallQueue flushing for clarity
2023-07-14 18:49:08 +02:00
Yuri Sizov 2a595c26d9 Merge pull request #72784 from myaaaaaaaaa/parallel-foreach
Implement parallel `foreach()` for easier multithreading
2023-07-14 18:48:49 +02:00
Angad Kambli 9c6c2f09e0
Check parameter validity in `Object::set_script`
Fixes #46120.
2023-07-07 16:13:33 +02:00
Rémi Verschelde 862a2841c0
Merge pull request #78845 from RandomShaper/fix_wtp_zero_batch_lazy
Fix zero-sized WorkerThreadPool not processing group tasks
2023-07-07 08:27:43 +02:00
Pedro J. Estébanez cac4d44cde Re-enable docs cache with fixes 2023-07-05 10:44:58 +02:00
Pedro J. Estébanez 3a6527d6d3 Let user know about dead instances in deferred calls 2023-07-03 17:57:49 +02:00
Pedro J. Estébanez 30925fcfb0 Fix management of safe-for-nodes flag in ResourceLoader and WorkerThreadPool 2023-07-03 12:27:57 +02:00
Pedro J. Estébanez 28d0d56a69 Fix zero-sized WorkerThreadPool not processing group tasks 2023-06-29 19:44:42 +02:00
Valery Zhuk 818cee6184 add explicit default initialization for flag in undo redo operation 2023-06-28 21:57:47 +03:00
Pedro J. Estébanez c85beb8106 Refactor CallQueue flushing for clarity 2023-06-23 13:27:34 +02:00
Ryan Roden-Corrent 731a13a1ba
Fix race in ScriptServer.
Fixes #76581.

TSAN flagged this issue on starting the editor:

1. main calls register_core_types, which calls IP::create(), which calls Thread::start on the resolver thread
2. Thread::callback calls ScriptServer::thread_enter(), as "Scripts may need to attach a stack."
3. ScriptServer::thread_enter() accesses ScriptServer::_languages, which is still being initialized on the main thread by initialize_gdscript_module

This fixes the issue by skipping thread enter/exit notifications if languages have not finished initializing yet.
I'm assuming that notifying un-initialized languages of thread starts/stops would have been pointless anyways. If we need to somehow notify languages of threads before the languages initialize, we'll need a different solution.

```
Godot Engine v4.0.2.stable.custom_build.7a0977ce2 - https://godotengine.org
==================
WARNING: ThreadSanitizer: data race (pid=9426)
  Write of size 4 at 0x55615b187cd0 by main thread:
    #0 ScriptServer::register_language(ScriptLanguage*) /home/rcorre/src/godot/godot/core/object/script_language.cpp:177:28 (godot.linuxbsd.editor.x86_64.llvm.san+0x9e52ab9) (BuildId: 780a9db7c37d88e78d5ee659c4fa1cd378abd048)
    #1 initialize_gdscript_module(ModuleInitializationLevel) /home/rcorre/src/godot/godot/modules/gdscript/register_types.cpp:118:3 (godot.linuxbsd.editor.x86_64.llvm.san+0x36f9c6f) (BuildId: 780a9db7c37d88e78d5ee659c4fa1cd378abd048)
    #2 initialize_modules(ModuleInitializationLevel) /home/rcorre/src/godot/godot/modules/register_module_types.gen.cpp:93:2 (godot.linuxbsd.editor.x86_64.llvm.san+0x2f50499) (BuildId: 780a9db7c37d88e78d5ee659c4fa1cd378abd048)
    #3 Main::setup2(unsigned long) /home/rcorre/src/godot/godot/main/main.cpp:1961:2 (godot.linuxbsd.editor.x86_64.llvm.san+0x2f1d40d) (BuildId: 780a9db7c37d88e78d5ee659c4fa1cd378abd048)
    #4 Main::setup(char const*, int, char**, bool) /home/rcorre/src/godot/godot/main/main.cpp:1879:10 (godot.linuxbsd.editor.x86_64.llvm.san+0x2f16370) (BuildId: 780a9db7c37d88e78d5ee659c4fa1cd378abd048)
    #5 main /home/rcorre/src/godot/godot/platform/linuxbsd/godot_linuxbsd.cpp:61:14 (godot.linuxbsd.editor.x86_64.llvm.san+0x2e67e1f) (BuildId: 780a9db7c37d88e78d5ee659c4fa1cd378abd048)

  Previous read of size 4 at 0x55615b187cd0 by thread T1:
    #0 ScriptServer::thread_enter() /home/rcorre/src/godot/godot/core/object/script_language.cpp:244:22 (godot.linuxbsd.editor.x86_64.llvm.san+0x9e54aed) (BuildId: 780a9db7c37d88e78d5ee659c4fa1cd378abd048)
    #1 Thread::callback(unsigned long, Thread::Settings const&, void (*)(void*), void*) /home/rcorre/src/godot/godot/core/os/thread.cpp:61:2 (godot.linuxbsd.editor.x86_64.llvm.san+0x9464ab0) (BuildId: 780a9db7c37d88e78d5ee659c4fa1cd378abd048)
    #2 void std::__invoke_impl<void, void (*)(unsigned long, Thread::Settings const&, void (*)(void*), void*), unsigned long, Thread::Settings, void (*)(void*), void*>(std::__invoke_other, void (*&&)(unsigned long, Thread::Settings const&, void (*)(void*), void*), unsigned long&&, Thread::Settings&&, void (*&&)(void*), void*&&) /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/12.2.1/../../../../include/c++/12.2.1/bits/invoke.h:61:14 (godot.linuxbsd.editor.x86_64.llvm.san+0x9465283) (BuildId: 780a9db7c37d88e78d5ee659c4fa1cd378abd048)
    #3 std::__invoke_result<void (*)(unsigned long, Thread::Settings const&, void (*)(void*), void*), unsigned long, Thread::Settings, void (*)(void*), void*>::type std::__invoke<void (*)(unsigned long, Thread::Settings const&, void (*)(void*), void*), unsigned long, Thread::Settings, void (*)(void*), void*>(void (*&&)(unsigned long, Thread::Settings const&, void (*)(void*), void*), unsigned long&&, Thread::Settings&&, void (*&&)(void*), void*&&) /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/12.2.1/../../../../include/c++/12.2.1/bits/invoke.h:96:14 (godot.linuxbsd.editor.x86_64.llvm.san+0x9465283)
    #4 void std:🧵:_Invoker<std::tuple<void (*)(unsigned long, Thread::Settings const&, void (*)(void*), void*), unsigned long, Thread::Settings, void (*)(void*), void*>>::_M_invoke<0ul, 1ul, 2ul, 3ul, 4ul>(std::_Index_tuple<0ul, 1ul, 2ul, 3ul, 4ul>) /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/12.2.1/../../../../include/c++/12.2.1/bits/std_thread.h:258:13 (godot.linuxbsd.editor.x86_64.llvm.san+0x9465283)
    #5 std:🧵:_Invoker<std::tuple<void (*)(unsigned long, Thread::Settings const&, void (*)(void*), void*), unsigned long, Thread::Settings, void (*)(void*), void*>>::operator()() /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/12.2.1/../../../../include/c++/12.2.1/bits/std_thread.h:265:11 (godot.linuxbsd.editor.x86_64.llvm.san+0x9465283)
    #6 std:🧵:_State_impl<std:🧵:_Invoker<std::tuple<void (*)(unsigned long, Thread::Settings const&, void (*)(void*), void*), unsigned long, Thread::Settings, void (*)(void*), void*>>>::_M_run() /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/12.2.1/../../../../include/c++/12.2.1/bits/std_thread.h:210:13 (godot.linuxbsd.editor.x86_64.llvm.san+0x9465283)
    #7 execute_native_thread_routine /usr/src/debug/gcc/gcc/libstdc++-v3/src/c++11/thread.cc:82:18 (libstdc++.so.6+0xd72c2) (BuildId: 6fe66a2d539a78c993bd2d377e00fad389220963)

  Location is global 'ScriptServer::_language_count' of size 4 at 0x55615b187cd0 (godot.linuxbsd.editor.x86_64.llvm.san+0xbf46cd0)

  Thread T1 (tid=9431, running) created by main thread at:
    #0 pthread_create <null> (godot.linuxbsd.editor.x86_64.llvm.san+0x2de5776) (BuildId: 780a9db7c37d88e78d5ee659c4fa1cd378abd048)
    #1 __gthread_create /usr/src/debug/gcc/gcc-build/x86_64-pc-linux-gnu/libstdc++-v3/include/x86_64-pc-linux-gnu/bits/gthr-default.h:663:35 (libstdc++.so.6+0xd73a9) (BuildId: 6fe66a2d539a78c993bd2d377e00fad389220963)
    #2 std:🧵:_M_start_thread(std::unique_ptr<std:🧵:_State, std::default_delete<std:🧵:_State>>, void (*)()) /usr/src/debug/gcc/gcc/libstdc++-v3/src/c++11/thread.cc:147:37 (libstdc++.so.6+0xd73a9)
    #3 IP::IP() /home/rcorre/src/godot/godot/core/io/ip.cpp:347:19 (godot.linuxbsd.editor.x86_64.llvm.san+0x962cbcd) (BuildId: 780a9db7c37d88e78d5ee659c4fa1cd378abd048)
    #4 IPUnix::IPUnix() /home/rcorre/src/godot/godot/drivers/unix/ip_unix.cpp:261:9 (godot.linuxbsd.editor.x86_64.llvm.san+0x4aee599) (BuildId: 780a9db7c37d88e78d5ee659c4fa1cd378abd048)
    #5 IPUnix::_create_unix() /home/rcorre/src/godot/godot/drivers/unix/ip_unix.cpp:258:9 (godot.linuxbsd.editor.x86_64.llvm.san+0x4aee599)
    #6 IP::create() /home/rcorre/src/godot/godot/core/io/ip.cpp:339:9 (godot.linuxbsd.editor.x86_64.llvm.san+0x962ca5e) (BuildId: 780a9db7c37d88e78d5ee659c4fa1cd378abd048)
    #7 register_core_types() /home/rcorre/src/godot/godot/core/register_core_types.cpp:279:7 (godot.linuxbsd.editor.x86_64.llvm.san+0x93e2333) (BuildId: 780a9db7c37d88e78d5ee659c4fa1cd378abd048)
    #8 Main::setup(char const*, int, char**, bool) /home/rcorre/src/godot/godot/main/main.cpp:690:2 (godot.linuxbsd.editor.x86_64.llvm.san+0x2f08a49) (BuildId: 780a9db7c37d88e78d5ee659c4fa1cd378abd048)
    #9 main /home/rcorre/src/godot/godot/platform/linuxbsd/godot_linuxbsd.cpp:61:14 (godot.linuxbsd.editor.x86_64.llvm.san+0x2e67e1f) (BuildId: 780a9db7c37d88e78d5ee659c4fa1cd378abd048)

SUMMARY: ThreadSanitizer: data race /home/rcorre/src/godot/godot/core/object/script_language.cpp:177:28 in ScriptServer::register_language(ScriptLanguage*)
```

Co-authored-by: Pedro J. Estébanez <RandomShaper@users.noreply.github.com>
2023-06-21 09:52:10 -04:00
Yuri Sizov 329652b6fe
Merge pull request #78392 from Gallilus/master
Fix `Ref<>.is_valid()` for ScriptInstanceExtension
2023-06-20 21:19:20 +02:00
David Cambré ceed30c442 Fix Ref<>.is_valid() for ScriptInstanceExtension
Only check the reference not the value.
2023-06-20 19:45:47 +02:00
myaaaaaaaaa 5cc961627d Avoid sorting CallableCustomMethodPointers by their actual address values 2023-06-20 08:40:01 -04:00
Rémi Verschelde c9c941e339
CI: Update static checks to black 23.3.0
And apply it to the codebase, removing empty lines at the start of blocks.
2023-06-19 23:33:02 +02:00
fuzzy@home 09fa22002a fixes #76473, where filling a large amount of tiles all at once crashes
the engine due to segmentation fault.
2023-06-18 22:32:23 +09:00
ajreckof e9a2060b27 Fix wrong alphabetical order in autocompletion sorting.
Co-Authored-By: A Thousand Ships <96648715+AThousandShips@users.noreply.github.com>
2023-06-16 14:04:07 +02:00
Rémi Verschelde 8c5c29f2a3
Merge pull request #78061 from dsnopek/gdextension-class-not-exposed
Fix wrapping Object's in GDExtension that aren't exposed
2023-06-15 10:50:27 +02:00
ajreckof 81aa5ad999 add backward_undo_ops as property for action 2023-06-13 15:32:05 +02:00
Rémi Verschelde 37d1dfef9d
Merge pull request #78000 from RandomShaper/let_users_mess_up
Let user scripts disable thread safety checks
2023-06-10 12:12:13 +02:00
David Snopek 36f4b99638 Fix wrapping Object's in GDExtension that aren't exposed 2023-06-09 13:41:57 -05:00
Pedro J. Estébanez 2b001db76e Let user scripts disable thread safety checks 2023-06-09 18:24:01 +02:00
myaaaaaaaaa e28868e30c Implement parallel foreach() for easier multithreading 2023-06-09 08:27:32 -04:00
Rémi Verschelde 577ab3c565
Merge pull request #75746 from ajreckof/order_autocomplete
Sort code autocompletion with rules
2023-06-08 18:14:31 +02:00
Rémi Verschelde aa5dfff3f0
Merge pull request #77410 from dsnopek/object-pointer-pointer-encoding
Standardize Object ptrcall encoding on `Object **`
2023-06-07 13:31:49 +02:00
Yuri Sizov 97a6b40e4e
Merge pull request #70386 from sfrembling/70141
Add Human Readable Error Message for Object::set_meta
2023-05-29 17:24:25 +02:00
David Snopek 77733faede Attempt to standardize Object ptrcall encoding on `Object **` 2023-05-25 21:46:22 -05:00