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
718fa543
Commit
718fa543
authored
Dec 15, 2019
by
Jean-Baptiste Mardelle
Browse files
Fix clip losing thumb/length on profile switch.
Related to
#479
parent
678ed5e3
Changes
7
Hide whitespace changes
Inline
Side-by-side
src/bin/bin.cpp
View file @
718fa543
...
...
@@ -70,6 +70,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <QUrl>
#include <QVBoxLayout>
#include <utility>
#include <utils/thumbnailcache.hpp>
/**
* @class BinItemDelegate
...
...
@@ -3078,18 +3079,21 @@ void Bin::reloadAllProducers()
QDomDocument
doc
;
QDomElement
xml
=
clip
->
toXml
(
doc
,
false
,
false
);
// Make sure we reload clip length
xml
.
removeAttribute
(
QStringLiteral
(
"out"
));
Xml
::
removeXmlProperty
(
xml
,
QStringLiteral
(
"length"
));
if
(
clip
->
clipType
()
==
ClipType
::
AV
||
clip
->
clipType
()
==
ClipType
::
Video
||
clip
->
clipType
()
==
ClipType
::
Audio
||
clip
->
clipType
()
==
ClipType
::
Playlist
)
{
xml
.
removeAttribute
(
QStringLiteral
(
"out"
));
Xml
::
removeXmlProperty
(
xml
,
QStringLiteral
(
"length"
));
}
if
(
clip
->
isValid
())
{
clip
->
resetProducerProperty
(
QStringLiteral
(
"kdenlive:duration"
));
clip
->
resetProducerProperty
(
QStringLiteral
(
"length"
));
}
if
(
!
xml
.
isNull
())
{
clip
->
setClipStatus
(
AbstractProjectItem
::
StatusWaiting
);
clip
->
discardAudioThumb
();
pCore
->
jobManager
()
->
slotDiscardClipJobs
(
clip
->
clipId
());
clip
->
discardAudioThumb
();
// We need to set a temporary id before all outdated producers are replaced;
int
jobId
=
pCore
->
jobManager
()
->
startJob
<
LoadJob
>
({
clip
->
clipId
()},
-
1
,
QString
(),
xml
);
ThumbnailCache
::
get
()
->
invalidateThumbsForClip
(
clip
->
clipId
(),
true
);
pCore
->
jobManager
()
->
startJob
<
ThumbJob
>
({
clip
->
clipId
()},
jobId
,
QString
(),
150
,
-
1
,
true
,
true
);
pCore
->
jobManager
()
->
startJob
<
AudioThumbJob
>
({
clip
->
clipId
()},
jobId
,
QString
());
}
...
...
src/bin/clipcreator.cpp
View file @
718fa543
...
...
@@ -84,14 +84,12 @@ QString ClipCreator::createColorClip(const QString &color, int duration, const Q
return
res
?
id
:
QStringLiteral
(
"-1"
);
}
QString
ClipCreator
::
createClipFromFile
(
const
QString
&
path
,
const
QString
&
parentFolder
,
const
std
::
shared_ptr
<
ProjectItemModel
>
&
model
,
Fun
&
undo
,
Fun
&
redo
,
const
std
::
function
<
void
(
const
QString
&
)
>
&
readyCallBack
)
QDomDocument
ClipCreator
::
getXmlFromUrl
(
const
QString
&
path
)
{
QDomDocument
xml
;
QMimeDatabase
db
;
QMimeType
type
=
db
.
mimeTypeForUrl
(
QUrl
::
fromLocalFile
(
path
));
qDebug
()
<<
"/////////// createClipFromFile"
<<
path
<<
parentFolder
<<
path
<<
type
.
name
();
QDomElement
prod
;
if
(
type
.
name
().
startsWith
(
QLatin1String
(
"image/"
)))
{
int
duration
=
pCore
->
currentDoc
()
->
getFramePos
(
KdenliveSettings
::
image_duration
());
...
...
@@ -120,7 +118,7 @@ QString ClipCreator::createClipFromFile(const QString &path, const QString &pare
prod
.
setAttribute
(
QStringLiteral
(
"xmldata"
),
titleData
);
}
else
{
txtfile
.
close
();
return
Q
StringLiteral
(
"-1"
);
return
Q
DomDocument
(
);
}
}
else
{
// it is a "normal" file, just use a producer
...
...
@@ -133,7 +131,17 @@ QString ClipCreator::createClipFromFile(const QString &path, const QString &pare
if
(
pCore
->
bin
()
->
isEmpty
()
&&
(
KdenliveSettings
::
default_profile
().
isEmpty
()
||
KdenliveSettings
::
checkfirstprojectclip
()))
{
prod
.
setAttribute
(
QStringLiteral
(
"_checkProfile"
),
1
);
}
return
xml
;
}
QString
ClipCreator
::
createClipFromFile
(
const
QString
&
path
,
const
QString
&
parentFolder
,
const
std
::
shared_ptr
<
ProjectItemModel
>
&
model
,
Fun
&
undo
,
Fun
&
redo
,
const
std
::
function
<
void
(
const
QString
&
)
>
&
readyCallBack
)
{
qDebug
()
<<
"/////////// createClipFromFile"
<<
path
<<
parentFolder
<<
path
;
QDomDocument
xml
=
getXmlFromUrl
(
path
);
if
(
xml
.
isNull
())
{
return
QStringLiteral
(
"-1"
);
}
qDebug
()
<<
"/////////// final xml"
<<
xml
.
toString
();
QString
id
;
bool
res
=
model
->
requestAddBinClip
(
id
,
xml
.
documentElement
(),
parentFolder
,
undo
,
redo
,
readyCallBack
);
...
...
src/bin/clipcreator.hpp
View file @
718fa543
...
...
@@ -95,6 +95,10 @@ bool createClipFromFile(const QString &path, const QString &parentFolder, std::s
bool
createClipsFromList
(
const
QList
<
QUrl
>
&
list
,
bool
checkRemovable
,
const
QString
&
parentFolder
,
const
std
::
shared_ptr
<
ProjectItemModel
>
&
model
,
Fun
&
undo
,
Fun
&
redo
,
bool
topLevel
=
true
);
bool
createClipsFromList
(
const
QList
<
QUrl
>
&
list
,
bool
checkRemovable
,
const
QString
&
parentFolder
,
std
::
shared_ptr
<
ProjectItemModel
>
model
);
/* @brief Create minimal xml description from an url
*/
QDomDocument
getXmlFromUrl
(
const
QString
&
path
);
}
// namespace ClipCreator
#endif
src/bin/projectclip.cpp
View file @
718fa543
...
...
@@ -340,7 +340,12 @@ void ProjectClip::reloadProducer(bool refreshOnly, bool audioStreamChanged, bool
QDomElement
ProjectClip
::
toXml
(
QDomDocument
&
document
,
bool
includeMeta
,
bool
includeProfile
)
{
getProducerXML
(
document
,
includeMeta
,
includeProfile
);
QDomElement
prod
=
document
.
documentElement
().
firstChildElement
(
QStringLiteral
(
"producer"
));
QDomElement
prod
;
if
(
document
.
documentElement
().
tagName
()
==
QLatin1String
(
"producer"
))
{
prod
=
document
.
documentElement
();
}
else
{
prod
=
document
.
documentElement
().
firstChildElement
(
QStringLiteral
(
"producer"
));
}
if
(
m_clipType
!=
ClipType
::
Unknown
)
{
prod
.
setAttribute
(
QStringLiteral
(
"type"
),
(
int
)
m_clipType
);
}
...
...
src/bin/projectclip.h
View file @
718fa543
...
...
@@ -254,8 +254,6 @@ public slots:
private:
/** @brief Generate and store file hash if not available. */
const
QString
getFileHash
();
/** @brief Store clip url temporarily while the clip controller has not been created. */
QString
m_temporaryUrl
;
std
::
shared_ptr
<
Mlt
::
Producer
>
m_thumbsProducer
;
QMutex
m_producerMutex
;
QMutex
m_thumbMutex
;
...
...
src/mltcontroller/clipcontroller.cpp
View file @
718fa543
...
...
@@ -28,6 +28,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "kdenlivesettings.h"
#include "lib/audio/audioStreamInfo.h"
#include "profiles/profilemodel.hpp"
#include "bin/clipcreator.hpp"
#include "core.h"
#include "kdenlive_debug.h"
...
...
@@ -193,6 +194,11 @@ void ClipController::getProducerXML(QDomDocument &document, bool includeMeta, bo
QString
xml
=
producerXml
(
m_masterProducer
,
includeMeta
,
includeProfile
);
document
.
setContent
(
xml
);
}
else
{
if
(
!
m_temporaryUrl
.
isEmpty
())
{
document
=
ClipCreator
::
getXmlFromUrl
(
m_temporaryUrl
);
}
else
if
(
!
m_path
.
isEmpty
())
{
document
=
ClipCreator
::
getXmlFromUrl
(
m_path
);
}
qCDebug
(
KDENLIVE_LOG
)
<<
" + + ++ NO MASTER PROD"
;
}
}
...
...
src/mltcontroller/clipcontroller.h
View file @
718fa543
...
...
@@ -236,6 +236,8 @@ protected:
std
::
shared_ptr
<
MarkerListModel
>
m_markerModel
;
bool
m_hasAudio
;
bool
m_hasVideo
;
/** @brief Store clip url temporarily while the clip controller has not been created. */
QString
m_temporaryUrl
;
private:
/** @brief Mutex to protect the producer properties on read/write */
...
...
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