Fix exit crash when showing GDB options page.

The options page deleted the widget, which it does not own.

Remove the deletion, rename GdbOptionsPagePrivate to
GdbOptionsPageWidget and use a QPointer in the GdbOptionsPage,
rename the member to m_widget for clarity.

Change-Id: I211a7cf4d59015c540335bd6313eaff13f1999a4
Reviewed-by: hjk <qthjk@ovi.com>
This commit is contained in:
Friedemann Kleint
2012-08-27 13:58:47 +02:00
committed by hjk
parent a208cebdcc
commit fc878896b4
2 changed files with 13 additions and 14 deletions

View File

@@ -54,10 +54,10 @@
namespace Debugger {
namespace Internal {
class GdbOptionsPagePrivate : public QWidget
class GdbOptionsPageWidget : public QWidget
{
public:
explicit GdbOptionsPagePrivate(QWidget *parent);
explicit GdbOptionsPageWidget(QWidget *parent);
QGroupBox *groupBoxGeneral;
QLabel *labelGdbWatchdogTimeout;
@@ -91,7 +91,7 @@ public:
QString searchKeywords;
};
GdbOptionsPagePrivate::GdbOptionsPagePrivate(QWidget *parent)
GdbOptionsPageWidget::GdbOptionsPageWidget(QWidget *parent)
: QWidget(parent)
{
groupBoxGeneral = new QGroupBox(this);
@@ -338,7 +338,6 @@ GdbOptionsPagePrivate::GdbOptionsPagePrivate(QWidget *parent)
}
GdbOptionsPage::GdbOptionsPage()
: d(0)
{
setId(QLatin1String("M.Gdb"));
setDisplayName(tr("GDB"));
@@ -349,30 +348,29 @@ GdbOptionsPage::GdbOptionsPage()
GdbOptionsPage::~GdbOptionsPage()
{
delete d;
}
QWidget *GdbOptionsPage::createPage(QWidget *parent)
{
d = new GdbOptionsPagePrivate(parent);
return d;
m_widget = new GdbOptionsPageWidget(parent);
return m_widget;
}
void GdbOptionsPage::apply()
{
if (d)
d->group.apply(Core::ICore::settings());
if (m_widget)
m_widget->group.apply(Core::ICore::settings());
}
void GdbOptionsPage::finish()
{
if (d)
d->group.finish();
if (m_widget)
m_widget->group.finish();
}
bool GdbOptionsPage::matches(const QString &s) const
{
return d && d->searchKeywords.contains(s, Qt::CaseInsensitive);
return m_widget && m_widget->searchKeywords.contains(s, Qt::CaseInsensitive);
}
} // namespace Internal

View File

@@ -32,11 +32,12 @@
#define GDBOPTIONSPAGE_H
#include <coreplugin/dialogs/ioptionspage.h>
#include <QPointer>
namespace Debugger {
namespace Internal {
class GdbOptionsPagePrivate;
class GdbOptionsPageWidget;
class GdbOptionsPage : public Core::IOptionsPage
{
@@ -51,7 +52,7 @@ public:
bool matches(const QString &) const;
private:
GdbOptionsPagePrivate *d;
QPointer<GdbOptionsPageWidget> m_widget;
};
} // namespace Internal