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

View File

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