Version: 3.3.6 (using KDE KDE 3.5.2) Installed from: SuSE RPMs OS: Linux I've created a multipage TIFF file with AFPL Ghostscript (using "-sDEVICE=tiffg4"); file attached. * KFax displays it just fine; * the default display zoom level seems to be one level below the "Actual Size" * scrolling (page 1 --> 10 and back) works if no zooming is applied; * scrolling (page 1 --> 10 and back) works with zooming in by 1 level applied; * scrolling (page 1 --> 10 and back) works with zooming out by 1 level * KFax crashes if scrolling is attempted with zooming out 2 levels (seems to be the maximum levels) applied; The tiffg4 file and a (probably not so useful) backtrace is attached.
Created attachment 16325 [details] Multipage TIFF G4 file created with AFPL Ghostscript 8.53
Created attachment 16326 [details] Backtrace of KFax crash when zooming out of multipage TIFF G4 file and scrolling
SVN commit 546368 by deller: fix Bug 128235: kfax crash: multipage TIFF --> zoom out --> hit "PgDown" to go to next page BUG: 128235 M +56 -92 kfax.cpp --- branches/KDE/3.5/kdegraphics/kfax/kfax.cpp #546367:546368 @@ -344,7 +344,7 @@ { actSize->setEnabled( Image && oz > 0 ); actZoomIn->setEnabled( Image && oz > 0 ); - actZoomOut->setEnabled( Image && oz < MAXZOOM && Image->width >= 256 ); + actZoomOut->setEnabled( Image && oz < MAXZOOM-1 && Image->width >= 256 ); } bool TopLevel::queryClose() @@ -434,30 +434,46 @@ actRecent->addURL( fileURL ); } + +static void freeImages() +{ + int i; + for (i = 1; i < MAXZOOM; i++) { + if (Images[i]) + FreeImage(Images[i]); + Images[i] = NULL; + } +} + +static XImage *generateZoomImages(int maxzoom) +{ + int i; + for (i = 1; i < MAXZOOM; i++){ + if (!Images[i-1]) + continue; + Image = Images[i] = ZoomImage(Images[i-1]); + if(Image == NULL){// out of memory + Image = Images[i -1]; + break; + } + } + + i = maxzoom; + while (!Images[i]) + i--; + return Images[i]; +} + + void TopLevel::zoom( int factor ) { if(!thispage || !Image || !faxqtwin || !display_is_setup) return; - Image = Images[ factor ]; Resize = Refresh = 1; - int i; + Image = generateZoomImages(factor); - if (Image == NULL) { - for (i = factor; i && (Images[i] == NULL); i--) - ; - for (; i != factor; i++){ - Images[i+1] = ZoomImage(Images[i]); - Image = Images[i+1]; - - if(Images[i+1] == NULL){ // out of memory - Image = Images[i]; - break; - } - } - } - PaneWidth = Image->width; PaneHeight = Image->height; @@ -907,8 +923,7 @@ XDefineCursor(qtdisplay, Win, ReadyCursor); XFlush(qtdisplay); - for (oz = 0; oz < MAXZOOM; oz++) - Images[oz] = NULL; + memset(Images, 0, sizeof(Images)); // Start at half the Size oz = 1; @@ -1129,39 +1144,23 @@ if(!thispage || !Image || !faxqtwin || !display_is_setup) return; - XImage *newrotimage = NULL; - XDefineCursor(qtdisplay, Win, WorkCursor); XFlush(qtdisplay); - newrotimage = RotImage(Images[0]); + XImage *newrotimage = RotImage(Images[0]); + XDefineCursor(qtdisplay, Win, ReadyCursor); + if(newrotimage == NULL){ // out of memory - XDefineCursor(qtdisplay, Win, ReadyCursor); return; } - thispage->extra = Image = newrotimage; + thispage->extra = Images[0] = newrotimage; thispage->orient ^= TURN_L; - int i; - for (i = 1; Images[i]; i++) { - FreeImage(Images[i]); - Images[i] = NULL; - } + freeImages(); + Image = generateZoomImages(oz); - Images[0] = Image; - - for (i = 1; i <= oz; i++){ - - Images[i] = ZoomImage(Images[i-1]); - Image = Images[i]; - if(Images[i] == NULL){// out of memory - Image = Images[i -1]; - break; - } - } - { int t = xpos ; xpos= ypos; ypos= t; } Refresh = Resize = 1; @@ -1174,32 +1173,23 @@ if(!thispage || !Image || !faxqtwin || !display_is_setup) return; - XImage *newflipimage = NULL; - XDefineCursor(qtdisplay, Win, WorkCursor); XFlush(qtdisplay); - newflipimage = FlipImage(Images[0]); + XImage *newflipimage = FlipImage(Images[0]); + XDefineCursor(qtdisplay, Win, ReadyCursor); + if(newflipimage == NULL){ // out of memory - XDefineCursor(qtdisplay, Win, ReadyCursor); return; } thispage->extra = Images[0] = newflipimage; thispage->orient ^= TURN_U; - int i; - for (i = 1; Images[i]; i++) { - FreeImage(Images[i]); - Images[i] = ZoomImage(Images[i-1]); - if(Images[i]== NULL){// out of memory - break; - } - } + freeImages(); + Image = generateZoomImages(oz); - Image = Images[QMIN(i-1,oz)]; - Refresh = Resize = 1; putImage(); } @@ -1209,29 +1199,21 @@ if(!thispage || !Image || !faxqtwin || !display_is_setup) return; - XImage *newmirror = NULL; - XDefineCursor(qtdisplay, Win, WorkCursor); XFlush(qtdisplay); - newmirror = MirrorImage(Images[0]); + XImage *newmirror = MirrorImage(Images[0]); + XDefineCursor(qtdisplay, Win, ReadyCursor); + if(newmirror == NULL){ // out of memory - XDefineCursor(qtdisplay, Win, ReadyCursor); return; } thispage->extra = Images[0] = newmirror; - thispage->orient ^= TURN_M; - int i; - for (i = 1; Images[i]; i++) { - FreeImage(Images[i]); - Images[i] = ZoomImage(Images[i-1]); - if (Images[i] == NULL) // out of memory - break; - } - Image = Images[QMIN(oz,i-1)]; + freeImages(); + Image = generateZoomImages(oz); Refresh = Resize = 1; putImage(); @@ -1296,6 +1278,7 @@ updateGoActions(); } + void TopLevel::nextPage() { if(!thispage) @@ -1332,25 +1315,16 @@ void TopLevel::newPage(){ - if(!display_is_setup) SetupDisplay(); - XDefineCursor(qtdisplay, Win, WorkCursor); XFlush(qtdisplay); + freeImages(); - int i; - - for (i = 1; Images[i]; i++) { - FreeImage(Images[i]); - Images[i] = NULL; - } - int k = -1; - if(!thispage) { XDefineCursor(qtdisplay, Win, ReadyCursor); return; @@ -1383,15 +1357,8 @@ setCaption(thispage->name); - for (i = 1; i <= oz; i++){ - Images[i] = ZoomImage(Images[i-1]); - Image = Images[i]; - if (Images[i] == NULL){ // out of memory - Image = Images[i-1]; - break; - } - } - + Image = generateZoomImages(oz); + PaneWidth = Image->width; PaneHeight = Image->height; Refresh = 1; @@ -1425,16 +1392,13 @@ if(display_is_setup) XClearWindow(qtdisplay, Win); - for (int i = 1; Images[i]; i++) { - FreeImage(Images[i]); - Images[i] = NULL; - } + freeImages(); pagenode *pn; - for (pn = firstpage; pn; pn = pn->next){ if(Pimage(pn)){ FreeImage(Pimage(pn)); + pn->extra = NULL; } }
Boah!, Helge :-) Thanks a lot for that quick fix! (Seems that one was not even trivial, judging from the total lines of code you had to touch). Cheers, Kurt