Commit graph

167 commits

Author SHA1 Message Date
Pedro J. Estébanez
4e4b1d7568 Fix potential crash when listing leaked objects
Note:
Casting to the C++ classes and calling the methods there would work as well,
but would require including he header files for the specific object types handled
here, which wouldn't be OK either.
2020-06-10 20:44:11 +02:00
Rémi Verschelde
2b5545270a Core: Add hints to run with --verbose when leaking nodes/resources at exit 2020-06-08 16:48:21 +02:00
Rémi Verschelde
85220fec01 Style: Remove unnecessary semicolons from core
Semicolons are not necessary after function definitions or control flow
blocks, and having some code use them makes things inconsistent (and
occasionally can mess up `clang-format`'s formatting).

Removing them is tedious work though, I had to do this manually (regex
+ manual review) as I couldn't find a tool for that. All other code
folders would need to get the same treatment.
2020-05-19 15:57:56 +02:00
Rémi Verschelde
0ee0fa42e6 Style: Enforce braces around if blocks and loops
Using clang-tidy's `readability-braces-around-statements`.
https://clang.llvm.org/extra/clang-tidy/checks/readability-braces-around-statements.html
2020-05-14 21:57:34 +02:00
Rémi Verschelde
07bc4e2f96 Style: Enforce separation line between function definitions
I couldn't find a tool that enforces it, so I went the manual route:
```
find -name "thirdparty" -prune \
  -o -name "*.cpp" -o -name "*.h" -o -name "*.m" -o -name "*.mm" \
  -o -name "*.glsl" > files
perl -0777 -pi -e 's/\n}\n([^#])/\n}\n\n\1/g' $(cat files)
misc/scripts/fix_style.sh -c
```

This adds a newline after all `}` on the first column, unless they
are followed by `#` (typically `#endif`). This leads to having lots
of places with two lines between function/class definitions, but
clang-format then fixes it as we enforce max one line of separation.

This doesn't fix potential occurrences of function definitions which
are indented (e.g. for a helper class defined in a .cpp), but it's
better than nothing. Also can't be made to run easily on CI/hooks so
we'll have to be careful with new code.

Part of #33027.
2020-05-14 16:54:55 +02:00
Rémi Verschelde
0be6d925dc Style: clang-format: Disable KeepEmptyLinesAtTheStartOfBlocks
Which means that reduz' beloved style which we all became used to
will now be changed automatically to remove the first empty line.

This makes us lean closer to 1TBS (the one true brace style) instead
of hybridating it with some Allman-inspired spacing.

There's still the case of braces around single-statement blocks that
needs to be addressed (but clang-format can't help with that, but
clang-tidy may if we agree about it).

Part of #33027.
2020-05-14 16:54:55 +02:00
Rémi Verschelde
1f6f364a56 Port member initialization from constructor to declaration (C++11)
Using `clang-tidy`'s `modernize-use-default-member-init` check and
manual review of the changes, and some extra manual changes that
`clang-tidy` failed to do.

Also went manually through all of `core` to find occurrences that
`clang-tidy` couldn't handle, especially all initializations done
in a constructor without using initializer lists.
2020-05-14 10:01:56 +02:00
Rémi Verschelde
e956e80c1f Style: clang-format: Disable AllowShortIfStatementsOnASingleLine
Part of #33027, also discussed in #29848.

Enforcing the use of brackets even on single line statements would be
preferred, but `clang-format` doesn't have this functionality yet.
2020-05-10 13:12:16 +02:00
lupoDharkael
95a1400a2a Replace NULL with nullptr 2020-04-02 13:38:00 +02:00
PouleyKetchoupp
258d91f883 Added has_signal method for Object 2020-03-23 11:27:17 +01:00
Rémi Verschelde
fe1dfb5fb7
Merge pull request #36481 from nekomatata/fix-crash-connect-callable
Fixed crash when connecting a signal in GDScript
2020-02-25 13:26:08 +01:00
PouleyKetchoupp
a5505ce643 Fixed crash when connecting a signal in GDScript 2020-02-23 10:06:13 +01:00
Juan Linietsky
3c0059650d Added StringName as a variant type.
Also changed all relevant properties defined manually to StringName.
2020-02-21 14:25:29 +01:00
Juan Linietsky
69c95f4b4c Reworked signal connection system, added support for Callable and Signal objects and made them default. 2020-02-20 08:24:50 +01:00
nathanwfranke
a31bc1b0ba Fix two signal errors
Update
2020-02-19 15:22:34 -06:00
Juan Linietsky
3205a92ad8 PoolVector is gone, replaced by Vector
Typed `PoolTypeArray` types are now renamed `PackedTypeArray` and are
sugar for `Vector<Type>`.
2020-02-18 10:10:36 +01:00
Juan Linietsky
867d073b98 Changed logic and optimized ObjectID in ObjectDB and Variant, removed RefPtr. 2020-02-15 08:36:04 -03:00
Juan Linietsky
cf8c679a23 ObjectID converted to a structure, fixes many bugs where used incorrectly as 32 bits. 2020-02-12 14:24:54 -03:00
Marcel Admiraal
5af3b4ca27 Remove duplicate ERR_PRINT macro. 2020-02-05 11:13:24 +01:00
Fabio Alessandrelli
41f59ecfca Make sure we know when deleting an emitting object
We used a lock signals in the signal_map while emitting, because it was
not allowed to disconnect them while being emitted.
We used that lock to check if we where deleting an object during signal
emission.
Now that we allow to disconnect signals while they are being emitted, if
an object first disconnects, then gets deleted we can't know that a
signal was being emitted during the destructor.

This commit adds a new `_emitting` boolean member to Object to be set
while emitting and checked in the destructor, while removing the old
signal lock which is now unused.
2020-01-22 14:08:16 +01:00
Rémi Verschelde
0aeb5bbf62 Object: Avoid error on emit_signal with freed target
As advised by @reduz.
2020-01-13 22:20:18 +01:00
Rémi Verschelde
f38bfccf42 Object: Remove error on disconnect of locked signals
According to 22637beb2e (commitcomment-36651823)
and as confirmed by @reduz, this seems not to be necessary now that we
copy-on-write.

This triggered freeze scenarios in cases where a node would be deleted
while being used as a target in a signal emission.

Fixes #34650.
Fixes #34769.

Now those two errors go back to reporting:
```
ERROR: emit_signal: Condition ' !target ' is true. Continuing..:
   At: core/object.cpp:1191.
```
2020-01-13 17:03:02 +01:00
Rémi Verschelde
a97b08e7d2
Merge pull request #34745 from timothyqiu/vararg-return-nil-34743
Allows to doc vararg method return type as void
2020-01-02 15:20:58 +01:00
Rémi Verschelde
e772a1241a Object::disconnect: Better errors when no signal or locked
It will now give information about the originating object instance
and when locked, the target callback.

This should help debugging editor and game issues that are now being
reported due to adding signal locking in
22637beb2e.
2020-01-02 14:51:50 +01:00
Haoyu Qiu
4d727f1ee6 Allows to doc vararg method return type as void 2020-01-02 21:37:26 +08:00
Rémi Verschelde
a7f49ac9a1 Update copyright statements to 2020
Happy new year to the wonderful Godot community!

We're starting a new decade with a well-established, non-profit, free
and open source game engine, and tons of further improvements in the
pipeline from hundreds of contributors.

Godot will keep getting better, and we're looking forward to all the
games that the community will keep developing and releasing with it.
2020-01-01 11:16:22 +01:00
Juan Linietsky
28599e6c20 Suggest use of deferred or oneshot on disconnect if the signal is locked. Closes #34443. 2019-12-18 19:32:00 -03:00
Juan Linietsky
0dd6079e4e Improve error message and do not spam forever. 2019-12-17 11:18:47 -03:00
Juan Linietsky
22637beb2e Restore signal locking, for some reason missing. 2019-12-17 10:43:51 -03:00
Bojidar Marinov
0b251997bb
Ensure object metadata is unique
Closes #32415
2019-09-28 18:15:23 +03:00
qarmin
17732fe698 Added some obvious errors explanations 2019-09-25 10:28:50 +02:00
Rémi Verschelde
5c853a45e6
Merge pull request #31423 from Calinou/improve-node-signal-group-tooltip
Improve the scene tree signals/groups tooltip
2019-08-18 10:55:16 +02:00
Hugo Locurcio
c62302a432
Improve the scene tree signals/groups tooltip
The tooltip now displays the number of connections and groups
that are assigned to the hovered node.
2019-08-17 14:20:16 +02:00
Braden Bodily
71d71d55b5 Replace 'ERR_EXPLAIN' with 'ERR_FAIL_*_MSG' in 'core/' and 'editor/'
Condensed some if and ERR statements. Added dots to end of error messages

Couldn't figure out EXPLAINC. These files gave me trouble: core/error_macros.h, core/io/file_access_buffered_fa.h (where is it?),
core/os/memory.cpp,
drivers/png/png_driver_common.cpp,
drivers/xaudio2/audio_driver_xaudio2.cpp (where is it?)
2019-08-17 12:33:15 +02:00
Rémi Verschelde
9f5b77acc9
Revert "Expose "meta" to the Inspector" 2019-07-22 12:03:57 +02:00
Rémi Verschelde
2ca3e47d66
Merge pull request #22642 from YeldhamDev/inspector_metadata
Expose "meta" to the Inspector
2019-07-19 14:39:23 +02:00
Rémi Verschelde
b0ce9401ff
Merge pull request #30126 from qarmin/remove_unnecessary_code
Remove unnecessary code and add some error explanations
2019-07-01 14:32:04 +02:00
qarmin
3c154eb93b Remove unnecessary code and add some error explanations 2019-07-01 12:59:42 +02:00
Rémi Verschelde
755b589384
Merge pull request #30096 from akien-mga/doc-misc-updates
doc: Proofread and complete various nodes
2019-06-27 08:12:34 +02:00
Rémi Verschelde
867dda1124 doc: Proofread and complete various nodes
All 100% completed: MainLoop, Node, Object, Path, Performance,
Reference, Resource, SceneState, SceneTree, UndoRedo.

Also fixed some en_GB occurrences as the reference spelling is en_US.
2019-06-26 23:05:51 +02:00
qarmin
4e5310cc60 Some code changed with Clang-Tidy 2019-06-26 15:08:25 +02:00
Rémi Verschelde
defd960276
Merge pull request #27886 from LeonardMeagher2/obj_to_string
Allow overriding how scripted objects are converted to strings
2019-05-20 22:37:01 +02:00
Fabio Alessandrelli
d39ffc101b Fix Object::get_indexed for simple properties.
Object::get_indexed was not correctly reporting invalid keys if the name
was a direct property (not a subproperty), causing for example Tween to
not report correctly a bad interpolate_property key.
2019-05-16 23:22:52 +02:00
Aaron Franke
702b539405
Change "ID" to lowercase "id"
Reasoning: ID is not an acronym, it is simply short for identification, so it logically should not be capitalized. But even if it was an acronym, other acronyms in Godot are not capitalized, like p_rid, p_ip, and p_json.
2019-05-09 06:25:32 -04:00
Leonard Meagher
f7eb426e2e Allow overriding how scripted objects are converted to strings
solves #26796

- ADD `String to_string()` method to Object which can be overriden by `String _to_string()` in scripts
- ADD `String to_string(r_valid)` method to ScriptInstance to allow langauges to control how scripted objects are converted to strings
- IMPLEMENT to_string for GDScriptInstance, VisualScriptInstance, and NativeScriptInstance
- ADD Documentation about `Object.to_string` and `Object._to_string`
- Changed `Variant::operator String` to use `obj->to_string()`
2019-05-03 15:06:05 -07:00
Sintinium
d1fa546dc9 Undo support for locking and grouping for both 2D and 3D 2019-04-26 18:16:59 -05:00
Hein-Pieter van Braam-Stewart
20b0046945 Object::script may not be a valid Ref<Script>
It appears that Object::script may be a valid ScriptInstance but not be
castable to Ref<Script>. There were only 5 places in the code that made
this assumption. This commit fixes that.
2019-04-20 02:13:28 +02:00
Rémi Verschelde
c8994b56f9 Style: Apply new changes from clang-format 8.0
It seems to stay compatible with formatting done by clang-format 6.0 and 7.0,
so contributors can keep using those versions for now (they will not undo those
changes).
2019-04-09 17:09:48 +02:00
Bojidar Marinov
dadcb33302
Print errors comming from callv
Fixes #18386
2019-03-05 12:24:21 +02:00
Juan Linietsky
61b41d6001 Ensure all properties are refreshed when setting a script, fixes #24845 2019-02-24 10:50:43 -03:00