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
remotes/origin/KDE/4.0
Pino Toscano 19 years ago
parent bd14706edb
commit fa3f297b06
  1. 26
      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
{

Loading…
Cancel
Save