summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMontel Laurent <[email protected]>2017-09-21 13:51:44 +0200
committerMontel Laurent <[email protected]>2017-09-21 13:51:44 +0200
commitc37c5a55c28e3f77879462a6ff1717cf0f339c96 (patch)
tree0a9f1d75e837726559dcb806ec5e16c595dd61bd
parentb60d039e012d682a43160be4de6a3943b47a5cf4 (diff)
Fix crash
-rw-r--r--src/pimcommon/logactivities/logactivitiesdialog.cpp12
-rw-r--r--src/pimcommon/logactivities/logactivitiesdialog.h1
-rw-r--r--src/pimcommon/logactivities/logactivitiesmanager.cpp10
-rw-r--r--src/pimcommon/logactivities/logactivitieswidget.cpp2
4 files changed, 17 insertions, 8 deletions
diff --git a/src/pimcommon/logactivities/logactivitiesdialog.cpp b/src/pimcommon/logactivities/logactivitiesdialog.cpp
index 31a9550..82b54c3 100644
--- a/src/pimcommon/logactivities/logactivitiesdialog.cpp
+++ b/src/pimcommon/logactivities/logactivitiesdialog.cpp
@@ -26,6 +26,7 @@
#include <QDialogButtonBox>
#include <QPushButton>
#include <QCheckBox>
+#include <QDebug>
using namespace PimCommon;
@@ -52,10 +53,10 @@ LogActivitiesDialog::LogActivitiesDialog(QWidget *parent)
mClearButton->setObjectName(QStringLiteral("clearbutton"));
buttonBox->addButton(mClearButton, QDialogButtonBox::ActionRole);
connect(mClearButton, &QPushButton::clicked, this, &LogActivitiesDialog::slotClear);
- QPushButton *saveButton = buttonBox->button(QDialogButtonBox::Save);
- saveButton->setObjectName(QStringLiteral("savebutton"));
- saveButton->setEnabled(false);
- connect(saveButton, &QPushButton::clicked, this, &LogActivitiesDialog::slotSave);
+ mSaveButton = buttonBox->button(QDialogButtonBox::Save);
+ mSaveButton->setObjectName(QStringLiteral("savebutton"));
+ mSaveButton->setEnabled(false);
+ connect(mSaveButton, &QPushButton::clicked, this, &LogActivitiesDialog::slotSave);
mainLayout->addWidget(buttonBox);
connect(buttonBox, &QDialogButtonBox::rejected, this, &LogActivitiesDialog::reject);
@@ -63,12 +64,13 @@ LogActivitiesDialog::LogActivitiesDialog(QWidget *parent)
connect(PimCommon::LogActivitiesManager::self(), &LogActivitiesManager::logEntryAdded, this, &LogActivitiesDialog::slotLogEntryAdded);
connect(PimCommon::LogActivitiesManager::self(), &LogActivitiesManager::logEntryCleared, this, &LogActivitiesDialog::slotLogEntryCleared);
- connect(mLogWidget, &LogActivitiesWidget::textChanged, saveButton, &QPushButton::setEnabled);
+ connect(mLogWidget, &LogActivitiesWidget::textChanged, mSaveButton, &QPushButton::setEnabled);
mEnableLogActivities->setChecked(PimCommon::LogActivitiesManager::self()->enableLogActivities());
}
LogActivitiesDialog::~LogActivitiesDialog()
{
+ disconnect(mLogWidget, &LogActivitiesWidget::textChanged, mSaveButton, &QPushButton::setEnabled);
writeConfig();
}
diff --git a/src/pimcommon/logactivities/logactivitiesdialog.h b/src/pimcommon/logactivities/logactivitiesdialog.h
index 6aae30d..24872d6 100644
--- a/src/pimcommon/logactivities/logactivitiesdialog.h
+++ b/src/pimcommon/logactivities/logactivitiesdialog.h
@@ -48,6 +48,7 @@ private:
LogActivitiesWidget *mLogWidget = nullptr;
QPushButton *mClearButton = nullptr;
QCheckBox *mEnableLogActivities = nullptr;
+ QPushButton *mSaveButton = nullptr;
};
}
diff --git a/src/pimcommon/logactivities/logactivitiesmanager.cpp b/src/pimcommon/logactivities/logactivitiesmanager.cpp
index 391e089..cacc790 100644
--- a/src/pimcommon/logactivities/logactivitiesmanager.cpp
+++ b/src/pimcommon/logactivities/logactivitiesmanager.cpp
@@ -18,6 +18,8 @@
#include "logactivitiesmanager.h"
#include "logactivitiesdialog.h"
#include <QTime>
+#include <QDebug>
+#include <QPointer>
using namespace PimCommon;
@@ -35,11 +37,12 @@ public:
~LogActivitiesManagerPrivate()
{
- delete mDialog;
+ //Disable delete it.
+ //delete mDialog;
}
QStringList mLog;
- PimCommon::LogActivitiesDialog *mDialog = nullptr;
+ QPointer<PimCommon::LogActivitiesDialog> mDialog = nullptr;
bool mEnableLogActivities = false;
};
@@ -83,7 +86,8 @@ void LogActivitiesManager::showLogActivitiesDialog()
{
if (!d->mDialog) {
d->mDialog = new PimCommon::LogActivitiesDialog();
- connect(d->mDialog, &LogActivitiesDialog::logCleared, this, &LogActivitiesManager::clear);
+ d->mDialog->setAttribute(Qt::WA_DeleteOnClose, true);
+ connect(d->mDialog.data(), &LogActivitiesDialog::logCleared, this, &LogActivitiesManager::clear);
}
d->mDialog->setLog(log());
d->mDialog->show();
diff --git a/src/pimcommon/logactivities/logactivitieswidget.cpp b/src/pimcommon/logactivities/logactivitieswidget.cpp
index 540aa99..f06cb79 100644
--- a/src/pimcommon/logactivities/logactivitieswidget.cpp
+++ b/src/pimcommon/logactivities/logactivitieswidget.cpp
@@ -19,6 +19,7 @@
#include <QVBoxLayout>
#include <KPIMTextEdit/PlainTextEditorWidget>
#include <KPIMTextEdit/PlainTextEditor>
+#include <QDebug>
using namespace PimCommon;
LogActivitiesWidget::LogActivitiesWidget(QWidget *parent)
@@ -37,6 +38,7 @@ LogActivitiesWidget::LogActivitiesWidget(QWidget *parent)
LogActivitiesWidget::~LogActivitiesWidget()
{
+ disconnect(mLog->editor(), &KPIMTextEdit::PlainTextEditor::textChanged, this, &LogActivitiesWidget::slotTextChanged);
}
void LogActivitiesWidget::slotTextChanged()