Re: Bad behaviour with really extreme images

Aurélien Gâteau <[email protected]> Tue, 29 Jul 2008 21:00:11 +0200
Newsgroups gmane.comp.kde.gwenview
Message-ID <[email protected]>
Ilya Konkov wrote:
> On Thu, Jul 24, 2008 at 5:51 PM, Aurélien Gâteau
> <[email protected]> wrote:
>> Ilya Konkov wrote:
>>> Hello,
>>>
>>> I undestand that this is really not very usable case, but anyway:
>>>
>>> QImage image(1, 10000, QImage::Format_Mono);
>>> image.fill(0);
>>> image.save("image.png", "PNG");
>>>
>>> Opening this image with gwenview gives:
>>> ASSERT: "!image.isNull()" in file
>>> /home/eruart/app/kdesvn/kdegraphics/gwenview/lib/imagescaler.cpp, line
>>> 145
>> Interesting, maybe we should check that we don't try to resize to
>> something less than 1 pixel width or height? I guess what's happening
>> here is that width() / mZoom returns something too close to 0. Can you
>> check this?
>>
>> Aurélien
>>
>> -------------------------------------------------------------------------
>> This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
>> Build the coolest Linux based applications with Moblin SDK & win great prizes
>> Grand prize is a trip for two to an Open Source event anywhere in the world
>> http://moblin-contest.org/redirect.php?banner_id=100&url=/
>> _______________________________________________
>> Gwenview-general mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/gwenview-general
>>
> 
> Ok. With this changes gwenview doesn't fall on png image:
> 
> Index: lib/document/document.cpp
> ===================================================================
> --- lib/document/document.cpp   (revision 837350)
> +++ lib/document/document.cpp   (working copy)
> @@ -330,6 +330,11 @@
>         if (loadingState() == Loaded) {
>                 // Resample image from the full one
>                 d->mDownSampledImageMap[invertedZoom] =
> d->mImage.scaled(d->mImage.size() / invertedZoom, Qt::KeepAspectRatio,
> Qt::FastTransformation);
> +               kDebug() <<
> "d->mDownSampledImageMap[invertedZoom].size()" <<
> d->mDownSampledImageMap[invertedZoom].size();
> +               if (!d->mDownSampledImageMap[invertedZoom].size().isValid()) {
> +                       d->mDownSampledImageMap[invertedZoom] = d->mImage;
> +                       return false;
> +               }
>                 return true;
>         }
> 
> 
> And output:
> gwenview(21254) Gwenview::Document::prepareDownSampledImageForZoom:
> d->mDownSampledImageMap[invertedZoom].size() QSize(-1, -1)
> QPainter::begin: Cannot paint on a null pixmap
> QPainter::setCompositionMode: Painter not active

The patch looks ok, except it should return true, IMHO because down 
sampled is ready.

> But still fails to open .jpg image:
> 
> Program received signal SIGFPE, Arithmetic exception.
> [Switching to Thread 0xb4424b90 (LWP 21595)]
> 0xb7ebddbd in ?? () from /home/eruart/app/kde/lib/libgwenviewlib.so.4
> (gdb)
> Continuing.
> KCrash: crashing... crashRecursionCounter = 2
> KCrash: Application Name = gwenview path = <unknown> pid = 21586
> sock_file=/home/eruart//.kde4/socket-eNote/kdeinit4__0
> gwenview: Fatal IO error: client killed

The cause of this should be easy to catche with the debugger, SIGFPE 
makes me think about a divide by zero error.

Can you add test cases for both images to DocumentTest? Otherwise I am 
sure this bug will come back to bite us again.

Aurélien

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Gwenview-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gwenview-general