Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc
Commits
c66586a5
Commit
c66586a5
authored
Jan 28, 2010
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Warn about reparented object when debugging
parent
97676090
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
0 deletions
+21
-0
src/libvlc.h
src/libvlc.h
+1
-0
src/misc/objects.c
src/misc/objects.c
+20
-0
No files found.
src/libvlc.h
View file @
c66586a5
...
...
@@ -183,6 +183,7 @@ struct vlc_object_internals
vlc_object_internals_t
*
next
;
/* next sibling */
vlc_object_internals_t
*
prev
;
/* previous sibling */
vlc_object_internals_t
*
first
;
/* first child */
vlc_object_t
*
old_parent
;
};
#define ZOOM_SECTION N_("Zoom")
...
...
src/misc/objects.c
View file @
c66586a5
...
...
@@ -154,6 +154,9 @@ void *__vlc_custom_create( vlc_object_t *p_this, size_t i_size,
p_priv
->
b_thread
=
false
;
p_new
->
p_parent
=
NULL
;
p_priv
->
first
=
NULL
;
#ifndef NDEBUG
p_priv
->
old_parent
=
NULL
;
#endif
/* Initialize mutexes and condvars */
vlc_mutex_init
(
&
p_priv
->
var_lock
);
...
...
@@ -612,6 +615,20 @@ void __vlc_object_attach( vlc_object_t *p_this, vlc_object_t *p_parent )
priv
->
prev
=
NULL
;
vlc_object_hold
(
p_parent
);
libvlc_lock
(
p_this
->
p_libvlc
);
#ifndef NDEBUG
/* Reparenting an object carries a risk of invalid access to the parent,
* from another thread. This can happen when inheriting a variable, or
* through any direct access to vlc_object_t.p_parent. Also, reparenting
* brings a functional bug, whereby the reparented object uses incorrect
* old values for inherited variables (as the new parent may have different
* variable values, especially if it is an input).
* Note that the old parent may be already destroyed.
* So its pointer must not be dereferenced.
*/
if
(
priv
->
old_parent
)
msg_Info
(
p_this
,
"Reparenting an object is dangerous (%p -> %p)!"
,
priv
->
old_parent
,
p_parent
);
#endif
/* Attach the parent to its child */
assert
(
!
p_this
->
p_parent
);
...
...
@@ -642,6 +659,9 @@ static void vlc_object_detach_unlocked (vlc_object_t *p_this)
priv
->
next
->
prev
=
priv
->
prev
;
/* Remove p_this's parent */
#ifndef NDEBUG
priv
->
old_parent
=
p_this
->
p_parent
;
#endif
p_this
->
p_parent
=
NULL
;
}
...
...
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