Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
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
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
ee36a48d
Commit
ee36a48d
authored
Sep 05, 2019
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
db/simple/Directory: RemoveSong() returns SongPtr
parent
07f212c9
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
7 additions
and
6 deletions
+7
-6
Directory.cxx
src/db/plugins/simple/Directory.cxx
+2
-1
Directory.hxx
src/db/plugins/simple/Directory.hxx
+2
-2
Editor.cxx
src/db/update/Editor.cxx
+3
-3
No files found.
src/db/plugins/simple/Directory.cxx
View file @
ee36a48d
...
...
@@ -172,7 +172,7 @@ Directory::AddSong(SongPtr song) noexcept
songs
.
push_back
(
*
song
.
release
());
}
void
SongPtr
Directory
::
RemoveSong
(
Song
*
song
)
noexcept
{
assert
(
holding_db_lock
());
...
...
@@ -180,6 +180,7 @@ Directory::RemoveSong(Song *song) noexcept
assert
(
&
song
->
parent
==
this
);
songs
.
erase
(
songs
.
iterator_to
(
*
song
));
return
SongPtr
(
song
);
}
const
Song
*
...
...
src/db/plugins/simple/Directory.hxx
View file @
ee36a48d
...
...
@@ -257,9 +257,9 @@ public:
/**
* Remove a song object from this directory (which effectively
* invalidates the song object, because the "parent" attribute becomes
* stale),
but does not free it
.
* stale),
and return ownership to the caller
.
*/
void
RemoveSong
(
Song
*
song
)
noexcept
;
SongPtr
RemoveSong
(
Song
*
song
)
noexcept
;
/**
* Caller must lock the #db_mutex.
...
...
src/db/update/Editor.cxx
View file @
ee36a48d
...
...
@@ -32,7 +32,7 @@ DatabaseEditor::DeleteSong(Directory &dir, Song *del)
assert
(
&
del
->
parent
==
&
dir
);
/* first, prevent traversers in main task from getting this */
dir
.
RemoveSong
(
del
);
const
SongPtr
song
=
dir
.
RemoveSong
(
del
);
/* temporary unlock, because update_remove_song() blocks */
const
ScopeDatabaseUnlock
unlock
;
...
...
@@ -40,8 +40,8 @@ DatabaseEditor::DeleteSong(Directory &dir, Song *del)
/* now take it out of the playlist (in the main_task) */
remove
.
Remove
(
del
->
GetURI
());
/*
finally, all possible references gone, free it */
delete
del
;
/*
the Song object will be freed here because its owning
SongPtr lives on our stack, see above */
}
void
...
...
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