Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
VLC
Manage
Activity
Members
Labels
Plan
Issues
4k
Issue boards
Milestones
Code
Merge requests
450
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Contributor analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
VideoLAN
VLC
Commits
572b5887
Commit
572b5887
authored
2 years ago
by
Pierre Lamot
Committed by
Jean-Baptiste Kempf
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
qt: fix deleting/updating items in cache before it's loaded
parent
3035fa4e
No related branches found
Branches containing commit
No related tags found
1 merge request
!1707
qt: fix deleting/updating items in cache before it's loaded
Pipeline
#207502
passed with stages
in 35 minutes and 51 seconds
Changes
1
Pipelines
3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
modules/gui/qt/medialibrary/mllistcache.cpp
+14
-0
14 additions, 0 deletions
modules/gui/qt/medialibrary/mllistcache.cpp
with
14 additions
and
0 deletions
modules/gui/qt/medialibrary/mllistcache.cpp
+
14
−
0
View file @
572b5887
...
...
@@ -143,6 +143,10 @@ int MLListCache::updateItem(std::unique_ptr<MLItem>&& newItem)
if
(
m_oldData
)
return
-
1
;
//we can't update an item before we have any cache
if
(
unlikely
(
!
m_cachedData
))
return
-
1
;
MLItemId
mlid
=
newItem
->
getId
();
//this may be inneficient to look at every items, maybe we can have a hashmap to access the items by id
auto
it
=
std
::
find_if
(
m_cachedData
->
list
.
begin
(),
m_cachedData
->
list
.
end
(),
[
mlid
](
const
ItemType
&
item
)
{
...
...
@@ -165,6 +169,10 @@ int MLListCache::deleteItem(const MLItemId& mlid)
if
(
m_oldData
)
return
-
1
;
//we can't remove an item before we have any cache
if
(
unlikely
(
!
m_cachedData
))
return
-
1
;
auto
it
=
std
::
find_if
(
m_cachedData
->
list
.
begin
(),
m_cachedData
->
list
.
end
(),
[
mlid
](
const
ItemType
&
item
)
{
return
(
item
->
getId
()
==
mlid
);
});
...
...
@@ -192,6 +200,9 @@ void MLListCache::moveRange(int first, int last, int to)
if
(
first
<=
to
&&
to
<=
last
)
return
;
if
(
unlikely
(
!
m_cachedData
))
return
;
emit
beginMoveRows
(
first
,
last
,
to
);
auto
it
=
m_cachedData
->
list
.
begin
();
//build a temporary list with the items in order
...
...
@@ -217,6 +228,9 @@ void MLListCache::moveRange(int first, int last, int to)
void
MLListCache
::
deleteRange
(
int
first
,
int
last
)
{
if
(
unlikely
(
!
m_cachedData
))
return
;
assert
(
first
<=
last
);
emit
beginRemoveRows
(
first
,
last
);
auto
it
=
m_cachedData
->
list
.
begin
();
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment