Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
godot
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
community
godot
Commits
f2aa99a8
Unverified
Commit
f2aa99a8
authored
Jan 16, 2020
by
Rémi Verschelde
Committed by
GitHub
Jan 16, 2020
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #35201 from bojidar-bg/27582-gdfunction-validate-instance
Validate instances of objects before trying to check their type in GDScript
parents
4998983b
dc4455d8
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
2 deletions
+10
-2
gdscript_function.h
modules/gdscript/gdscript_function.h
+10
-2
No files found.
modules/gdscript/gdscript_function.h
View file @
f2aa99a8
...
@@ -76,8 +76,12 @@ struct GDScriptDataType {
...
@@ -76,8 +76,12 @@ struct GDScriptDataType {
if
(
p_variant
.
get_type
()
!=
Variant
::
OBJECT
)
{
if
(
p_variant
.
get_type
()
!=
Variant
::
OBJECT
)
{
return
false
;
return
false
;
}
}
Object
*
obj
=
p_variant
.
operator
Object
*
();
Object
*
obj
=
p_variant
.
operator
Object
*
();
if
(
obj
)
{
if
(
!
obj
||
!
ObjectDB
::
instance_validate
(
obj
))
{
return
false
;
}
if
(
!
ClassDB
::
is_parent_class
(
obj
->
get_class_name
(),
native_type
))
{
if
(
!
ClassDB
::
is_parent_class
(
obj
->
get_class_name
(),
native_type
))
{
// Try with underscore prefix
// Try with underscore prefix
StringName
underscore_native_type
=
"_"
+
native_type
;
StringName
underscore_native_type
=
"_"
+
native_type
;
...
@@ -85,7 +89,6 @@ struct GDScriptDataType {
...
@@ -85,7 +89,6 @@ struct GDScriptDataType {
return
false
;
return
false
;
}
}
}
}
}
return
true
;
return
true
;
}
break
;
}
break
;
case
SCRIPT
:
case
SCRIPT
:
...
@@ -96,7 +99,12 @@ struct GDScriptDataType {
...
@@ -96,7 +99,12 @@ struct GDScriptDataType {
if
(
p_variant
.
get_type
()
!=
Variant
::
OBJECT
)
{
if
(
p_variant
.
get_type
()
!=
Variant
::
OBJECT
)
{
return
false
;
return
false
;
}
}
Object
*
obj
=
p_variant
.
operator
Object
*
();
Object
*
obj
=
p_variant
.
operator
Object
*
();
if
(
!
obj
||
!
ObjectDB
::
instance_validate
(
obj
))
{
return
false
;
}
Ref
<
Script
>
base
=
obj
&&
obj
->
get_script_instance
()
?
obj
->
get_script_instance
()
->
get_script
()
:
NULL
;
Ref
<
Script
>
base
=
obj
&&
obj
->
get_script_instance
()
?
obj
->
get_script_instance
()
->
get_script
()
:
NULL
;
bool
valid
=
false
;
bool
valid
=
false
;
while
(
base
.
is_valid
())
{
while
(
base
.
is_valid
())
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment