mirror of
https://invent.kde.org/graphics/okular
synced 2024-10-02 14:14:10 +00:00
Keep a list of the currently active pixmap requests (usually one at most), and wait for their finish when closing the document.
svn path=/trunk/KDE/kdegraphics/okular/; revision=769281
This commit is contained in:
parent
283852c563
commit
e9bd289993
|
@ -615,6 +615,7 @@ void DocumentPrivate::sendGeneratorRequest()
|
|||
// we always have to unlock _before_ the generatePixmap() because
|
||||
// a sync generation would end with requestDone() -> deadlock, and
|
||||
// we can not really know if the generator can do async requests
|
||||
m_executingPixmapRequests.push_back( request );
|
||||
m_pixmapRequestsMutex.unlock();
|
||||
m_generator->generatePixmap( request );
|
||||
}
|
||||
|
@ -1313,6 +1314,22 @@ void Document::closeDocument()
|
|||
if ( !d->m_generator )
|
||||
return;
|
||||
|
||||
QEventLoop loop;
|
||||
bool startEventLoop = false;
|
||||
do
|
||||
{
|
||||
d->m_pixmapRequestsMutex.lock();
|
||||
startEventLoop = !d->m_executingPixmapRequests.isEmpty();
|
||||
d->m_pixmapRequestsMutex.unlock();
|
||||
if ( startEventLoop )
|
||||
{
|
||||
d->m_closingLoop = &loop;
|
||||
loop.exec();
|
||||
d->m_closingLoop = 0;
|
||||
}
|
||||
}
|
||||
while ( startEventLoop );
|
||||
|
||||
if ( d->m_fontThread )
|
||||
{
|
||||
disconnect( d->m_fontThread, 0, this, 0 );
|
||||
|
@ -2597,9 +2614,20 @@ const KComponentData* Document::componentData() const
|
|||
|
||||
void DocumentPrivate::requestDone( PixmapRequest * req )
|
||||
{
|
||||
if ( !m_generator || !req )
|
||||
if ( !req )
|
||||
return;
|
||||
|
||||
if ( !m_generator || m_closingLoop )
|
||||
{
|
||||
m_pixmapRequestsMutex.lock();
|
||||
m_executingPixmapRequests.removeAll( req );
|
||||
m_pixmapRequestsMutex.unlock();
|
||||
delete req;
|
||||
if ( m_closingLoop )
|
||||
m_closingLoop->exit();
|
||||
return;
|
||||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
if ( !m_generator->canGeneratePixmap() )
|
||||
kDebug(OkularDebug) << "requestDone with generator not in READY state.";
|
||||
|
@ -2636,6 +2664,9 @@ void DocumentPrivate::requestDone( PixmapRequest * req )
|
|||
#endif
|
||||
|
||||
// 3. delete request
|
||||
m_pixmapRequestsMutex.lock();
|
||||
m_executingPixmapRequests.removeAll( req );
|
||||
m_pixmapRequestsMutex.unlock();
|
||||
delete req;
|
||||
|
||||
// 4. start a new generation if some is pending
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include "fontinfo.h"
|
||||
#include "generator.h"
|
||||
|
||||
class QEventLoop;
|
||||
class QTimer;
|
||||
class KTemporaryFile;
|
||||
|
||||
|
@ -70,6 +71,7 @@ class DocumentPrivate
|
|||
m_saveBookmarksTimer( 0 ),
|
||||
m_generator( 0 ),
|
||||
m_generatorsLoaded( false ),
|
||||
m_closingLoop( 0 ),
|
||||
m_fontsCached( false )
|
||||
{
|
||||
}
|
||||
|
@ -141,6 +143,7 @@ class DocumentPrivate
|
|||
// observers / requests / allocator stuff
|
||||
QMap< int, DocumentObserver * > m_observers;
|
||||
QLinkedList< PixmapRequest * > m_pixmapRequestsStack;
|
||||
QLinkedList< PixmapRequest * > m_executingPixmapRequests;
|
||||
QMutex m_pixmapRequestsMutex;
|
||||
QLinkedList< AllocatedPixmap * > m_allocatedPixmapsFifo;
|
||||
qulonglong m_allocatedPixmapsTotalMemory;
|
||||
|
@ -176,6 +179,8 @@ class DocumentPrivate
|
|||
// cache of the mimetype we support
|
||||
QStringList m_supportedMimeTypes;
|
||||
|
||||
QEventLoop *m_closingLoop;
|
||||
|
||||
QPointer< FontExtractionThread > m_fontThread;
|
||||
bool m_fontsCached;
|
||||
FontInfo::List m_fontsCache;
|
||||
|
|
Loading…
Reference in a new issue