Skip to content
GitLab
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
395ebda4
Commit
395ebda4
authored
Nov 22, 2022
by
Jean-Baptiste Mardelle
Browse files
Fix project duration incorrectly changed when changing speed of last clip in project
parent
272290c7
Pipeline
#272869
passed with stage
in 8 minutes and 42 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/timeline2/model/timelinemodel.cpp
View file @
395ebda4
...
...
@@ -2983,17 +2983,47 @@ int TimelineModel::requestClipResizeAndTimeWarp(int itemId, int size, bool right
}
// First delete clip, then timewarp, resize and reinsert
int
pos
=
getItemPosition
(
id
);
int
invalidateIn
=
pos
;
int
invalidateOut
=
invalidateIn
+
getClipPlaytime
(
id
);
if
(
!
right
)
{
pos
+=
getItemPlaytime
(
id
)
-
size
;
}
result
=
getTrackById
(
tid
)
->
requestClipDeletion
(
id
,
true
,
true
,
undo
,
redo
,
false
,
false
);
bool
hasVideo
=
false
;
if
(
tid
!=
-
1
&&
!
getTrackById_const
(
tid
)
->
isAudioTrack
())
{
hasVideo
=
true
;
}
int
trackDuration
=
getTrackById_const
(
tid
)
->
trackDuration
();
result
=
getTrackById
(
tid
)
->
requestClipDeletion
(
id
,
true
,
false
,
undo
,
redo
,
false
,
false
);
bool
pitchCompensate
=
m_allClips
[
id
]
->
getIntProperty
(
QStringLiteral
(
"warp_pitch"
));
result
=
result
&&
requestClipTimeWarp
(
id
,
speed
,
pitchCompensate
,
true
,
undo
,
redo
);
result
=
result
&&
requestItemResize
(
id
,
size
,
true
,
true
,
undo
,
redo
);
result
=
result
&&
getTrackById
(
tid
)
->
requestClipInsertion
(
id
,
pos
,
true
,
tru
e
,
undo
,
redo
,
false
,
false
);
result
=
result
&&
getTrackById
(
tid
)
->
requestClipInsertion
(
id
,
pos
,
true
,
fals
e
,
undo
,
redo
,
false
,
false
);
if
(
!
result
)
{
break
;
}
bool
durationChanged
=
false
;
if
(
trackDuration
!=
getTrackById_const
(
tid
)
->
trackDuration
())
{
durationChanged
=
true
;
getTrackById
(
tid
)
->
adjustStackLength
(
trackDuration
,
getTrackById_const
(
tid
)
->
trackDuration
(),
undo
,
redo
);
}
if
(
right
)
{
invalidateOut
=
qMax
(
invalidateOut
,
invalidateIn
+
getClipPlaytime
(
id
));
}
else
{
invalidateIn
=
qMin
(
invalidateIn
,
invalidateOut
-
getClipPlaytime
(
id
));
}
Fun
view_redo
=
[
this
,
invalidateIn
,
invalidateOut
,
hasVideo
,
durationChanged
]()
{
if
(
hasVideo
)
{
emit
invalidateZone
(
invalidateIn
,
invalidateOut
);
}
if
(
durationChanged
)
{
// last clip in playlist updated
updateDuration
();
}
return
true
;
};
view_redo
();
PUSH_LAMBDA
(
view_redo
,
redo
);
PUSH_LAMBDA
(
view_redo
,
undo
);
}
if
(
!
result
)
{
bool
undone
=
undo
();
...
...
@@ -5640,10 +5670,10 @@ void TimelineModel::requestClipUpdate(int clipId, const QVector<int> &roles)
bool
TimelineModel
::
requestClipTimeWarp
(
int
clipId
,
double
speed
,
bool
pitchCompensate
,
bool
changeDuration
,
Fun
&
undo
,
Fun
&
redo
)
{
QWriteLocker
locker
(
&
m_lock
);
std
::
function
<
bool
(
void
)
>
local_undo
=
[]()
{
return
true
;
};
std
::
function
<
bool
(
void
)
>
local_redo
=
[]()
{
return
true
;
};
Fun
local_undo
=
[]()
{
return
true
;
};
Fun
local_redo
=
[]()
{
return
true
;
};
int
oldPos
=
getClipPosition
(
clipId
);
// in order to make the producer change effective, we need to unplant / replant the clip in i
n
t track
// in order to make the producer change effective, we need to unplant / replant the clip in it
s
track
bool
success
=
true
;
int
trackId
=
getClipTrackId
(
clipId
);
if
(
trackId
!=
-
1
)
{
...
...
src/timeline2/model/trackmodel.cpp
View file @
395ebda4
...
...
@@ -313,6 +313,11 @@ bool TrackModel::requestClipInsertion(int clipId, int position, bool updateView,
return
false
;
}
void
TrackModel
::
adjustStackLength
(
int
duration
,
int
newDuration
,
Fun
&
undo
,
Fun
&
redo
)
{
m_effectStack
->
adjustStackLength
(
true
,
0
,
duration
,
0
,
newDuration
,
0
,
undo
,
redo
,
true
);
}
void
TrackModel
::
temporaryUnplugClip
(
int
clipId
)
{
QWriteLocker
locker
(
&
m_lock
);
...
...
src/timeline2/model/trackmodel.hpp
View file @
395ebda4
...
...
@@ -336,6 +336,8 @@ protected:
QDomElement
mixXml
(
QDomDocument
&
document
,
int
cid
)
const
;
/** @brief Check if a mix is reversed (moslty used in tests) */
bool
mixIsReversed
(
int
cid
)
const
;
/** @brief Adjust effect stack length to current track duration */
void
adjustStackLength
(
int
duration
,
int
newDuration
,
Fun
&
undo
,
Fun
&
redo
);
public
slots
:
/** Delete the current track and all its associated clips */
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment