Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
VideoLAN
medialibrary
Commits
0a125d2c
Commit
0a125d2c
authored
Aug 22, 2016
by
Hugo Beauzée-Luyssen
Browse files
AlbumTrack: use Cache to store the Album
parent
89bd96c3
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/AlbumTrack.cpp
View file @
0a125d2c
...
...
@@ -212,13 +212,14 @@ unsigned int AlbumTrack::discNumber() const
std
::
shared_ptr
<
IAlbum
>
AlbumTrack
::
album
()
{
auto
album
=
m_album
.
lock
();
if
(
album
==
nullptr
&&
m_albumId
!=
0
)
{
album
=
Album
::
fetch
(
m_ml
,
m_albumId
);
m_album
=
album
;
}
return
album
;
// "Fail" early in case there's no album to fetch
if
(
m_albumId
==
0
)
return
nullptr
;
auto
lock
=
m_album
.
lock
();
if
(
m_album
.
isCached
()
==
false
)
m_album
=
Album
::
fetch
(
m_ml
,
m_albumId
);
return
m_album
.
get
().
lock
();
}
std
::
shared_ptr
<
IMedia
>
AlbumTrack
::
media
()
...
...
src/AlbumTrack.h
View file @
0a125d2c
...
...
@@ -85,7 +85,7 @@ class AlbumTrack : public IAlbumTrack, public DatabaseHelpers<AlbumTrack, policy
unsigned
int
m_discNumber
;
bool
m_isPresent
;
std
::
weak_ptr
<
Album
>
m_album
;
mutable
Cache
<
std
::
weak_ptr
<
Album
>
>
m_album
;
mutable
Cache
<
std
::
shared_ptr
<
Artist
>>
m_artist
;
mutable
Cache
<
std
::
shared_ptr
<
Genre
>>
m_genre
;
mutable
Cache
<
std
::
weak_ptr
<
Media
>>
m_media
;
...
...
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