Commit acd265ef authored by Ahmad Samir's avatar Ahmad Samir Committed by Kurt Hindenburg
Browse files

Less delete calls in destructors

- If the QObject has a parent, the parent will take care of deleting it
- Use std::unique_ptr to manage pointer member variable
- Use '= default' with empty destructors
- Fix initialization of QTimer in constructor initialization list
parent a7363fa5
......@@ -24,12 +24,11 @@ Emulation::Emulation() :
_windows(QList<ScreenWindow *>()),
_currentScreen(nullptr),
_codec(nullptr),
_decoder(nullptr),
_keyTranslator(nullptr),
_usesMouseTracking(false),
_bracketedPasteMode(false),
_bulkTimer1(new QTimer(this)),
_bulkTimer2(new QTimer(this)),
_bulkTimer1(QTimer(this)),
_bulkTimer2(QTimer(this)),
_imageSizeInitialized(false),
_peekingPrimary(false),
_activeScreenIndex(0)
......@@ -104,7 +103,6 @@ Emulation::~Emulation()
delete _screen[0];
delete _screen[1];
delete _decoder;
}
void Emulation::setPeekPrimary(const bool doPeek)
......@@ -161,8 +159,7 @@ void Emulation::setCodec(const QTextCodec *codec)
if (codec != nullptr) {
_codec = codec;
delete _decoder;
_decoder = _codec->makeDecoder();
_decoder.reset(_codec->makeDecoder());
Q_EMIT useUtf8Request(utf8());
} else {
......
......@@ -17,6 +17,8 @@
#include "Enumeration.h"
#include "konsoleprivate_export.h"
#include <memory>
class QKeyEvent;
namespace Konsole {
......@@ -440,7 +442,7 @@ protected:
//decodes an incoming C-style character stream into a unicode QString using
//the current text codec. (this allows for rendering of non-ASCII characters in text files etc.)
const QTextCodec *_codec;
QTextDecoder *_decoder;
std::unique_ptr<QTextDecoder> _decoder;
const KeyboardTranslator *_keyTranslator; // the keyboard layout
protected Q_SLOTS:
......
......@@ -73,7 +73,6 @@ Part::Part(QWidget *parentWidget, QObject *parent, const QVariantList &) :
Part::~Part()
{
ProfileManager::instance()->saveSettings();
delete _viewManager;
}
bool Part::openFile()
......
......@@ -89,9 +89,7 @@ Screen::Screen(int lines, int columns):
reset();
}
Screen::~Screen()
{
}
Screen::~Screen() = default;
void Screen::cursorUp(int n)
//=CUU
......@@ -383,7 +381,7 @@ bool Screen::isResize()
return _isResize;
}
void Screen::setReflowLines(bool enable)
void Screen::setReflowLines(bool enable)
{
_enableReflowLines = enable;
}
......
......@@ -23,9 +23,7 @@ ColorSchemeWallpaper::ColorSchemeWallpaper(const QString &path) :
{
}
ColorSchemeWallpaper::~ColorSchemeWallpaper()
{
}
ColorSchemeWallpaper::~ColorSchemeWallpaper() = default;
void ColorSchemeWallpaper::load()
{
......
......@@ -16,9 +16,7 @@ HistoryScroll::HistoryScroll(HistoryType *t) :
{
}
HistoryScroll::~HistoryScroll()
{
}
HistoryScroll::~HistoryScroll() = default;
bool HistoryScroll::hasScroll()
{
......
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