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
f25f0c54
Unverified
Commit
f25f0c54
authored
Jun 10, 2020
by
Rémi Verschelde
Committed by
GitHub
Jun 10, 2020
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #39390 from mrushyendra/duplicate_signals_master
Fix signal duplication bug when duplicating node with instanced children
parents
47f1faf5
a2392039
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
27 deletions
+34
-27
node.cpp
scene/main/node.cpp
+34
-27
No files found.
scene/main/node.cpp
View file @
f25f0c54
...
@@ -2238,46 +2238,53 @@ void Node::_duplicate_and_reown(Node *p_new_parent, const Map<Node *, Node *> &p
...
@@ -2238,46 +2238,53 @@ void Node::_duplicate_and_reown(Node *p_new_parent, const Map<Node *, Node *> &p
// because re-targeting of connections from some descendant to another is not possible
// because re-targeting of connections from some descendant to another is not possible
// if the emitter node comes later in tree order than the receiver
// if the emitter node comes later in tree order than the receiver
void
Node
::
_duplicate_signals
(
const
Node
*
p_original
,
Node
*
p_copy
)
const
{
void
Node
::
_duplicate_signals
(
const
Node
*
p_original
,
Node
*
p_copy
)
const
{
if
(
this
!=
p_original
&&
(
get_owner
()
!=
p_original
&&
get_owner
()
!=
p_original
->
get_owner
(
)))
{
if
(
(
this
!=
p_original
)
&&
!
(
p_original
->
is_a_parent_of
(
this
)))
{
return
;
return
;
}
}
List
<
Connection
>
conns
;
List
<
const
Node
*>
process_list
;
get_all_signal_connections
(
&
conns
);
process_list
.
push_back
(
this
);
while
(
!
process_list
.
empty
())
{
const
Node
*
n
=
process_list
.
front
()
->
get
();
process_list
.
pop_front
();
for
(
List
<
Connection
>::
Element
*
E
=
conns
.
front
();
E
;
E
=
E
->
next
())
{
List
<
Connection
>
conns
;
if
(
E
->
get
().
flags
&
CONNECT_PERSIST
)
{
n
->
get_all_signal_connections
(
&
conns
);
//user connected
NodePath
p
=
p_original
->
get_path_to
(
this
);
Node
*
copy
=
p_copy
->
get_node
(
p
);
Node
*
target
=
Object
::
cast_to
<
Node
>
(
E
->
get
().
callable
.
get_object
());
for
(
List
<
Connection
>::
Element
*
E
=
conns
.
front
();
E
;
E
=
E
->
next
())
{
if
(
!
target
)
{
if
(
E
->
get
().
flags
&
CONNECT_PERSIST
)
{
continue
;
//user connected
}
NodePath
p
=
p_original
->
get_path_to
(
n
);
NodePath
ptarget
=
p_original
->
get_path_to
(
target
);
Node
*
copy
=
p_copy
->
get_node
(
p
);
Node
*
copytarget
=
target
;
Node
*
target
=
Object
::
cast_to
<
Node
>
(
E
->
get
().
callable
.
get_object
());
if
(
!
target
)
{
continue
;
}
NodePath
ptarget
=
p_original
->
get_path_to
(
target
);
// Attempt to find a path to the duplicate target, if it seems it's not part
Node
*
copytarget
=
target
;
// of the duplicated and not yet parented hierarchy then at least try to connect
// to the same target as the original
if
(
p_copy
->
has_node
(
ptarget
))
{
// Attempt to find a path to the duplicate target, if it seems it's not part
copytarget
=
p_copy
->
get_node
(
ptarget
);
// of the duplicated and not yet parented hierarchy then at least try to connect
}
// to the same target as the original
if
(
copy
&&
copytarget
)
{
if
(
p_copy
->
has_node
(
ptarget
))
{
const
Callable
copy_callable
=
Callable
(
copytarget
,
E
->
get
().
callable
.
get_method
());
copytarget
=
p_copy
->
get_node
(
ptarget
);
if
(
!
copy
->
is_connected
(
E
->
get
().
signal
.
get_name
(),
copy_callable
))
{
}
copy
->
connect
(
E
->
get
().
signal
.
get_name
(),
copy_callable
,
E
->
get
().
binds
,
E
->
get
().
flags
);
if
(
copy
&&
copytarget
)
{
const
Callable
copy_callable
=
Callable
(
copytarget
,
E
->
get
().
callable
.
get_method
());
if
(
!
copy
->
is_connected
(
E
->
get
().
signal
.
get_name
(),
copy_callable
))
{
copy
->
connect
(
E
->
get
().
signal
.
get_name
(),
copy_callable
,
E
->
get
().
binds
,
E
->
get
().
flags
);
}
}
}
}
}
}
}
}
for
(
int
i
=
0
;
i
<
get_child_count
();
i
++
)
{
for
(
int
i
=
0
;
i
<
n
->
get_child_count
();
i
++
)
{
get_child
(
i
)
->
_duplicate_signals
(
p_original
,
p_copy
);
process_list
.
push_back
(
n
->
get_child
(
i
));
}
}
}
}
}
...
...
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