summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMontel Laurent <[email protected]>2017-08-20 13:38:25 +0200
committerMontel Laurent <[email protected]>2017-08-20 13:38:25 +0200
commit54bfa33e02d0589e596e281e47d0141cfa51253a (patch)
tree0bc38599aa1b425035a9f400e488d619841fd887
parent47a44560620d0615265b39fb9b6708cdd36ee582 (diff)
Fix potential crash
-rw-r--r--src/mainwidget.cpp18
-rw-r--r--src/mainwindow.cpp8
2 files changed, 15 insertions, 11 deletions
diff --git a/src/mainwidget.cpp b/src/mainwidget.cpp
index e9d588a..e8475e7 100644
--- a/src/mainwidget.cpp
+++ b/src/mainwidget.cpp
@@ -374,12 +374,13 @@ void MainWidget::initializeImportExportPlugin(KActionCollection *collection)
void MainWidget::configure()
{
- KCMultiDialog dlg(this);
- dlg.addModule(QStringLiteral("akonadicontact_actions.desktop"));
- dlg.addModule(QStringLiteral("kcmldap.desktop"));
- dlg.addModule(QStringLiteral("kaddressbook_config_plugins.desktop"));
+ QPointer<KCMultiDialog> dlg = new KCMultiDialog(this);
+ dlg->addModule(QStringLiteral("akonadicontact_actions.desktop"));
+ dlg->addModule(QStringLiteral("kcmldap.desktop"));
+ dlg->addModule(QStringLiteral("kaddressbook_config_plugins.desktop"));
- dlg.exec();
+ dlg->exec();
+ delete dlg;
}
void MainWidget::handleCommandLine(const QStringList &arguments)
@@ -717,10 +718,10 @@ void MainWidget::printPreview()
printer.setOutputFormat(QPrinter::PdfFormat);
printer.setCollateCopies(true);
- PimCommon::KPimPrintPreviewDialog previewdlg(&printer, this);
+ QPointer<PimCommon::KPimPrintPreviewDialog> previewdlg = new PimCommon::KPimPrintPreviewDialog(&printer, this);
KABPrinting::PrintingWizard wizard(&printer, mItemView->selectionModel(), this);
wizard.setDefaultAddressBook(currentAddressBook());
- connect(&previewdlg, &QPrintPreviewDialog::paintRequested, this, [&wizard]() {
+ connect(previewdlg, &QPrintPreviewDialog::paintRequested, this, [&wizard]() {
wizard.print();
});
@@ -729,8 +730,9 @@ void MainWidget::printPreview()
Settings::self()->setDefaultFileName(printer.outputFileName());
Settings::self()->setPrintingStyle(wizard.printingStyle());
Settings::self()->setSortOrder(wizard.sortOrder());
- previewdlg.exec();
+ previewdlg->exec();
}
+ delete previewdlg;
}
void MainWidget::print()
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 7cfdcdd..084ca63 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -34,6 +34,7 @@
#include <KMessageBox>
#include <KToggleAction>
#include <QMenuBar>
+#include <QPointer>
MainWindow::MainWindow()
: KXmlGuiWindow(nullptr)
@@ -97,9 +98,10 @@ void MainWindow::configureToolbars()
KConfigGroup grp = KSharedConfig::openConfig()->group("MainWindow");
saveMainWindowSettings(grp);
- KEditToolBar dlg(factory());
- connect(&dlg, &KEditToolBar::newToolBarConfig, this, &MainWindow::newToolbarConfig);
- dlg.exec();
+ QPointer<KEditToolBar> dlg = new KEditToolBar(factory());
+ connect(dlg, &KEditToolBar::newToolBarConfig, this, &MainWindow::newToolbarConfig);
+ dlg->exec();
+ delete dlg;
}
void MainWindow::newToolbarConfig()