mirror of
https://bitbucket.org/smil3y/kdelibs.git
synced 2025-02-23 18:32:49 +00:00
kdeui: fix possible use of uninitialized variables in KHueSaturationSelector
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
d47d67b645
commit
7df1c4b6bb
2 changed files with 37 additions and 31 deletions
|
@ -28,9 +28,14 @@ using namespace KDEPrivate;
|
|||
class KHueSaturationSelector::Private
|
||||
{
|
||||
public:
|
||||
Private(KHueSaturationSelector *q): q(q) {}
|
||||
Private()
|
||||
: _mode(KColorChooserMode::ChooserClassic),
|
||||
_hue(0),
|
||||
_sat(0),
|
||||
_colorValue(0)
|
||||
{
|
||||
}
|
||||
|
||||
KHueSaturationSelector *q;
|
||||
QPixmap pixmap;
|
||||
|
||||
/**
|
||||
|
@ -45,11 +50,11 @@ public:
|
|||
};
|
||||
|
||||
|
||||
|
||||
KHueSaturationSelector::KHueSaturationSelector( QWidget *parent )
|
||||
: KXYSelector( parent ), d( new Private( this ) )
|
||||
KHueSaturationSelector::KHueSaturationSelector(QWidget *parent)
|
||||
: KXYSelector(parent),
|
||||
d(new Private())
|
||||
{
|
||||
setChooserMode( ChooserClassic );
|
||||
setChooserMode(KColorChooserMode::ChooserClassic);
|
||||
}
|
||||
|
||||
KColorChooserMode KHueSaturationSelector::chooserMode() const
|
||||
|
@ -57,14 +62,14 @@ KColorChooserMode KHueSaturationSelector::chooserMode() const
|
|||
return d->_mode;
|
||||
}
|
||||
|
||||
void KHueSaturationSelector::setChooserMode( KColorChooserMode chooserMode )
|
||||
void KHueSaturationSelector::setChooserMode(KColorChooserMode chooserMode)
|
||||
{
|
||||
int x;
|
||||
int x = 0;
|
||||
int y = 255;
|
||||
|
||||
switch ( chooserMode ) {
|
||||
case ChooserSaturation:
|
||||
case ChooserValue:
|
||||
switch (chooserMode) {
|
||||
case KColorChooserMode::ChooserSaturation:
|
||||
case KColorChooserMode::ChooserValue:
|
||||
x = 359;
|
||||
break;
|
||||
default:
|
||||
|
@ -72,27 +77,27 @@ void KHueSaturationSelector::setChooserMode( KColorChooserMode chooserMode )
|
|||
break;
|
||||
}
|
||||
|
||||
setRange( 0, 0, x, y );
|
||||
setRange(0, 0, x, y);
|
||||
d->_mode = chooserMode;
|
||||
}
|
||||
|
||||
int KHueSaturationSelector::hue () const
|
||||
int KHueSaturationSelector::hue() const
|
||||
{
|
||||
return d->_hue;
|
||||
}
|
||||
|
||||
void KHueSaturationSelector::setHue ( int hue )
|
||||
void KHueSaturationSelector::setHue(int hue)
|
||||
{
|
||||
d->_hue = hue;
|
||||
}
|
||||
|
||||
int KHueSaturationSelector::saturation () const
|
||||
int KHueSaturationSelector::saturation() const
|
||||
|
||||
{
|
||||
return d->_sat;
|
||||
}
|
||||
|
||||
void KHueSaturationSelector::setSaturation( int saturation )
|
||||
void KHueSaturationSelector::setSaturation(int saturation)
|
||||
{
|
||||
d->_sat = saturation;
|
||||
}
|
||||
|
@ -102,7 +107,7 @@ int KHueSaturationSelector::colorValue() const
|
|||
return d->_colorValue;
|
||||
}
|
||||
|
||||
void KHueSaturationSelector::setColorValue( int colorValue )
|
||||
void KHueSaturationSelector::setColorValue(int colorValue)
|
||||
{
|
||||
d->_colorValue = colorValue;
|
||||
}
|
||||
|
@ -117,17 +122,18 @@ void KHueSaturationSelector::updateContents()
|
|||
drawPalette( &d->pixmap );
|
||||
}
|
||||
|
||||
void KHueSaturationSelector::resizeEvent( QResizeEvent * )
|
||||
void KHueSaturationSelector::resizeEvent(QResizeEvent *event)
|
||||
{
|
||||
Q_UNUSED(event);
|
||||
updateContents();
|
||||
}
|
||||
|
||||
void KHueSaturationSelector::drawContents( QPainter *painter )
|
||||
void KHueSaturationSelector::drawContents(QPainter *painter)
|
||||
{
|
||||
painter->drawPixmap( contentsRect().x(), contentsRect().y(), d->pixmap );
|
||||
painter->drawPixmap(contentsRect().x(), contentsRect().y(), d->pixmap);
|
||||
}
|
||||
|
||||
void KHueSaturationSelector::drawPalette( QPixmap *pixmap )
|
||||
void KHueSaturationSelector::drawPalette(QPixmap *pixmap)
|
||||
{
|
||||
int xSteps = componentXSteps(chooserMode());
|
||||
int ySteps = componentYSteps(chooserMode());
|
||||
|
|
|
@ -32,7 +32,7 @@ public:
|
|||
/**
|
||||
* Constructs a hue/saturation selection widget.
|
||||
*/
|
||||
explicit KHueSaturationSelector( QWidget *parent = 0 );
|
||||
explicit KHueSaturationSelector(QWidget *parent = 0);
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
|
@ -45,14 +45,14 @@ public:
|
|||
*
|
||||
* @param The chooser mode as defined in KColorChooserMode
|
||||
*/
|
||||
void setChooserMode ( KColorChooserMode chooserMode );
|
||||
void setChooserMode(KColorChooserMode chooserMode);
|
||||
|
||||
/**
|
||||
* Returns the chooser mode.
|
||||
*
|
||||
* @return The chooser mode (defined in KColorChooserMode)
|
||||
*/
|
||||
KColorChooserMode chooserMode () const;
|
||||
KColorChooserMode chooserMode() const;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -67,7 +67,7 @@ public:
|
|||
*
|
||||
* @param hue The hue value (0-360)
|
||||
*/
|
||||
void setHue( int hue );
|
||||
void setHue(int hue);
|
||||
|
||||
/**
|
||||
* Returns the saturation (0-255)
|
||||
|
@ -81,7 +81,7 @@ public:
|
|||
*
|
||||
* @param saturation The saturation (0-255)
|
||||
*/
|
||||
void setSaturation( int saturation );
|
||||
void setSaturation(int saturation);
|
||||
|
||||
/**
|
||||
* Returns the color value (also known as lumniousity, 0-255)
|
||||
|
@ -95,7 +95,7 @@ public:
|
|||
*
|
||||
* @param colorValue The color value (0-255)
|
||||
*/
|
||||
void setColorValue( int colorValue );
|
||||
void setColorValue(int colorValue);
|
||||
|
||||
|
||||
/**
|
||||
|
@ -108,15 +108,15 @@ protected:
|
|||
* Draws the contents of the widget on a pixmap,
|
||||
* which is used for buffering.
|
||||
*/
|
||||
virtual void drawPalette( QPixmap *pixmap );
|
||||
virtual void resizeEvent( QResizeEvent * );
|
||||
virtual void drawPalette(QPixmap *pixmap);
|
||||
virtual void resizeEvent(QResizeEvent *event);
|
||||
|
||||
/**
|
||||
* Reimplemented from KXYSelector. This drawing is
|
||||
* buffered in a pixmap here. As real drawing
|
||||
* routine, drawPalette() is used.
|
||||
*/
|
||||
virtual void drawContents( QPainter *painter );
|
||||
virtual void drawContents(QPainter *painter);
|
||||
|
||||
private:
|
||||
|
||||
|
@ -124,7 +124,7 @@ private:
|
|||
friend class Private;
|
||||
Private * const d;
|
||||
|
||||
Q_DISABLE_COPY( KHueSaturationSelector )
|
||||
Q_DISABLE_COPY(KHueSaturationSelector)
|
||||
};
|
||||
|
||||
#endif /*KHUESATURATIONSELECT_H_*/
|
||||
|
|
Loading…
Add table
Reference in a new issue