Commit 57f0453b authored by Enrico Ros's avatar Enrico Ros

Document:

  Warning before running out of memory and stop pixmap request.
  CCMAIL: 103435@bugs.kde.org
PagePainter:
  Not related to the bug: avoid scaling up slow pixmaps.

svn path=/branches/kpdf_annotations/kdegraphics/kpdf/; revision=403884
parent bcc2542e
......@@ -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
......
......@@ -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 )
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment