summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorjasplin <qt-info@nokia.com>2009-06-22 12:58:48 (GMT)
committerjasplin <qt-info@nokia.com>2009-06-22 13:09:28 (GMT)
commit938592604e3689f4369d5babd2387ec8af8839bb (patch)
tree8d8b8b87da5867466e6137fa3cda0a00d6d4f17f /src
parentab3a7760008ed6723f978a06aa52bee57b34d68d (diff)
downloadQt-938592604e3689f4369d5babd2387ec8af8839bb.zip
Qt-938592604e3689f4369d5babd2387ec8af8839bb.tar.gz
Qt-938592604e3689f4369d5babd2387ec8af8839bb.tar.bz2
Prevented QWizard from crashing upon removing a page after deleting a field object.
QWizard crashed when removing a page after deleting an object that was already registered as a field for the page. This patch prevents such a crash by doing the necessary cleanup immediately when the object is deleted. QWizard::removePage() will then see a consistent state in this case. Reviewed-by: janarve Task-number: 255350
Diffstat (limited to 'src')
-rw-r--r--src/gui/dialogs/qwizard.cpp25
-rw-r--r--src/gui/dialogs/qwizard.h1
2 files changed, 26 insertions, 0 deletions
diff --git a/src/gui/dialogs/qwizard.cpp b/src/gui/dialogs/qwizard.cpp
index 2387134..6859fc9 100644
--- a/src/gui/dialogs/qwizard.cpp
+++ b/src/gui/dialogs/qwizard.cpp
@@ -560,6 +560,7 @@ public:
void enableUpdates();
void _q_emitCustomButtonClicked();
void _q_updateButtonStates();
+ void _q_handleFieldObjectDestroyed(QObject *);
void setStyle(QStyle *style);
#ifdef Q_WS_MAC
static QPixmap findDefaultBackgroundPixmap();
@@ -731,6 +732,8 @@ void QWizardPrivate::cleanupPagesNotInHistory()
void QWizardPrivate::addField(const QWizardField &field)
{
+ Q_Q(QWizard);
+
QWizardField myField = field;
myField.resolve(defaultPropertyTable);
@@ -744,15 +747,23 @@ void QWizardPrivate::addField(const QWizardField &field)
if (myField.mandatory && !myField.changedSignal.isEmpty())
QObject::connect(myField.object, myField.changedSignal,
myField.page, SLOT(_q_maybeEmitCompleteChanged()));
+ QObject::connect(
+ myField.object, SIGNAL(destroyed(QObject *)), q,
+ SLOT(_q_handleFieldObjectDestroyed(QObject *)));
}
void QWizardPrivate::removeFieldAt(int index)
{
+ Q_Q(QWizard);
+
const QWizardField &field = fields.at(index);
fieldIndexMap.remove(field.name);
if (field.mandatory && !field.changedSignal.isEmpty())
QObject::disconnect(field.object, field.changedSignal,
field.page, SLOT(_q_maybeEmitCompleteChanged()));
+ QObject::disconnect(
+ field.object, SIGNAL(destroyed(QObject *)), q,
+ SLOT(_q_handleFieldObjectDestroyed(QObject *)));
fields.remove(index);
}
@@ -1591,6 +1602,20 @@ void QWizardPrivate::_q_updateButtonStates()
enableUpdates();
}
+void QWizardPrivate::_q_handleFieldObjectDestroyed(QObject *object)
+{
+ QVector<QWizardField>::iterator it = fields.begin();
+ while (it != fields.end()) {
+ const QWizardField &field = *it;
+ if (field.object == object) {
+ fieldIndexMap.remove(field.name);
+ it = fields.erase(it);
+ } else {
+ ++it;
+ }
+ }
+}
+
void QWizardPrivate::setStyle(QStyle *style)
{
for (int i = 0; i < QWizard::NButtons; i++)
diff --git a/src/gui/dialogs/qwizard.h b/src/gui/dialogs/qwizard.h
index 1d1a9b5..d1f9cf7 100644
--- a/src/gui/dialogs/qwizard.h
+++ b/src/gui/dialogs/qwizard.h
@@ -197,6 +197,7 @@ private:
Q_DECLARE_PRIVATE(QWizard)
Q_PRIVATE_SLOT(d_func(), void _q_emitCustomButtonClicked())
Q_PRIVATE_SLOT(d_func(), void _q_updateButtonStates())
+ Q_PRIVATE_SLOT(d_func(), void _q_handleFieldObjectDestroyed(QObject *))
friend class QWizardPage;
};