Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Multimedia
Kdenlive
Commits
887b986c
Commit
887b986c
authored
Jan 04, 2022
by
Jean-Baptiste Mardelle
Browse files
Massive speedup on project load (at least when working on nfs filesystem)
Related to
#1266
parent
e8f27dac
Pipeline
#118353
passed with stage
in 5 minutes and 2 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/bin/filewatcher.cpp
View file @
887b986c
...
...
@@ -17,14 +17,44 @@ FileWatcher::FileWatcher(QObject *parent)
connect
(
KDirWatch
::
self
(),
&
KDirWatch
::
deleted
,
this
,
&
FileWatcher
::
slotUrlMissing
);
connect
(
KDirWatch
::
self
(),
&
KDirWatch
::
created
,
this
,
&
FileWatcher
::
slotUrlAdded
);
connect
(
&
m_modifiedTimer
,
&
QTimer
::
timeout
,
this
,
&
FileWatcher
::
slotProcessModifiedUrls
);
m_queueTimer
.
setInterval
(
300
);
m_queueTimer
.
setSingleShot
(
true
);
connect
(
&
m_queueTimer
,
&
QTimer
::
timeout
,
this
,
&
FileWatcher
::
slotProcessQueue
);
}
void
FileWatcher
::
slotProcessQueue
()
{
if
(
m_pendingUrls
.
size
()
==
0
)
{
return
;
}
auto
iter
=
m_pendingUrls
.
begin
();
doAddFile
(
iter
->
first
,
iter
->
second
);
m_pendingUrls
.
erase
(
iter
->
first
);
if
(
m_pendingUrls
.
size
()
>
0
&&
!
m_queueTimer
.
isActive
())
{
m_queueTimer
.
start
();
}
}
void
FileWatcher
::
addFile
(
const
QString
&
binId
,
const
QString
&
url
)
{
if
(
m_occurences
.
count
(
url
)
>
0
)
{
// Already queued
return
;
}
m_pendingUrls
[
binId
]
=
url
;
if
(
!
m_queueTimer
.
isActive
())
{
m_queueTimer
.
start
();
}
}
void
FileWatcher
::
doAddFile
(
const
QString
&
binId
,
const
QString
&
url
)
{
if
(
url
.
isEmpty
())
{
return
;
}
if
(
m_occurences
.
count
(
url
)
==
0
)
{
//QtConcurrent::run([=] { KDirWatch::self()->addFile(url); });
KDirWatch
::
self
()
->
addFile
(
url
);
}
m_occurences
[
url
].
insert
(
binId
);
...
...
src/bin/filewatcher.hpp
View file @
887b986c
...
...
@@ -22,7 +22,7 @@ class FileWatcher : public QObject
public:
// Constructor
explicit
FileWatcher
(
QObject
*
parent
=
nullptr
);
// Add a file to the
list of
watched items
// Add a file to the
queue for
watched items
void
addFile
(
const
QString
&
binId
,
const
QString
&
url
);
// Remove a binId from the list of watched items
void
removeFile
(
const
QString
&
binId
);
...
...
@@ -44,6 +44,7 @@ private slots:
void
slotUrlMissing
(
const
QString
&
path
);
void
slotUrlAdded
(
const
QString
&
path
);
void
slotProcessModifiedUrls
();
void
slotProcessQueue
();
private:
// A list with urls as keys, and the corresponding clip ids as value
...
...
@@ -53,8 +54,14 @@ private:
// List of files for which we received an update since the last send
std
::
unordered_set
<
QString
>
m_modifiedUrls
;
// When loading a project or adding many clips, adding many files to the watcher causes a freeze, so queue them
std
::
unordered_map
<
QString
,
QString
>
m_pendingUrls
;
QTimer
m_modifiedTimer
;
QTimer
m_queueTimer
;
// Add a file to the list of watched items
void
doAddFile
(
const
QString
&
binId
,
const
QString
&
url
);
};
#endif
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