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
b4e2e0d7
Commit
b4e2e0d7
authored
Jan 13, 2021
by
Jean-Baptiste Mardelle
Browse files
Fix some crashes on subtitle track action
parent
08254e68
Pipeline
#47544
passed with stage
in 10 minutes and 50 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/timeline2/view/timelinecontroller.cpp
View file @
b4e2e0d7
...
...
@@ -2657,15 +2657,30 @@ void TimelineController::switchTrackLock(bool applyToAll)
{
if
(
!
applyToAll
)
{
// apply to active track only
bool
locked
=
m_model
->
getTrackById_const
(
m_activeTrack
)
->
isLocked
();
m_model
->
setTrackLockedState
(
m_activeTrack
,
!
locked
);
if
(
m_activeTrack
==
-
2
)
{
// Subtitle track
switchSubtitleLock
();
}
else
{
bool
locked
=
m_model
->
getTrackById_const
(
m_activeTrack
)
->
isLocked
();
m_model
->
setTrackLockedState
(
m_activeTrack
,
!
locked
);
}
}
else
{
// Invert track lock
const
auto
ids
=
m_model
->
getAllTracksIds
();
// count the number of tracks to be locked
int
toBeLockedCount
=
std
::
accumulate
(
ids
.
begin
(),
ids
.
end
(),
0
,
[
this
](
int
s
,
int
id
)
{
return
s
+
(
m_model
->
getTrackById_const
(
id
)
->
isLocked
()
?
0
:
1
);
});
bool
leaveOneUnlocked
=
toBeLockedCount
==
m_model
->
getTracksCount
();
auto
subtitleModel
=
pCore
->
getSubtitleModel
();
bool
subLocked
=
false
;
bool
hasSubtitleTrack
=
false
;
if
(
subtitleModel
)
{
hasSubtitleTrack
=
true
;
subLocked
=
subtitleModel
->
isLocked
();
if
(
!
subLocked
)
{
toBeLockedCount
++
;
}
}
bool
leaveOneUnlocked
=
toBeLockedCount
==
m_model
->
getTracksCount
()
+
hasSubtitleTrack
?
1
:
0
;
for
(
const
int
id
:
ids
)
{
// leave active track unlocked
if
(
leaveOneUnlocked
&&
id
==
m_activeTrack
)
{
...
...
@@ -2674,11 +2689,19 @@ void TimelineController::switchTrackLock(bool applyToAll)
bool
isLocked
=
m_model
->
getTrackById_const
(
id
)
->
isLocked
();
m_model
->
setTrackLockedState
(
id
,
!
isLocked
);
}
if
(
hasSubtitleTrack
)
{
if
(
!
leaveOneUnlocked
||
m_activeTrack
!=
-
2
)
{
switchSubtitleLock
();
}
}
}
}
void
TimelineController
::
switchTargetTrack
()
{
if
(
m_activeTrack
<
0
)
{
return
;
}
bool
isAudio
=
m_model
->
getTrackById_const
(
m_activeTrack
)
->
getProperty
(
"kdenlive:audio_track"
).
toInt
()
==
1
;
if
(
isAudio
)
{
QMap
<
int
,
int
>
current
=
m_model
->
m_audioTarget
;
...
...
@@ -2780,17 +2803,30 @@ void TimelineController::selectAll()
for
(
const
auto
&
clp
:
m_model
->
m_allCompositions
)
{
ids
.
insert
(
clp
.
first
);
}
// Subtitles
for
(
const
auto
&
sub
:
m_model
->
m_allSubtitles
)
{
ids
.
insert
(
sub
.
first
);
}
m_model
->
requestSetSelection
(
ids
);
}
void
TimelineController
::
selectCurrentTrack
()
{
std
::
unordered_set
<
int
>
ids
;
for
(
const
auto
&
clp
:
m_model
->
getTrackById_const
(
m_activeTrack
)
->
m_allClips
)
{
ids
.
insert
(
clp
.
first
);
if
(
m_activeTrack
==
-
1
)
{
return
;
}
for
(
const
auto
&
clp
:
m_model
->
getTrackById_const
(
m_activeTrack
)
->
m_allCompositions
)
{
ids
.
insert
(
clp
.
first
);
std
::
unordered_set
<
int
>
ids
;
if
(
m_activeTrack
==
-
2
)
{
for
(
const
auto
&
sub
:
m_model
->
m_allSubtitles
)
{
ids
.
insert
(
sub
.
first
);
}
}
else
{
for
(
const
auto
&
clp
:
m_model
->
getTrackById_const
(
m_activeTrack
)
->
m_allClips
)
{
ids
.
insert
(
clp
.
first
);
}
for
(
const
auto
&
clp
:
m_model
->
getTrackById_const
(
m_activeTrack
)
->
m_allCompositions
)
{
ids
.
insert
(
clp
.
first
);
}
}
m_model
->
requestSetSelection
(
ids
);
}
...
...
Write
Preview
Supports
Markdown
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