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
ec0ff97c
Commit
ec0ff97c
authored
Dec 17, 2020
by
Jean-Baptiste Mardelle
Browse files
Fix some crashes with locked subtitle track
parent
e21a4d11
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/bin/model/subtitlemodel.cpp
View file @
ec0ff97c
...
...
@@ -1068,7 +1068,7 @@ void SubtitleModel::switchLocked()
m_subtitleFilter
->
set
(
"kdenlive:locked"
,
isLocked
?
0
:
1
);
// En/disable snapping on lock
std
::
vector
<
std
::
weak_ptr
<
SnapInterface
>>
validSnapModels
;
/*
std::vector<std::weak_ptr<SnapInterface>> validSnapModels;
for (const auto &snapModel : m_regSnaps) {
if (auto ptr = snapModel.lock()) {
validSnapModels.push_back(snapModel);
...
...
@@ -1093,7 +1093,7 @@ void SubtitleModel::switchLocked()
int id = m_selected.takeFirst();
updateSub(id, {SelectedRole});
}
}
}
*/
}
...
...
@@ -1117,3 +1117,11 @@ void SubtitleModel::loadProperties(QMap<QString, QString> subProperties)
++
i
;
}
}
void
SubtitleModel
::
allSnaps
(
std
::
vector
<
int
>
&
snaps
)
{
for
(
const
auto
&
subtitle
:
m_subtitleList
)
{
snaps
.
push_back
(
subtitle
.
first
.
frames
(
pCore
->
getCurrentFps
()));
snaps
.
push_back
(
subtitle
.
second
.
second
.
frames
(
pCore
->
getCurrentFps
()));
}
}
src/bin/model/subtitlemodel.hpp
View file @
ec0ff97c
...
...
@@ -137,6 +137,8 @@ public:
bool
isLocked
()
const
;
/** @brief Load some subtitle filter properties from file */
void
loadProperties
(
QMap
<
QString
,
QString
>
subProperties
);
/** @brief Add all subtitle items to snaps */
void
allSnaps
(
std
::
vector
<
int
>
&
snaps
);
public
slots
:
/** @brief Function that parses through a subtitle file */
...
...
src/timeline2/model/timelinemodel.cpp
View file @
ec0ff97c
...
...
@@ -1880,7 +1880,6 @@ bool TimelineModel::requestSubtitleDeletion(int clipId, Fun &undo, Fun &redo, bo
UPDATE_UNDO_REDO
(
operation
,
reverse
,
undo
,
redo
);
return
true
;
}
undo
();
return
false
;
}
...
...
@@ -2881,10 +2880,15 @@ int TimelineModel::requestItemResize(int itemId, int size, bool right, bool logU
TRACE_RES
(
-
1
)
return
-
1
;
}
int
in
=
getItemPosition
(
itemId
)
;
int
in
=
0
;
int
offset
=
getItemPlaytime
(
itemId
);
int
out
=
in
+
offset
;
size
=
requestItemResizeInfo
(
itemId
,
in
,
out
,
size
,
right
,
snapDistance
);
int
tid
=
getItemTrackId
(
itemId
);
int
out
=
offset
;
if
(
tid
!=
-
1
)
{
in
=
getItemPosition
(
itemId
);
out
+=
in
;
size
=
requestItemResizeInfo
(
itemId
,
in
,
out
,
size
,
right
,
snapDistance
);
}
offset
-=
size
;
Fun
undo
=
[]()
{
return
true
;
};
Fun
redo
=
[]()
{
return
true
;
};
...
...
@@ -2896,8 +2900,7 @@ int TimelineModel::requestItemResize(int itemId, int size, bool right, bool logU
std
::
unordered_set
<
int
>
all_items
;
QList
<
int
>
tracksWithMixes
;
all_items
.
insert
(
itemId
);
if
(
logUndo
&&
isClip
(
itemId
))
{
int
tid
=
getItemTrackId
(
itemId
);
if
(
logUndo
&&
isClip
(
itemId
))
{
if
(
tid
>
-
1
)
{
if
(
right
)
{
if
(
getTrackById_const
(
tid
)
->
hasEndMix
(
itemId
))
{
...
...
@@ -3078,6 +3081,9 @@ int TimelineModel::requestItemResize(int itemId, int size, bool right, bool logU
if
(
tid
>
-
1
&&
getTrackById_const
(
tid
)
->
isLocked
())
{
continue
;
}
if
(
tid
==
-
2
&&
m_subtitleModel
&&
m_subtitleModel
->
isLocked
())
{
continue
;
}
if
(
right
)
{
finalSize
=
finalPos
-
getItemPosition
(
id
);
}
else
{
...
...
@@ -3871,7 +3877,8 @@ int TimelineModel::getNextSnapPos(int pos, std::vector<int> &snaps)
}
++
it
;
}
if
(
tracks
.
isEmpty
()
||
tracks
.
count
()
==
(
int
)
m_allTracks
.
size
())
{
bool
hasSubtitles
=
m_subtitleModel
&&
!
m_allSubtitles
.
empty
();
if
((
tracks
.
isEmpty
()
||
tracks
.
count
()
==
(
int
)
m_allTracks
.
size
())
&&
(
!
hasSubtitles
||
!
m_subtitleModel
->
isLocked
()))
{
// No active track, use all possible snap points
return
m_snaps
->
getNextPoint
((
int
)
pos
);
}
...
...
@@ -3883,6 +3890,11 @@ int TimelineModel::getNextSnapPos(int pos, std::vector<int> &snaps)
clip
->
allSnaps
(
snaps
);
}
}
// Subtitle snaps
if
(
hasSubtitles
&&
!
m_subtitleModel
->
isLocked
())
{
// Add subtitle snaps
m_subtitleModel
->
allSnaps
(
snaps
);
}
// sort snaps
std
::
sort
(
snaps
.
begin
(),
snaps
.
end
());
for
(
auto
i
:
snaps
)
{
...
...
@@ -3904,7 +3916,8 @@ int TimelineModel::getPreviousSnapPos(int pos, std::vector<int> &snaps)
}
++
it
;
}
if
(
tracks
.
isEmpty
()
||
tracks
.
count
()
==
(
int
)
m_allTracks
.
size
())
{
bool
hasSubtitles
=
m_subtitleModel
&&
!
m_allSubtitles
.
empty
();
if
((
tracks
.
isEmpty
()
||
tracks
.
count
()
==
(
int
)
m_allTracks
.
size
())
&&
(
!
hasSubtitles
||
!
m_subtitleModel
->
isLocked
()))
{
// No active track, use all possible snap points
return
m_snaps
->
getPreviousPoint
((
int
)
pos
);
}
...
...
@@ -3916,6 +3929,11 @@ int TimelineModel::getPreviousSnapPos(int pos, std::vector<int> &snaps)
clip
->
allSnaps
(
snaps
);
}
}
// Subtitle snaps
if
(
hasSubtitles
&&
!
m_subtitleModel
->
isLocked
())
{
// Add subtitle snaps
m_subtitleModel
->
allSnaps
(
snaps
);
}
// sort snaps
std
::
sort
(
snaps
.
begin
(),
snaps
.
end
());
// sort descending
...
...
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