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
212f3a58
Commit
212f3a58
authored
Jul 08, 2021
by
Jean-Baptiste Mardelle
Browse files
Fix freeze on loading clip with unknown duration
parent
8ef991dd
Pipeline
#69199
canceled with stage
Changes
5
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/bin/projectclip.cpp
View file @
212f3a58
...
...
@@ -2093,6 +2093,7 @@ void ProjectClip::updateJobProgress()
void
ProjectClip
::
setInvalid
()
{
m_isInvalid
=
true
;
m_producerLock
.
unlock
();
}
void
ProjectClip
::
updateProxyProducer
(
const
QString
&
path
)
...
...
src/bin/projectclip.h
View file @
212f3a58
...
...
@@ -242,8 +242,6 @@ public:
static
const
QByteArray
getFolderHash
(
QDir
dir
,
QString
fileName
);
/** @brief Check if the clip is included in timeline and reset its occurrences on producer reload. */
void
updateTimelineOnReload
();
/** @brief If a clip is invalid on load, mark it as such so we don't try to re-insert it on undo/redo. */
void
setInvalid
();
int
getRecordTime
();
/** @brief Return maximum audio level for a stream. */
int
getAudioMax
(
int
stream
);
...
...
@@ -284,6 +282,9 @@ public slots:
/** @brief A proxy clip is available or disabled, update path and reload */
void
updateProxyProducer
(
const
QString
&
path
);
/** @brief If a clip is invalid on load, mark it as such so we don't try to re-insert it on undo/redo. */
void
setInvalid
();
/**
* Imports effect from a given producer
...
...
src/jobs/cliploadtask.cpp
View file @
212f3a58
...
...
@@ -55,6 +55,7 @@ ClipLoadTask::ClipLoadTask(const ObjectId &owner, const QDomElement &xml, bool t
,
m_thumbOnly
(
thumbOnly
)
,
m_readyCallBack
(
std
::
move
(
readyCallBack
))
{
QObject
::
connect
(
this
,
&
ClipLoadTask
::
proposeTranscode
,
this
,
&
ClipLoadTask
::
doProposeTranscode
,
Qt
::
QueuedConnection
);
}
ClipLoadTask
::~
ClipLoadTask
()
...
...
@@ -516,15 +517,8 @@ void ClipLoadTask::run()
if
(
producer
)
{
producer
.
reset
();
}
qDebug
()
<<
"=== MAX DURATION: "
<<
INT_MAX
<<
", DURATION: "
<<
(
INT_MAX
/
25
/
60
);
QAction
*
ac
=
new
QAction
(
i18n
(
"Transcode"
),
m_object
);
QObject
::
connect
(
ac
,
&
QAction
::
triggered
,
[
&
]()
{
pCore
->
transcodeFile
(
resource
);
});
QList
<
QAction
*>
actions
=
{
ac
};
QMetaObject
::
invokeMethod
(
pCore
.
get
(),
"displayBinMessage"
,
Qt
::
QueuedConnection
,
Q_ARG
(
QString
,
i18n
(
"Cannot get duration for file %1"
,
resource
)),
Q_ARG
(
int
,
int
(
KMessageWidget
::
Warning
)),
Q_ARG
(
QList
<
QAction
*>
,
actions
));
qDebug
()
<<
"=== MAX DURATION: "
<<
INT_MAX
<<
", DURATION: "
<<
(
INT_MAX
/
25
/
60
)
<<
"; RES: "
<<
resource
;
emit
proposeTranscode
(
resource
);
abort
();
return
;
}
...
...
@@ -685,18 +679,33 @@ void ClipLoadTask::abort()
{
Fun
undo
=
[]()
{
return
true
;
};
Fun
redo
=
[]()
{
return
true
;
};
m_progress
=
100
;
pCore
->
taskManager
.
taskDone
(
m_owner
.
second
,
this
);
if
(
!
m_softDelete
)
{
auto
binClip
=
pCore
->
projectItemModel
()
->
getClipByBinID
(
QString
::
number
(
m_owner
.
second
));
if
(
binClip
)
{
QMetaObject
::
invokeMethod
(
binClip
.
get
(),
"setInvalid"
,
Qt
::
QueuedConnection
);
if
(
binClip
->
hash
().
isEmpty
())
{
// User tried to add an invalid clip, remove it.
binClip
->
setInvalid
();
pCore
->
projectItemModel
()
->
requestBinClipDeletion
(
binClip
,
undo
,
redo
);
}
else
{
// An existing clip just became invalid, mark it as missing.
binClip
->
setClipStatus
(
FileStatus
::
StatusMissing
);
}
}
}
pCore
->
taskManager
.
taskDone
(
m_owner
.
second
,
this
);
}
void
ClipLoadTask
::
doProposeTranscode
(
const
QString
&
resource
)
{
QAction
*
ac
=
new
QAction
(
i18n
(
"Transcode"
),
m_object
);
qDebug
()
<<
"=== PREPARING TRANSCODE!!!"
;
QObject
::
connect
(
ac
,
&
QAction
::
triggered
,
[
resource
]()
{
//QMetaObject::invokeMethod(pCore.get(), "transcodeFile", Qt::QueuedConnection, Q_ARG(QString, resource));
pCore
->
transcodeFile
(
resource
);
});
QList
<
QAction
*>
actions
=
{
ac
};
QMetaObject
::
invokeMethod
(
pCore
.
get
(),
"displayBinMessage"
,
Qt
::
QueuedConnection
,
Q_ARG
(
QString
,
i18n
(
"Cannot get duration for file %1"
,
resource
)),
Q_ARG
(
int
,
int
(
KMessageWidget
::
Warning
)),
Q_ARG
(
QList
<
QAction
*>
,
actions
));
}
src/jobs/cliploadtask.h
View file @
212f3a58
...
...
@@ -36,6 +36,7 @@ class ProjectClip;
class
ClipLoadTask
:
public
AbstractTask
{
Q_OBJECT
public:
ClipLoadTask
(
const
ObjectId
&
owner
,
const
QDomElement
&
xml
,
bool
thumbOnly
,
int
in
,
int
out
,
QObject
*
object
,
std
::
function
<
void
()
>
readyCallBack
);
virtual
~
ClipLoadTask
();
...
...
@@ -51,6 +52,9 @@ public:
protected:
void
run
()
override
;
private
slots
:
void
doProposeTranscode
(
const
QString
&
resource
);
private:
//QString cacheKey();
QDomElement
m_xml
;
...
...
@@ -61,6 +65,9 @@ private:
QString
m_errorMessage
;
void
generateThumbnail
(
std
::
shared_ptr
<
ProjectClip
>
binClip
,
std
::
shared_ptr
<
Mlt
::
Producer
>
producer
);
void
abort
();
signals:
void
proposeTranscode
(
const
QString
&
resource
);
};
#endif // CLIPLOADTASK_H
src/mltcontroller/clipcontroller.h
View file @
212f3a58
...
...
@@ -223,6 +223,9 @@ public:
const
QString
getOriginalUrl
();
protected:
/** @brief Mutex to protect the producer properties on read/write */
mutable
QReadWriteLock
m_producerLock
;
virtual
void
emitProducerChanged
(
const
QString
&
/*unused*/
,
const
std
::
shared_ptr
<
Mlt
::
Producer
>
&
/*unused*/
){};
virtual
void
connectEffectStack
(){};
...
...
@@ -255,8 +258,6 @@ protected:
std
::
shared_ptr
<
Mlt
::
Producer
>
m_thumbsProducer
;
private:
/** @brief Mutex to protect the producer properties on read/write */
mutable
QReadWriteLock
m_producerLock
;
/** @brief Temporarily store clip properties until producer is available */
QMap
<
QString
,
QVariant
>
m_tempProps
;
QString
m_controllerBinId
;
...
...
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