From ef1b15ffbc7e8362b2a4cc421823634a571dd0f3 Mon Sep 17 00:00:00 2001 From: Godfrey Laswai Date: Thu, 25 Oct 2018 13:50:54 +0300 Subject: [PATCH] Update Subtitle.cpp For embedded subtitles in video files, skipping produces multiple subtitle objects on the screen make an illusion of repeated subtitles. To prevent this, the changes in above code, accounts for the previous frame and check whether the previous and current text are the same or they differ. If the text differ, it updates the subtitle, if the same, it ignores it. --- src/subtitle/Subtitle.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/subtitle/Subtitle.cpp b/src/subtitle/Subtitle.cpp index 00fd5fd3c..68503d751 100644 --- a/src/subtitle/Subtitle.cpp +++ b/src/subtitle/Subtitle.cpp @@ -501,9 +501,14 @@ QString Subtitle::getText() const priv->current_text.clear(); const int count = qAbs(priv->current_count); QLinkedList::iterator it = priv->current_count > 0 ? priv->itf : priv->itf + (priv->current_count+1); - for (int i = 0; i < count; ++i) { - priv->current_text.append(it->text).append(QStringLiteral("\n")); - ++it; + + for (int i = 0; i < count; ++i) { + if(priv->current_text.startsWith(it->text)){ + break; + } else { + priv->current_text.append(it->text).append(QStringLiteral("\n")); + ++it; + } } priv->current_text = priv->current_text.trimmed(); return priv->current_text;