From fa3f297b064a2ca904cea50103cc5d09f37cf9f2 Mon Sep 17 00:00:00 2001 From: Pino Toscano Date: Thu, 4 Jan 2007 00:02:48 +0000 Subject: [PATCH] Fix a nasty bug that could happened in presentation mode: when requestng -synchronously- a pixmap for the current page, it could be scheduled in the queue. Then, requesting the previous and next page in presentation mode -in a second request- caused the deletion of the original page request The fix consists in requesting all the requests -at once-, so no request is lost. Furthermore, swap the order of previous and next page request so the next page pixmap is requested before (worth touching Document directly?) svn path=/trunk/playground/graphics/okular/; revision=619673 --- ui/presentationwidget.cpp | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/ui/presentationwidget.cpp b/ui/presentationwidget.cpp index 6bee4a210..9c2f215cd 100644 --- a/ui/presentationwidget.cpp +++ b/ui/presentationwidget.cpp @@ -589,32 +589,30 @@ void PresentationWidget::changePage( int newPage ) // operation will take long: set busy cursor QApplication::setOverrideCursor( KCursor::workingCursor() ); // request the pixmap - QLinkedList< Okular::PixmapRequest * > request; - request.push_back( new Okular::PixmapRequest( PRESENTATION_ID, m_frameIndex, pixW, pixH, PRESENTATION_PRIO, false ) ); - m_document->requestPixmaps( request ); + QLinkedList< Okular::PixmapRequest * > requests; + requests.push_back( new Okular::PixmapRequest( PRESENTATION_ID, m_frameIndex, pixW, pixH, PRESENTATION_PRIO, false ) ); // restore cursor QApplication::restoreOverrideCursor(); // ask for next and previous page if not in low memory usage setting if (Okular::Settings::memoryLevel() != Okular::Settings::EnumMemoryLevel::Low && Okular::Settings::enableThreading()) { - QLinkedList< Okular::PixmapRequest * > asyncRequests; - if (newPage + 1 < (int)m_document->pages()) - { - PresentationFrame *nextFrame = m_frames[ newPage + 1 ]; - pixW = nextFrame->geometry.width(); - pixH = nextFrame->geometry.height(); - if ( !nextFrame->page->hasPixmap( PRESENTATION_ID, pixW, pixH ) ) - asyncRequests.push_back( new Okular::PixmapRequest( PRESENTATION_ID, newPage + 1, pixW, pixH, PRESENTATION_PRELOAD_PRIO, true ) ); - } if (newPage - 1 >= 0) { PresentationFrame *prevFrame = m_frames[ newPage - 1 ]; pixW = prevFrame->geometry.width(); pixH = prevFrame->geometry.height(); if ( !prevFrame->page->hasPixmap( PRESENTATION_ID, pixW, pixH ) ) - asyncRequests.push_back( new Okular::PixmapRequest( PRESENTATION_ID, newPage - 1, pixW, pixH, PRESENTATION_PRELOAD_PRIO, true ) ); + requests.push_back( new Okular::PixmapRequest( PRESENTATION_ID, newPage - 1, pixW, pixH, PRESENTATION_PRELOAD_PRIO, true ) ); + } + if (newPage + 1 < (int)m_document->pages()) + { + PresentationFrame *nextFrame = m_frames[ newPage + 1 ]; + pixW = nextFrame->geometry.width(); + pixH = nextFrame->geometry.height(); + if ( !nextFrame->page->hasPixmap( PRESENTATION_ID, pixW, pixH ) ) + requests.push_back( new Okular::PixmapRequest( PRESENTATION_ID, newPage + 1, pixW, pixH, PRESENTATION_PRELOAD_PRIO, true ) ); } - if (!asyncRequests.isEmpty()) m_document->requestPixmaps( asyncRequests ); } + m_document->requestPixmaps( requests ); } else {