Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Kdenlive
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
259
Issues
259
List
Boards
Labels
Service Desk
Milestones
Merge Requests
14
Merge Requests
14
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Multimedia
Kdenlive
Commits
3cdb86cd
Commit
3cdb86cd
authored
Dec 01, 2020
by
Jean-Baptiste Mardelle
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix possible crashes in subtitles
parent
42c7c030
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
16 deletions
+28
-16
src/bin/model/subtitlemodel.cpp
src/bin/model/subtitlemodel.cpp
+28
-16
No files found.
src/bin/model/subtitlemodel.cpp
View file @
3cdb86cd
...
...
@@ -114,16 +114,16 @@ void SubtitleModel::importSubtitle(const QString filePath, int offset, bool exte
turn
++
;
continue
;
}
if
(
line
.
contains
(
"-->"
))
{
if
(
line
.
contains
(
QLatin1String
(
"-->"
)
))
{
timeLine
+=
line
;
QStringList
srtTime
=
timeLine
.
split
(
' '
);
QStringList
srtTime
=
timeLine
.
split
(
QLatin1Char
(
' '
)
);
if
(
srtTime
.
count
()
<
3
)
{
// invalid time
continue
;
}
start
=
srtTime
[
0
]
;
start
=
srtTime
.
at
(
0
)
;
startPos
=
stringtoTime
(
start
);
end
=
srtTime
[
2
]
;
end
=
srtTime
.
at
(
2
)
;
endPos
=
stringtoTime
(
end
);
}
else
{
r
++
;
...
...
@@ -136,14 +136,17 @@ void SubtitleModel::importSubtitle(const QString filePath, int offset, bool exte
}
turn
++
;
}
else
{
addSubtitle
(
startPos
+
subtitleOffset
,
endPos
+
subtitleOffset
,
comment
,
undo
,
redo
,
false
);
if
(
endPos
>
startPos
)
{
addSubtitle
(
startPos
+
subtitleOffset
,
endPos
+
subtitleOffset
,
comment
,
undo
,
redo
,
false
);
}
//reinitialize
comment
=
timeLine
=
""
;
comment
.
clear
();
timeLine
.
clear
();
turn
=
0
;
r
=
0
;
}
}
srtFile
.
close
();
}
else
if
(
filePath
.
endsWith
(
".ass"
))
{
}
else
if
(
filePath
.
endsWith
(
QLatin1String
(
".ass"
)
))
{
qDebug
()
<<
"ass File"
;
QString
startTime
,
endTime
,
text
;
QString
EventFormat
,
section
;
...
...
@@ -287,15 +290,23 @@ GenTime SubtitleModel::stringtoTime(QString &str)
double
hours
=
0
,
mins
=
0
,
seconds
=
0
,
ms
=
0
;
double
total_sec
=
0
;
GenTime
pos
;
total
=
str
.
split
(
':'
);
hours
=
atoi
(
total
[
0
].
toStdString
().
c_str
());
mins
=
atoi
(
total
[
1
].
toStdString
().
c_str
());
if
(
total
[
2
].
contains
(
'.'
))
secs
=
total
[
2
].
split
(
'.'
);
//ssa file
total
=
str
.
split
(
QLatin1Char
(
':'
));
if
(
total
.
count
()
!=
3
)
{
// invalid time found
return
GenTime
();
}
hours
=
atoi
(
total
.
at
(
0
).
toStdString
().
c_str
());
mins
=
atoi
(
total
.
at
(
1
).
toStdString
().
c_str
());
if
(
total
.
at
(
2
).
contains
(
QLatin1Char
(
'.'
)))
secs
=
total
.
at
(
2
).
split
(
QLatin1Char
(
'.'
));
//ssa file
else
secs
=
total
[
2
].
split
(
','
);
//srt file
seconds
=
atoi
(
secs
[
0
].
toStdString
().
c_str
());
ms
=
atoi
(
secs
[
1
].
toStdString
().
c_str
());
secs
=
total
.
at
(
2
).
split
(
QLatin1Char
(
','
));
//srt file
if
(
secs
.
count
()
<
2
)
{
seconds
=
atoi
(
total
.
at
(
2
).
toStdString
().
c_str
());
}
else
{
seconds
=
atoi
(
secs
.
at
(
0
).
toStdString
().
c_str
());
ms
=
atoi
(
secs
.
at
(
1
).
toStdString
().
c_str
());
}
total_sec
=
hours
*
3600
+
mins
*
60
+
seconds
+
ms
*
0.001
;
pos
=
GenTime
(
total_sec
);
return
pos
;
...
...
@@ -888,6 +899,7 @@ void SubtitleModel::jsontoSubtitle(const QString &data)
auto
list
=
json
.
array
();
if
(
outF
.
open
(
QIODevice
::
WriteOnly
))
{
QTextStream
out
(
&
outF
);
out
.
setCodec
(
"UTF-8"
);
if
(
assFormat
)
{
out
<<
scriptInfoSection
<<
endl
;
out
<<
styleSection
<<
endl
;
...
...
@@ -980,7 +992,7 @@ int SubtitleModel::getRowForId(int id) const
int
SubtitleModel
::
getSubtitlePlaytime
(
int
id
)
const
{
GenTime
startPos
=
m_timeline
->
m_allSubtitles
.
at
(
id
);
return
(
m_subtitleList
.
at
(
startPos
).
second
-
startPos
)
.
frames
(
pCore
->
getCurrentFps
());
return
m_subtitleList
.
at
(
startPos
).
second
.
frames
(
pCore
->
getCurrentFps
())
-
startPos
.
frames
(
pCore
->
getCurrentFps
());
}
void
SubtitleModel
::
setSelected
(
int
id
,
bool
select
)
...
...
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