diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2013-09-30 18:43:21 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-12-24 15:33:10 +0100 |
commit | 132e812556fc171e2aec398bb077152a9aeb3aac (patch) | |
tree | 44b1436e54263e5438eb5ced6f573795d594c583 /src/widgets/dialogs | |
parent | a2131d6c2f0b2048815e24ca0abbe3e50709acf0 (diff) |
QWizard: Replace a static char* table with a switch statement.
The usual way of concatenating the strings with NUL bytes and
recording the relative offset of each in a separate offset
table doesn't work here, because the entries are the results
of SLOT() and SIGNAL() macros, which might, in debug mode,
inject a runtime function call (to qFlagLocation()).
Linux AMD64 GCC 4.9-pre stripped -O2 effects:
text size: +16B
data size: -64B
relocs: -6
Change-Id: I532840668bb57ab72ef3fecb01a450c4c46516e9
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
Diffstat (limited to 'src/widgets/dialogs')
-rw-r--r-- | src/widgets/dialogs/qwizard.cpp | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/src/widgets/dialogs/qwizard.cpp b/src/widgets/dialogs/qwizard.cpp index a667f299e8..bf5addbc7c 100644 --- a/src/widgets/dialogs/qwizard.cpp +++ b/src/widgets/dialogs/qwizard.cpp @@ -887,9 +887,28 @@ void QWizardPrivate::switchToPage(int newId, Direction direction) } // keep in sync with QWizard::WizardButton -static const char * const buttonSlots[QWizard::NStandardButtons] = { - SLOT(back()), SLOT(next()), SLOT(next()), SLOT(accept()), SLOT(reject()), - SIGNAL(helpRequested()) +static const char * buttonSlots(QWizard::WizardButton which) +{ + switch (which) { + case QWizard::BackButton: + return SLOT(back()); + case QWizard::NextButton: + case QWizard::CommitButton: + return SLOT(next()); + case QWizard::FinishButton: + return SLOT(accept()); + case QWizard::CancelButton: + return SLOT(reject()); + case QWizard::HelpButton: + return SIGNAL(helpRequested()); + case QWizard::CustomButton1: + case QWizard::CustomButton2: + case QWizard::CustomButton3: + case QWizard::Stretch: + case QWizard::NoButton: + Q_UNREACHABLE(); + }; + return 0; }; QWizardLayoutInfo QWizardPrivate::layoutInfoForCurrentPage() @@ -1405,7 +1424,7 @@ void QWizardPrivate::connectButton(QWizard::WizardButton which) const { Q_Q(const QWizard); if (which < QWizard::NStandardButtons) { - QObject::connect(btns[which], SIGNAL(clicked()), q, buttonSlots[which]); + QObject::connect(btns[which], SIGNAL(clicked()), q, buttonSlots(which)); } else { QObject::connect(btns[which], SIGNAL(clicked()), q, SLOT(_q_emitCustomButtonClicked())); } @@ -1576,7 +1595,7 @@ bool QWizardPrivate::handleAeroStyleChange() if (isWindow) vistaHelper->setTitleBarIconAndCaptionVisible(false); QObject::connect( - vistaHelper->backButton(), SIGNAL(clicked()), q, buttonSlots[QWizard::BackButton]); + vistaHelper->backButton(), SIGNAL(clicked()), q, buttonSlots(QWizard::BackButton)); vistaHelper->backButton()->show(); } else { q->setMouseTracking(true); // ### original value possibly different |