Fix 18 memory leaks

Also whitespace.
This commit is contained in:
Guillaume Munch 2017-02-26 22:15:49 +01:00
parent d319976566
commit 26b2cc89d3
6 changed files with 95 additions and 97 deletions

View File

@ -140,7 +140,7 @@ GuiCitation::GuiCitation(GuiView & lv)
connect(textAfterED, SIGNAL(returnPressed()), connect(textAfterED, SIGNAL(returnPressed()),
this, SLOT(on_okPB_clicked())); this, SLOT(on_okPB_clicked()));
selectionManager = new GuiSelectionManager(availableLV, selectedLV, selectionManager = new GuiSelectionManager(this, availableLV, selectedLV,
addPB, deletePB, upPB, downPB, &available_model_, &selected_model_, 1); addPB, deletePB, upPB, downPB, &available_model_, &selected_model_, 1);
connect(selectionManager, SIGNAL(selectionChanged()), connect(selectionManager, SIGNAL(selectionChanged()),
this, SLOT(setCitedKeys())); this, SLOT(setCitedKeys()));
@ -172,12 +172,6 @@ GuiCitation::GuiCitation(GuiView & lv)
} }
GuiCitation::~GuiCitation()
{
delete selectionManager;
}
void GuiCitation::closeEvent(QCloseEvent * e) void GuiCitation::closeEvent(QCloseEvent * e)
{ {
clearSelection(); clearSelection();

View File

@ -44,8 +44,6 @@ class GuiCitation : public DialogView, public Ui::CitationUi
public: public:
/// ///
GuiCitation(GuiView & lv); GuiCitation(GuiView & lv);
///
~GuiCitation();
private Q_SLOTS: private Q_SLOTS:
void on_okPB_clicked(); void on_okPB_clicked();

View File

@ -251,18 +251,19 @@ class ModuleSelectionManager : public GuiSelectionManager
{ {
public: public:
/// ///
ModuleSelectionManager( ModuleSelectionManager(QObject * parent,
QTreeView * availableLV, QTreeView * availableLV,
QListView * selectedLV, QListView * selectedLV,
QPushButton * addPB, QPushButton * addPB,
QPushButton * delPB, QPushButton * delPB,
QPushButton * upPB, QPushButton * upPB,
QPushButton * downPB, QPushButton * downPB,
GuiIdListModel * availableModel, GuiIdListModel * availableModel,
GuiIdListModel * selectedModel, GuiIdListModel * selectedModel,
GuiDocument const * container) GuiDocument const * container)
: GuiSelectionManager(availableLV, selectedLV, addPB, delPB, : GuiSelectionManager(parent, availableLV, selectedLV, addPB, delPB,
upPB, downPB, availableModel, selectedModel), container_(container) upPB, downPB, availableModel, selectedModel),
container_(container)
{} {}
/// ///
void updateProvidedModules(LayoutModuleList const & pm) void updateProvidedModules(LayoutModuleList const & pm)
@ -451,7 +452,8 @@ void ModuleSelectionManager::updateDelPB()
// //
///////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////
PreambleModule::PreambleModule() : current_id_(0) PreambleModule::PreambleModule(QWidget * parent)
: UiWidget<Ui::PreambleUi>(parent), current_id_(0)
{ {
// This is not a memory leak. The object will be destroyed // This is not a memory leak. The object will be destroyed
// with this. // with this.
@ -517,7 +519,8 @@ void PreambleModule::closeEvent(QCloseEvent * e)
///////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////
LocalLayout::LocalLayout() : current_id_(0), validated_(false) LocalLayout::LocalLayout(QWidget * parent)
: UiWidget<Ui::LocalLayoutUi>(parent), current_id_(0), validated_(false)
{ {
connect(locallayoutTE, SIGNAL(textChanged()), this, SLOT(textChanged())); connect(locallayoutTE, SIGNAL(textChanged()), this, SLOT(textChanged()));
connect(validatePB, SIGNAL(clicked()), this, SLOT(validatePressed())); connect(validatePB, SIGNAL(clicked()), this, SLOT(validatePressed()));
@ -676,7 +679,7 @@ GuiDocument::GuiDocument(GuiView & lv)
// text layout // text layout
textLayoutModule = new UiWidget<Ui::TextLayoutUi>; textLayoutModule = new UiWidget<Ui::TextLayoutUi>(this);
connect(textLayoutModule->lspacingCO, SIGNAL(activated(int)), connect(textLayoutModule->lspacingCO, SIGNAL(activated(int)),
this, SLOT(change_adaptor())); this, SLOT(change_adaptor()));
connect(textLayoutModule->lspacingCO, SIGNAL(activated(int)), connect(textLayoutModule->lspacingCO, SIGNAL(activated(int)),
@ -749,7 +752,7 @@ GuiDocument::GuiDocument(GuiView & lv)
// master/child handling // master/child handling
masterChildModule = new UiWidget<Ui::MasterChildUi>; masterChildModule = new UiWidget<Ui::MasterChildUi>(this);
connect(masterChildModule->childrenTW, SIGNAL(itemDoubleClicked(QTreeWidgetItem *, int)), connect(masterChildModule->childrenTW, SIGNAL(itemDoubleClicked(QTreeWidgetItem *, int)),
this, SLOT(includeonlyClicked(QTreeWidgetItem *, int))); this, SLOT(includeonlyClicked(QTreeWidgetItem *, int)));
@ -771,7 +774,7 @@ GuiDocument::GuiDocument(GuiView & lv)
// Formats // Formats
outputModule = new UiWidget<Ui::OutputUi>; outputModule = new UiWidget<Ui::OutputUi>(this);
connect(outputModule->defaultFormatCO, SIGNAL(activated(int)), connect(outputModule->defaultFormatCO, SIGNAL(activated(int)),
this, SLOT(change_adaptor())); this, SLOT(change_adaptor()));
@ -800,7 +803,7 @@ GuiDocument::GuiDocument(GuiView & lv)
this, SLOT(change_adaptor())); this, SLOT(change_adaptor()));
// fonts // fonts
fontModule = new FontModule; fontModule = new FontModule(this);
connect(fontModule->osFontsCB, SIGNAL(clicked()), connect(fontModule->osFontsCB, SIGNAL(clicked()),
this, SLOT(change_adaptor())); this, SLOT(change_adaptor()));
connect(fontModule->osFontsCB, SIGNAL(toggled(bool)), connect(fontModule->osFontsCB, SIGNAL(toggled(bool)),
@ -875,7 +878,7 @@ GuiDocument::GuiDocument(GuiView & lv)
// page layout // page layout
pageLayoutModule = new UiWidget<Ui::PageLayoutUi>; pageLayoutModule = new UiWidget<Ui::PageLayoutUi>(this);
connect(pageLayoutModule->papersizeCO, SIGNAL(activated(int)), connect(pageLayoutModule->papersizeCO, SIGNAL(activated(int)),
this, SLOT(papersizeChanged(int))); this, SLOT(papersizeChanged(int)));
connect(pageLayoutModule->papersizeCO, SIGNAL(activated(int)), connect(pageLayoutModule->papersizeCO, SIGNAL(activated(int)),
@ -955,7 +958,7 @@ GuiDocument::GuiDocument(GuiView & lv)
// margins // margins
marginsModule = new UiWidget<Ui::MarginsUi>; marginsModule = new UiWidget<Ui::MarginsUi>(this);
connect(marginsModule->marginCB, SIGNAL(toggled(bool)), connect(marginsModule->marginCB, SIGNAL(toggled(bool)),
this, SLOT(setCustomMargins(bool))); this, SLOT(setCustomMargins(bool)));
connect(marginsModule->marginCB, SIGNAL(clicked()), connect(marginsModule->marginCB, SIGNAL(clicked()),
@ -1028,7 +1031,7 @@ GuiDocument::GuiDocument(GuiView & lv)
// language & quote // language & quote
langModule = new UiWidget<Ui::LanguageUi>; langModule = new UiWidget<Ui::LanguageUi>(this);
connect(langModule->languageCO, SIGNAL(activated(int)), connect(langModule->languageCO, SIGNAL(activated(int)),
this, SLOT(change_adaptor())); this, SLOT(change_adaptor()));
connect(langModule->languageCO, SIGNAL(activated(int)), connect(langModule->languageCO, SIGNAL(activated(int)),
@ -1083,7 +1086,7 @@ GuiDocument::GuiDocument(GuiView & lv)
// color // color
colorModule = new UiWidget<Ui::ColorUi>; colorModule = new UiWidget<Ui::ColorUi>(this);
connect(colorModule->fontColorPB, SIGNAL(clicked()), connect(colorModule->fontColorPB, SIGNAL(clicked()),
this, SLOT(changeFontColor())); this, SLOT(changeFontColor()));
connect(colorModule->delFontColorTB, SIGNAL(clicked()), connect(colorModule->delFontColorTB, SIGNAL(clicked()),
@ -1103,7 +1106,7 @@ GuiDocument::GuiDocument(GuiView & lv)
// numbering // numbering
numberingModule = new UiWidget<Ui::NumberingUi>; numberingModule = new UiWidget<Ui::NumberingUi>(this);
connect(numberingModule->depthSL, SIGNAL(valueChanged(int)), connect(numberingModule->depthSL, SIGNAL(valueChanged(int)),
this, SLOT(change_adaptor())); this, SLOT(change_adaptor()));
connect(numberingModule->tocSL, SIGNAL(valueChanged(int)), connect(numberingModule->tocSL, SIGNAL(valueChanged(int)),
@ -1119,7 +1122,7 @@ GuiDocument::GuiDocument(GuiView & lv)
setSectionResizeMode(numberingModule->tocTW->header(), QHeaderView::ResizeToContents); setSectionResizeMode(numberingModule->tocTW->header(), QHeaderView::ResizeToContents);
// biblio // biblio
biblioModule = new UiWidget<Ui::BiblioUi>; biblioModule = new UiWidget<Ui::BiblioUi>(this);
connect(biblioModule->citeEngineCO, SIGNAL(activated(int)), connect(biblioModule->citeEngineCO, SIGNAL(activated(int)),
this, SLOT(citeEngineChanged(int))); this, SLOT(citeEngineChanged(int)));
connect(biblioModule->citeStyleCO, SIGNAL(activated(int)), connect(biblioModule->citeStyleCO, SIGNAL(activated(int)),
@ -1189,7 +1192,7 @@ GuiDocument::GuiDocument(GuiView & lv)
// maths // maths
mathsModule = new UiWidget<Ui::MathsUi>; mathsModule = new UiWidget<Ui::MathsUi>(this);
QStringList headers; QStringList headers;
headers << qt_("Package") << qt_("Load automatically") headers << qt_("Package") << qt_("Load automatically")
<< qt_("Load always") << qt_("Do not load"); << qt_("Load always") << qt_("Do not load");
@ -1257,7 +1260,7 @@ GuiDocument::GuiDocument(GuiView & lv)
// latex class // latex class
latexModule = new UiWidget<Ui::LaTeXUi>; latexModule = new UiWidget<Ui::LaTeXUi>(this);
connect(latexModule->optionsLE, SIGNAL(textChanged(QString)), connect(latexModule->optionsLE, SIGNAL(textChanged(QString)),
this, SLOT(change_adaptor())); this, SLOT(change_adaptor()));
connect(latexModule->defaultOptionsCB, SIGNAL(clicked()), connect(latexModule->defaultOptionsCB, SIGNAL(clicked()),
@ -1322,7 +1325,7 @@ GuiDocument::GuiDocument(GuiView & lv)
// branches // branches
branchesModule = new GuiBranches; branchesModule = new GuiBranches(this);
connect(branchesModule, SIGNAL(changed()), connect(branchesModule, SIGNAL(changed()),
this, SLOT(change_adaptor())); this, SLOT(change_adaptor()));
connect(branchesModule, SIGNAL(renameBranches(docstring const &, docstring const &)), connect(branchesModule, SIGNAL(renameBranches(docstring const &, docstring const &)),
@ -1332,32 +1335,34 @@ GuiDocument::GuiDocument(GuiView & lv)
// preamble // preamble
preambleModule = new PreambleModule; preambleModule = new PreambleModule(this);
connect(preambleModule, SIGNAL(changed()), connect(preambleModule, SIGNAL(changed()),
this, SLOT(change_adaptor())); this, SLOT(change_adaptor()));
localLayout = new LocalLayout; localLayout = new LocalLayout(this);
connect(localLayout, SIGNAL(changed()), connect(localLayout, SIGNAL(changed()),
this, SLOT(change_adaptor())); this, SLOT(change_adaptor()));
// bullets // bullets
bulletsModule = new BulletsModule; bulletsModule = new BulletsModule(this);
connect(bulletsModule, SIGNAL(changed()), connect(bulletsModule, SIGNAL(changed()),
this, SLOT(change_adaptor())); this, SLOT(change_adaptor()));
// Modules // Modules
modulesModule = new UiWidget<Ui::ModulesUi>; modulesModule = new UiWidget<Ui::ModulesUi>(this);
modulesModule->availableLV->header()->setVisible(false); modulesModule->availableLV->header()->setVisible(false);
setSectionResizeMode(modulesModule->availableLV->header(), QHeaderView::ResizeToContents); setSectionResizeMode(modulesModule->availableLV->header(), QHeaderView::ResizeToContents);
modulesModule->availableLV->header()->setStretchLastSection(false); modulesModule->availableLV->header()->setStretchLastSection(false);
selectionManager = selectionManager =
new ModuleSelectionManager(modulesModule->availableLV, new ModuleSelectionManager(this, modulesModule->availableLV,
modulesModule->selectedLV, modulesModule->selectedLV,
modulesModule->addPB, modulesModule->deletePB, modulesModule->addPB,
modulesModule->upPB, modulesModule->downPB, modulesModule->deletePB,
availableModel(), selectedModel(), this); modulesModule->upPB,
modulesModule->downPB,
availableModel(), selectedModel(), this);
connect(selectionManager, SIGNAL(updateHook()), connect(selectionManager, SIGNAL(updateHook()),
this, SLOT(updateModuleInfo())); this, SLOT(updateModuleInfo()));
connect(selectionManager, SIGNAL(selectionChanged()), connect(selectionManager, SIGNAL(selectionChanged()),
@ -1365,7 +1370,7 @@ GuiDocument::GuiDocument(GuiView & lv)
// PDF support // PDF support
pdfSupportModule = new UiWidget<Ui::PDFSupportUi>; pdfSupportModule = new UiWidget<Ui::PDFSupportUi>(this);
connect(pdfSupportModule->use_hyperrefGB, SIGNAL(toggled(bool)), connect(pdfSupportModule->use_hyperrefGB, SIGNAL(toggled(bool)),
this, SLOT(change_adaptor())); this, SLOT(change_adaptor()));
connect(pdfSupportModule->titleLE, SIGNAL(textChanged(QString)), connect(pdfSupportModule->titleLE, SIGNAL(textChanged(QString)),
@ -1421,7 +1426,7 @@ GuiDocument::GuiDocument(GuiView & lv)
// listings // listings
listingsModule = new UiWidget<Ui::ListingsSettingsUi>; listingsModule = new UiWidget<Ui::ListingsSettingsUi>(this);
connect(listingsModule->listingsED, SIGNAL(textChanged()), connect(listingsModule->listingsED, SIGNAL(textChanged()),
this, SLOT(change_adaptor())); this, SLOT(change_adaptor()));
connect(listingsModule->bypassCB, SIGNAL(clicked()), connect(listingsModule->bypassCB, SIGNAL(clicked()),

View File

@ -61,7 +61,7 @@ template<class UI>
class UiWidget : public QWidget, public UI class UiWidget : public QWidget, public UI
{ {
public: public:
UiWidget(QWidget * parent = 0) : QWidget(parent) { UI::setupUi(this); } UiWidget(QWidget * parent) : QWidget(parent) { UI::setupUi(this); }
}; };
@ -306,7 +306,7 @@ class PreambleModule : public UiWidget<Ui::PreambleUi>
{ {
Q_OBJECT Q_OBJECT
public: public:
PreambleModule(); PreambleModule(QWidget * parent);
void update(BufferParams const & params, BufferId id); void update(BufferParams const & params, BufferId id);
void apply(BufferParams & params); void apply(BufferParams & params);
@ -329,7 +329,7 @@ class LocalLayout : public UiWidget<Ui::LocalLayoutUi>
{ {
Q_OBJECT Q_OBJECT
public: public:
LocalLayout(); LocalLayout(QWidget * parent);
void update(BufferParams const & params, BufferId id); void update(BufferParams const & params, BufferId id);
void apply(BufferParams & params); void apply(BufferParams & params);
bool isValid() const { return validated_; } bool isValid() const { return validated_; }
@ -357,6 +357,7 @@ class FontModule : public UiWidget<Ui::FontUi>
{ {
Q_OBJECT Q_OBJECT
public: public:
FontModule(QWidget * parent) : UiWidget<Ui::FontUi>(parent) {}
/// The roman font currently not selected by osFontsCB->isChecked() /// The roman font currently not selected by osFontsCB->isChecked()
QString font_roman; QString font_roman;
/// The sans font currently not selected by osFontsCB->isChecked() /// The sans font currently not selected by osFontsCB->isChecked()

View File

@ -41,21 +41,21 @@
namespace lyx { namespace lyx {
namespace frontend { namespace frontend {
GuiSelectionManager::GuiSelectionManager( GuiSelectionManager::GuiSelectionManager(QObject * parent,
QAbstractItemView * avail, QAbstractItemView * avail,
QAbstractItemView * sel, QAbstractItemView * sel,
QPushButton * add, QPushButton * add,
QPushButton * del, QPushButton * del,
QPushButton * up, QPushButton * up,
QPushButton * down, QPushButton * down,
QAbstractListModel * amod, QAbstractListModel * amod,
QAbstractItemModel * smod, QAbstractItemModel * smod,
int const main_sel_col) int const main_sel_col)
: availableLV(avail), selectedLV(sel), addPB(add), deletePB(del), : QObject(parent), availableLV(avail), selectedLV(sel),
upPB(up), downPB(down), availableModel(amod), selectedModel(smod), addPB(add), deletePB(del), upPB(up), downPB(down),
selectedHasFocus_(false), main_sel_col_(main_sel_col) availableModel(amod), selectedModel(smod),
selectedHasFocus_(false), main_sel_col_(main_sel_col)
{ {
selectedLV->setModel(smod); selectedLV->setModel(smod);
availableLV->setModel(amod); availableLV->setModel(amod);
selectedLV->setSelectionBehavior(QAbstractItemView::SelectRows); selectedLV->setSelectionBehavior(QAbstractItemView::SelectRows);

View File

@ -41,16 +41,16 @@ class GuiSelectionManager : public QObject
public: public:
/// ///
GuiSelectionManager( GuiSelectionManager(QObject * parent,
QAbstractItemView * availableLV, QAbstractItemView * availableLV,
QAbstractItemView * selectedLV, QAbstractItemView * selectedLV,
QPushButton * addPB, QPushButton * addPB,
QPushButton * delPB, QPushButton * delPB,
QPushButton * upPB, QPushButton * upPB,
QPushButton * downPB, QPushButton * downPB,
QAbstractListModel * availableModel, QAbstractListModel * availableModel,
QAbstractItemModel * selectedModel, QAbstractItemModel * selectedModel,
int const main_sel_col = 0); int const main_sel_col = 0);
/// Sets the state of the various push buttons, depending upon the /// Sets the state of the various push buttons, depending upon the
/// state of the widgets. (E.g., "delete" is enabled only if the /// state of the widgets. (E.g., "delete" is enabled only if the
/// selection is non-empty.) /// selection is non-empty.)