From f207e2e08ddc1bc875cfaaf9738a13192f5c4533 Mon Sep 17 00:00:00 2001 From: Bobby Holley Date: Sat, 31 Jul 2010 13:44:23 -0400 Subject: [PATCH] Bug 583205 - Crash at the time of download completion. r=karlt,a=blocker --- widget/src/gtk2/nsImageToPixbuf.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/widget/src/gtk2/nsImageToPixbuf.cpp b/widget/src/gtk2/nsImageToPixbuf.cpp index 4b84338a79b..32d05b405df 100644 --- a/widget/src/gtk2/nsImageToPixbuf.cpp +++ b/widget/src/gtk2/nsImageToPixbuf.cpp @@ -69,9 +69,21 @@ GdkPixbuf* nsImageToPixbuf::ImageToPixbuf(imgIContainer* aImage) { nsRefPtr frame; - aImage->CopyFrame(imgIContainer::FRAME_CURRENT, - imgIContainer::FLAG_SYNC_DECODE, - getter_AddRefs(frame)); + nsresult rv = aImage->CopyFrame(imgIContainer::FRAME_CURRENT, + imgIContainer::FLAG_SYNC_DECODE, + getter_AddRefs(frame)); + + // If the last call failed, it was probably because our call stack originates + // in an imgIDecoderObserver event, meaning that we're not allowed request + // a sync decode. Presumably the originating event is something sensible like + // OnStopFrame(), so we can just retry the call without a sync decode. + if (NS_FAILED(rv)) + aImage->CopyFrame(imgIContainer::FRAME_CURRENT, + imgIContainer::FLAG_NONE, + getter_AddRefs(frame)); + + if (!frame) + return nsnull; return ImgSurfaceToPixbuf(frame, frame->Width(), frame->Height()); }