forked from qt-creator/qt-creator
ImageViewer: Fix crash when opening invalid movie
Qt 6 sends the finished signal directly from QMovie::start, so if we connect QMovie::finished directly to QMovie::start, we end up in an endless recursion and stack exhaustion. Use a queued connection, and do not restart a movie if it went invalid. Fixes: QTCREATORBUG-26377 Change-Id: I9980615f44d0cf7e92f85c010427bd6b67046949 Reviewed-by: Robert Löhning <robert.loehning@qt.io> Reviewed-by: Alessandro Portale <alessandro.portale@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
@@ -126,7 +126,15 @@ Core::IDocument::OpenResult ImageViewerFile::openImpl(QString *errorString,
|
|||||||
m_type = TypeMovie;
|
m_type = TypeMovie;
|
||||||
m_movie = new QMovie(fileName, QByteArray(), this);
|
m_movie = new QMovie(fileName, QByteArray(), this);
|
||||||
m_movie->setCacheMode(QMovie::CacheAll);
|
m_movie->setCacheMode(QMovie::CacheAll);
|
||||||
connect(m_movie, &QMovie::finished, m_movie, &QMovie::start);
|
connect(
|
||||||
|
m_movie,
|
||||||
|
&QMovie::finished,
|
||||||
|
m_movie,
|
||||||
|
[this] {
|
||||||
|
if (m_movie->isValid())
|
||||||
|
m_movie->start();
|
||||||
|
},
|
||||||
|
Qt::QueuedConnection);
|
||||||
connect(m_movie, &QMovie::resized, this, &ImageViewerFile::imageSizeChanged);
|
connect(m_movie, &QMovie::resized, this, &ImageViewerFile::imageSizeChanged);
|
||||||
m_movie->start();
|
m_movie->start();
|
||||||
m_isPaused = false; // force update
|
m_isPaused = false; // force update
|
||||||
|
Reference in New Issue
Block a user