From 313d60c107d9659efd5e93ba5a036054f6b1ebba Mon Sep 17 00:00:00 2001 From: Davy Durham Date: Thu, 3 Jan 2013 21:48:07 -0600 Subject: Fix glitch on MNG animation Loops when QMovie caching is enabled libmng delivers the last animation frame with a 1ms delay, and delivers an extra blank frame after that with the proper delay time, but this confuses QMovie when QMovie::cacheMode() == QMovie::CacheAll. Task-Number: QTBUG-28894 Change-Id: Ic508c886286d9ec6786482927f321c6d77b68619 Reviewed-by: aavit --- src/plugins/imageformats/mng/qmnghandler.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/plugins/imageformats/mng/qmnghandler.cpp b/src/plugins/imageformats/mng/qmnghandler.cpp index 4a361ab..d99ce43 100644 --- a/src/plugins/imageformats/mng/qmnghandler.cpp +++ b/src/plugins/imageformats/mng/qmnghandler.cpp @@ -263,6 +263,7 @@ mng_bool QMngHandlerPrivate::processHeader(mng_uint32 iWidth, mng_uint32 iHeight bool QMngHandlerPrivate::getNextImage(QImage *result) { mng_retcode ret; + const bool savedHaveReadAll = haveReadAll; if (haveReadNone) { haveReadNone = false; ret = mng_readdisplay(hMNG); @@ -271,6 +272,13 @@ bool QMngHandlerPrivate::getNextImage(QImage *result) } if ((MNG_NOERROR == ret) || (MNG_NEEDTIMERWAIT == ret)) { *result = image; + + // QTBUG-28894 -- libmng produces an extra frame at the end + // of the animation on the first loop only. + if (nextDelay == 1 && (!savedHaveReadAll && haveReadAll)) { + ret = mng_display_resume(hMNG); + } + frameIndex = nextIndex++; if (haveReadAll && (frameCount == 0)) frameCount = nextIndex; -- cgit v1.2.3