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
d180c984
Commit
d180c984
authored
Nov 30, 2020
by
Jean-Baptiste Mardelle
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix possible crash on .ass subtutle error and dropping subtitle in timeline
parent
05fda675
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
19 deletions
+34
-19
src/bin/model/subtitlemodel.cpp
src/bin/model/subtitlemodel.cpp
+22
-15
src/timeline2/view/timelinecontroller.cpp
src/timeline2/view/timelinecontroller.cpp
+11
-3
src/timeline2/view/timelinecontroller.h
src/timeline2/view/timelinecontroller.h
+1
-1
No files found.
src/bin/model/subtitlemodel.cpp
View file @
d180c984
...
...
@@ -200,7 +200,9 @@ void SubtitleModel::importSubtitle(const QString filePath, int offset, bool exte
styleSection
+=
line
+
"
\n
"
;
//Style: Name,Fontname,Fontsize,PrimaryColour,SecondaryColour,OutlineColour,BackColour,Bold,Italic,Underline,StrikeOut,ScaleX,ScaleY,Spacing,Angle,BorderStyle,Outline,Shadow,Alignment,MarginL,MarginR,MarginV,Encoding
styleFormat
=
(
line
.
split
(
": "
)[
1
].
replace
(
" "
,
""
)).
split
(
','
);
styleName
=
styleFormat
[
0
];
if
(
!
styleFormat
.
isEmpty
())
{
styleName
=
styleFormat
.
first
();
}
}
//qDebug() << "\n turn != 0 " << turn<< line;
...
...
@@ -214,10 +216,13 @@ void SubtitleModel::importSubtitle(const QString filePath, int offset, bool exte
//qDebug() << format << format.count();
maxSplit
=
format
.
count
();
//TIME
startTime
=
format
[
1
];
endTime
=
format
[
2
];
if
(
maxSplit
>
2
)
startTime
=
format
.
at
(
1
);
if
(
maxSplit
>
3
)
endTime
=
format
.
at
(
2
);
// Text
text
=
format
[
9
];
if
(
maxSplit
>
9
)
text
=
format
.
at
(
9
);
//qDebug()<< startTime << endTime << text;
}
else
{
QString
EventDialogue
;
...
...
@@ -225,17 +230,19 @@ void SubtitleModel::importSubtitle(const QString filePath, int offset, bool exte
start
=
""
;
end
=
""
;
comment
=
""
;
EventDialogue
+=
line
;
dialogue
=
EventDialogue
.
split
(
": "
)[
1
].
split
(
','
);
QString
remainingStr
=
","
+
EventDialogue
.
split
(
": "
)[
1
].
section
(
','
,
maxSplit
);
//qDebug()<< dialogue;
//TIME
start
=
dialogue
[
1
];
startPos
=
stringtoTime
(
start
);
end
=
dialogue
[
2
];
endPos
=
stringtoTime
(
end
);
// Text
comment
=
dialogue
[
9
]
+
remainingStr
;
//qDebug()<<"Start: "<< start << "End: "<<end << comment;
addSubtitle
(
startPos
+
subtitleOffset
,
endPos
+
subtitleOffset
,
comment
,
undo
,
redo
,
false
);
if
(
dialogue
.
count
()
>
9
)
{
QString
remainingStr
=
","
+
EventDialogue
.
split
(
": "
)[
1
].
section
(
','
,
maxSplit
);
//qDebug()<< dialogue;
//TIME
start
=
dialogue
.
at
(
1
);
startPos
=
stringtoTime
(
start
);
end
=
dialogue
.
at
(
2
);
endPos
=
stringtoTime
(
end
);
// Text
comment
=
dialogue
.
at
(
9
)
+
remainingStr
;
//qDebug()<<"Start: "<< start << "End: "<<end << comment;
addSubtitle
(
startPos
+
subtitleOffset
,
endPos
+
subtitleOffset
,
comment
,
undo
,
redo
,
false
);
}
}
}
turn
++
;
...
...
src/timeline2/view/timelinecontroller.cpp
View file @
d180c984
...
...
@@ -3555,7 +3555,12 @@ void TimelineController::urlDropped(QStringList droppedFile, int frame, int tid)
m_recordTrack
=
tid
;
m_recordStart
=
{
frame
,
-
1
};
qDebug
()
<<
"=== GOT DROPPED FILED: "
<<
droppedFile
<<
"
\n
======"
;
finishRecording
(
QUrl
(
droppedFile
.
first
()).
toLocalFile
());
if
(
droppedFile
.
first
().
endsWith
(
QLatin1String
(
".ass"
))
||
droppedFile
.
first
().
endsWith
(
QLatin1String
(
".srt"
)))
{
// Subtitle dropped, import
importSubtitle
(
droppedFile
.
first
());
}
else
{
finishRecording
(
QUrl
(
droppedFile
.
first
()).
toLocalFile
());
}
}
void
TimelineController
::
finishRecording
(
const
QString
&
recordedFile
)
...
...
@@ -3860,14 +3865,17 @@ void TimelineController::addSubtitle(int startframe)
}
}
void
TimelineController
::
importSubtitle
()
void
TimelineController
::
importSubtitle
(
const
QString
path
)
{
QPointer
<
QDialog
>
d
=
new
QDialog
;
Ui
::
ImportSub_UI
view
;
view
.
setupUi
(
d
);
if
(
!
path
.
isEmpty
())
{
view
.
subtitle_url
->
setText
(
path
);
}
d
->
setWindowTitle
(
i18n
(
"Import Subtitle"
));
if
(
d
->
exec
()
==
QDialog
::
Accepted
&&
!
view
.
subtitle_url
->
url
().
isEmpty
())
{
auto
subtitleModel
=
pCore
->
getSubtitleModel
();
auto
subtitleModel
=
pCore
->
getSubtitleModel
(
true
);
int
offset
=
0
;
if
(
view
.
cursor_pos
->
isChecked
())
{
offset
=
pCore
->
getTimelinePosition
();
...
...
src/timeline2/view/timelinecontroller.h
View file @
d180c984
...
...
@@ -577,7 +577,7 @@ public:
/** @brief Delete subtitle clip with frame as start position*/
Q_INVOKABLE
void
deleteSubtitle
(
int
frameframe
,
int
endframe
,
QString
Ctext
);
/** @brief Import a subtitle file*/
void
importSubtitle
();
void
importSubtitle
(
const
QString
path
=
QString
()
);
/** @brief Export a subtitle file*/
void
exportSubtitle
();
...
...
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