Commit 6d8451b5 authored by Jean-Baptiste Mardelle's avatar Jean-Baptiste Mardelle
Browse files

FIx possible crash on subtitle resize, and allow cutting unselected subtitle.

Related to #936
parent 46650e6a
Pipeline #49846 passed with stage
in 10 minutes and 21 seconds
......@@ -485,19 +485,26 @@ std::unordered_set<int> SubtitleModel::getItemsInRange(int startFrame, int endFr
continue;
}
if (subtitles.first >= startTime || subtitles.second.second >= startTime) {
matching.emplace(getIdForStartPos(subtitles.first));
int sid = getIdForStartPos(subtitles.first);
if (sid > -1) {
matching.emplace(sid);
} else {
qDebug()<<"==== FOUND INVALID SUBTILE AT: "<<subtitles.first.frames(pCore->getCurrentFps());
}
}
}
return matching;
}
void SubtitleModel::cutSubtitle(int position)
bool SubtitleModel::cutSubtitle(int position)
{
Fun redo = []() { return true; };
Fun undo = []() { return true; };
if (cutSubtitle(position, undo, redo)) {
pCore->pushUndo(undo, redo, i18n("Cut clip"));
return true;
}
return false;
}
......
......@@ -122,7 +122,7 @@ public:
void setSelected(int id, bool select);
bool isSelected(int id) const;
/** @brief Cut a subtitle */
void cutSubtitle(int position);
bool cutSubtitle(int position);
bool cutSubtitle(int position, Fun &undo, Fun &redo);
QString getText(int id) const;
int getRowForId(int id) const;
......
......@@ -1541,6 +1541,10 @@ void TimelineController::cutClipUnderCursor(int position, int track)
if (cid >= 0 && TimelineFunctions::requestClipCut(m_model, cid, position)) {
foundClip = true;
}
} else if (track == -2) {
// Subtitle cut
auto subtitleModel = pCore->getSubtitleModel();
foundClip = subtitleModel->cutSubtitle(position);
}
}
if (!foundClip) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment