[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-bugs-dist
Subject:    [Bug 103435] KPDF trashing on bad pdf file
From:       Enrico Ros <rosenric () dei ! unipd ! it>
Date:       2005-04-07 20:27:05
Message-ID: 20050407202705.17502.qmail () ktown ! kde ! org
[Download RAW message or body]

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.
         
http://bugs.kde.org/show_bug.cgi?id=103435         




------- Additional Comments From rosenric dei unipd it  2005-04-07 22:27 -------
CVS commit by eros: 

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.


  M +16 -3     core/document.cpp   1.32.2.9
  M +3 -1      ui/pagepainter.cpp   1.7.2.9


--- kdegraphics/kpdf/core/document.cpp  #1.32.2.8:1.32.2.9
 @ -62,4 +62,5  @ class KPDFDocumentPrivate
         QValueList< AllocatedPixmap * > allocatedPixmapsFifo;
         int allocatedPixmapsTotalMemory;
+        bool warnedOutOfMemory;
 
         // timers (memory checking / info saver)
 @ -107,4 +108,5  @ KPDFDocument::KPDFDocument()
     d->memCheckTimer = 0;
     d->saveBookmarksTimer = 0;
+    d->warnedOutOfMemory = false;
 }
 
 @ -1091,8 +1093,19  @ void KPDFDocument::sendGeneratorRequest(
         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;
     }
 

--- kdegraphics/kpdf/ui/pagepainter.cpp  #1.7.2.8:1.7.2.9
 @ -52,5 +52,7  @ void PagePainter::paintPageOnPainter( QP
     /** 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() &&
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic