diff --git a/core/document.cpp b/core/document.cpp index d4e1507c4..e2ecb3055 100644 --- a/core/document.cpp +++ b/core/document.cpp @@ -61,6 +61,7 @@ class KPDFDocumentPrivate QValueList< PixmapRequest * > pixmapRequestsStack; QValueList< AllocatedPixmap * > allocatedPixmapsFifo; int allocatedPixmapsTotalMemory; + bool warnedOutOfMemory; // timers (memory checking / info saver) QTimer * memCheckTimer; @@ -106,6 +107,7 @@ KPDFDocument::KPDFDocument() d->allocatedPixmapsTotalMemory = 0; d->memCheckTimer = 0; d->saveBookmarksTimer = 0; + d->warnedOutOfMemory = false; } KPDFDocument::~KPDFDocument() @@ -1090,10 +1092,21 @@ void KPDFDocument::sendGeneratorRequest() PixmapRequest * r = d->pixmapRequestsStack.last(); d->pixmapRequestsStack.pop_back(); // request only if page isn't already present - if ( !r->page->hasPixmap( r->id, r->width, r->height ) ) - request = r; - else + if ( r->page->hasPixmap( r->id, r->width, r->height ) ) delete r; + else if ( (long)r->width * (long)r->height > 20000000L ) + { + delete r; + if ( !d->warnedOutOfMemory ) + { + kdWarning() << "Running out of memory on page " << r->pageNumber + << " (" << r->width << "x" << r->height << " px);" << endl; + kdWarning() << "this message will be reported only once." << endl; + d->warnedOutOfMemory = true; + } + } + else + request = r; } // if no request found (or already generated), return diff --git a/ui/pagepainter.cpp b/ui/pagepainter.cpp index c97699bf8..89bdc6645 100644 --- a/ui/pagepainter.cpp +++ b/ui/pagepainter.cpp @@ -51,7 +51,9 @@ void PagePainter::paintPageOnPainter( QPainter * destPainter, const KPDFPage * p /** 1B - IF NO PIXMAP, DRAW EMPTY PAGE **/ double pixmapRescaleRatio = pixmap ? scaledWidth / (double)pixmap->width() : -1; - if ( !pixmap || pixmapRescaleRatio > 20.0 || pixmapRescaleRatio < 0.25 ) + long pixmapPixels = pixmap ? (long)pixmap->width() * (long)pixmap->height() : 0; + if ( !pixmap || pixmapRescaleRatio > 20.0 || pixmapRescaleRatio < 0.25 || + (scaledWidth != pixmap->width() && pixmapPixels > 6000000L) ) { if ( Settings::changeColors() && Settings::renderMode() == Settings::EnumRenderMode::Paper )