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

List:       koffice-devel
Subject:    [patch] Avoid crash in KoColorPopupAction
From:       Jarosław_Staniek <staniek () kde ! org>
Date:       2009-07-30 20:46:52
Message-ID: 200907302246.52396.staniek () kde ! org
[Download RAW message or body]

Hi, for review:
When KoColorPopupAction (for whatever reason) receives invalid QColor, KoColor 
asserts [1]. 

The patch falls back to transparent black color and issues a warning.

[1] KoColor::KoColor(const QColor & color, const KoColorSpace * colorSpace)

-- 
regards / pozdrawiam, Jaroslaw Staniek
 Kexi & KOffice (http://www.kexi-project.org, http://www.koffice.org)
 http://www.linkedin.com/in/jstaniek

["KoColorPopupAction-invalid-colors.patch" (text/x-patch)]

Index: libs/widgets/colorwidgets/KoColorPopupAction.cpp
===================================================================
--- libs/widgets/colorwidgets/KoColorPopupAction.cpp	(revision 1001280)
+++ libs/widgets/colorwidgets/KoColorPopupAction.cpp	(working copy)
@@ -33,6 +33,7 @@
 #include <QGridLayout>
 
 #include <KColorDialog>
+#include <KDebug>
 #include <klocale.h>
 #include <kicon.h>
 
@@ -106,8 +107,12 @@
     delete d;
 }
 
-void KoColorPopupAction::setCurrentColor( const QColor &color )
+void KoColorPopupAction::setCurrentColor( const QColor &_color )
 {
+    QColor color(_color.isValid() ? _color : QColor(0,0,0,255));
+    if (!_color.isValid()) {
+        kWarning() << "Invalid color given, defaulting to black";
+    }
     d->colorChooser->setQColor( color );
 
     KoColor minColor( color, KoColorSpaceRegistry::instance()->rgb8() );


_______________________________________________
koffice-devel mailing list
koffice-devel@kde.org
https://mail.kde.org/mailman/listinfo/koffice-devel


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

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