Commit 43ecc4cc authored by Waqar Ahmed's avatar Waqar Ahmed Committed by Albert Astals Cid
Browse files

Fix leaks

parent 611635b9
Pipeline #125456 passed with stage
in 47 seconds
......@@ -93,19 +93,16 @@ void BitButton::setOn(bool value)
//------------------------------------------------------------------------------
void BitButton::setRenderSize(const QSize &size)
{
if (renderSize_) {
delete renderSize_;
}
renderSize_ = new QSize(size);
renderSize_ = size;
}
//------------------------------------------------------------------------------
// Name: renderSize
// Desc: returns current render size
//------------------------------------------------------------------------------
const QSize& BitButton::renderSize() const
QSize BitButton::renderSize() const
{
return *renderSize_;
return renderSize_;
}
//------------------------------------------------------------------------------
......
......@@ -18,7 +18,7 @@ public:
Q_REQUIRED_RESULT bool isOn() const;
void setOn(bool value);
void setRenderSize(const QSize &size);
const QSize &renderSize() const;
QSize renderSize() const;
protected:
void paintEvent(QPaintEvent *event) override;
......@@ -32,6 +32,6 @@ private:
void leaveEvent(QEvent *event) override;
bool on_ = false;
bool over_ = false;
QSize* renderSize_ = nullptr;
QSize renderSize_;
};
......@@ -54,9 +54,6 @@ KCalculator::KCalculator(QWidget *parent)
, memory_num_(0.0)
, core()
{
// initialize pointers
baseFont_ = nullptr;
// central widget to contain all the elements
auto const central = new QWidget(this);
central->setLayoutDirection(Qt::LeftToRight);
......@@ -2584,10 +2581,7 @@ void KCalculator::setFonts()
void KCalculator::setBaseFont(const QFont &font)
{
// Overwrite current baseFont
if (baseFont_) {
delete baseFont_;
}
baseFont_ = new QFont(font);
baseFont_ = font;
}
//------------------------------------------------------------------------------
......@@ -2596,7 +2590,7 @@ void KCalculator::setBaseFont(const QFont &font)
//------------------------------------------------------------------------------
const QFont& KCalculator::baseFont() const
{
return *baseFont_;
return baseFont_;
}
//------------------------------------------------------------------------------
......
......@@ -272,8 +272,8 @@ private:
QList<QAbstractButton *> stat_button_list_;
QList<QAbstractButton *> mem_button_list_;
QList<QAbstractButton *> operation_button_list_;
QFont* baseFont_;
QFont baseFont_;
bool is_still_in_launch_ = true; // necessary for startup at minimum size
CalcEngine core;
......
......@@ -603,11 +603,7 @@ void KCalcDisplay::setText(const QString &string)
void KCalcDisplay::setFont(const QFont &font)
{
// Overwrite current baseFont
if (baseFont_) {
delete baseFont_;
}
baseFont_ = new QFont(font);
baseFont_ = font;
updateFont();
}
......@@ -637,7 +633,7 @@ void KCalcDisplay::updateFont()
//------------------------------------------------------------------------------
const QFont& KCalcDisplay::baseFont() const
{
return *baseFont_;
return baseFont_;
}
//------------------------------------------------------------------------------
......
......@@ -121,8 +121,8 @@ private:
int fixed_precision_; // "-1" = no fixed_precision
KNumber display_amount_;
QFont* baseFont_ = nullptr;
QFont baseFont_;
QVector<KNumber> history_list_;
int history_index_;
......
......@@ -146,11 +146,7 @@ void KCalcHistory::changeSettings()
void KCalcHistory::setFont(const QFont &font)
{
// Overwrite current baseFont
if (baseFont_) {
delete baseFont_;
}
baseFont_ = new QFont(font);
baseFont_ = font;
updateFont();
}
......@@ -181,7 +177,7 @@ void KCalcHistory::updateFont(double zoomFactor)
//------------------------------------------------------------------------------
const QFont& KCalcHistory::baseFont() const
{
return *baseFont_;
return baseFont_;
}
//------------------------------------------------------------------------------
......
......@@ -40,7 +40,7 @@ protected:
private:
bool add_new_line_ = false;
QFont* baseFont_ = nullptr;
QFont baseFont_;
double idealPointSizeF_;
void updateFont(double zoomFactor = 1.0);
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment