Commit c37c5a55 authored by Laurent Montel's avatar Laurent Montel 😁

Fix crash

parent b60d039e
......@@ -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();
}
......
......@@ -48,6 +48,7 @@ private:
LogActivitiesWidget *mLogWidget = nullptr;
QPushButton *mClearButton = nullptr;
QCheckBox *mEnableLogActivities = nullptr;
QPushButton *mSaveButton = nullptr;
};
}
......
......@@ -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();
......
......@@ -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()
......
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