Fix 3 small memory leaks

This commit is contained in:
Albert Astals Cid 2020-10-28 19:24:59 +01:00 committed by Simone Gaiarin
parent 681f405390
commit eb548b006d
2 changed files with 12 additions and 14 deletions

View file

@ -43,8 +43,6 @@ public:
explicit AnnotationActionHandlerPrivate(AnnotationActionHandler *qq) explicit AnnotationActionHandlerPrivate(AnnotationActionHandler *qq)
: q(qq) : q(qq)
, annotator(nullptr) , annotator(nullptr)
, textTools(nullptr)
, textQuickTools(nullptr)
, agTools(nullptr) , agTools(nullptr)
, agLastAction(nullptr) , agLastAction(nullptr)
, aQuickTools(nullptr) , aQuickTools(nullptr)
@ -103,8 +101,8 @@ public:
PageViewAnnotator *annotator; PageViewAnnotator *annotator;
QList<QAction *> *textTools; QList<QAction *> textTools;
QList<QAction *> *textQuickTools; QList<QAction *> textQuickTools;
QActionGroup *agTools; QActionGroup *agTools;
QAction *agLastAction; QAction *agLastAction;
@ -341,7 +339,7 @@ void AnnotationActionHandlerPrivate::populateQuickAnnotations()
const QList<int> numberKeys = {Qt::Key_1, Qt::Key_2, Qt::Key_3, Qt::Key_4, Qt::Key_5, Qt::Key_6, Qt::Key_7, Qt::Key_8, Qt::Key_9, Qt::Key_0}; const QList<int> numberKeys = {Qt::Key_1, Qt::Key_2, Qt::Key_3, Qt::Key_4, Qt::Key_5, Qt::Key_6, Qt::Key_7, Qt::Key_8, Qt::Key_9, Qt::Key_0};
textQuickTools->clear(); textQuickTools.clear();
aQuickTools->removeAllActions(); aQuickTools->removeAllActions();
int favToolId = 1; int favToolId = 1;
@ -361,7 +359,7 @@ void AnnotationActionHandlerPrivate::populateQuickAnnotations()
QDomElement engineElement = favToolElement.firstChildElement(QStringLiteral("engine")); QDomElement engineElement = favToolElement.firstChildElement(QStringLiteral("engine"));
if (engineElement.attribute(QStringLiteral("type")) == QStringLiteral("TextSelector")) { if (engineElement.attribute(QStringLiteral("type")) == QStringLiteral("TextSelector")) {
textQuickTools->append(annFav); textQuickTools.append(annFav);
annFav->setEnabled(textToolsEnabled); annFav->setEnabled(textToolsEnabled);
} }
@ -559,12 +557,10 @@ AnnotationActionHandler::AnnotationActionHandler(PageViewAnnotator *parent, KAct
d->agTools->addAction(aEllipse); d->agTools->addAction(aEllipse);
d->agTools->addAction(aPolygon); d->agTools->addAction(aPolygon);
d->textQuickTools = new QList<QAction *>(); d->textTools.append(aHighlighter);
d->textTools = new QList<QAction *>(); d->textTools.append(aUnderline);
d->textTools->append(aHighlighter); d->textTools.append(aSquiggle);
d->textTools->append(aUnderline); d->textTools.append(aStrikeout);
d->textTools->append(aSquiggle);
d->textTools->append(aStrikeout);
int toolId = 1; int toolId = 1;
const QList<QAction *> tools = d->agTools->actions(); const QList<QAction *> tools = d->agTools->actions();
@ -751,10 +747,10 @@ void AnnotationActionHandler::setToolsEnabled(bool on)
void AnnotationActionHandler::setTextToolsEnabled(bool on) void AnnotationActionHandler::setTextToolsEnabled(bool on)
{ {
d->textToolsEnabled = on; d->textToolsEnabled = on;
for (QAction *ann : qAsConst(*d->textTools)) { for (QAction *ann : qAsConst(d->textTools)) {
ann->setEnabled(on); ann->setEnabled(on);
} }
for (QAction *ann : qAsConst(*d->textQuickTools)) { for (QAction *ann : qAsConst(d->textQuickTools)) {
ann->setEnabled(on); ann->setEnabled(on);
} }
} }

View file

@ -772,6 +772,8 @@ void PageViewAnnotator::reparseQuickToolsConfig()
PageViewAnnotator::~PageViewAnnotator() PageViewAnnotator::~PageViewAnnotator()
{ {
delete m_engine; delete m_engine;
delete m_builtinToolsDefinition;
delete m_quickToolsDefinition;
} }
bool PageViewAnnotator::active() const bool PageViewAnnotator::active() const