diff options
author | Alexander Akulich <akulichalexander@gmail.com> | 2018-03-13 21:56:17 +0300 |
---|---|---|
committer | Alexandr Akulich <akulichalexander@gmail.com> | 2018-03-14 19:25:22 +0000 |
commit | 96ba39b1ee095e814587c760dc83add03ee67232 (patch) | |
tree | 4d953c1029c63a0b5c8e989adc5a0fdc8b23252e /src | |
parent | 1718efe8fab245ef2a5a3dd11dc038cdcd0957bc (diff) |
QFlatpakTheme: Cleanup the code
There is no codepath that can result in d->baseTheme being nullptr.
Remove the checks and get rid unneeded and sometimes dangerous fallbacks
(createPlatformMenuBar(), showPlatformMenuBar() and three more methods
could overflow the stack because of infinity recursion).
Change-Id: Ib03adadf56c169286de42671e2da506502df7aea
Reviewed-by: Jan Grulich <jgrulich@redhat.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/plugins/platformthemes/flatpak/qflatpaktheme.cpp | 88 |
1 files changed, 15 insertions, 73 deletions
diff --git a/src/plugins/platformthemes/flatpak/qflatpaktheme.cpp b/src/plugins/platformthemes/flatpak/qflatpaktheme.cpp index 04abd707e1..6c5e1389cf 100644 --- a/src/plugins/platformthemes/flatpak/qflatpaktheme.cpp +++ b/src/plugins/platformthemes/flatpak/qflatpaktheme.cpp @@ -95,41 +95,25 @@ QFlatpakTheme::QFlatpakTheme() QPlatformMenuItem* QFlatpakTheme::createPlatformMenuItem() const { Q_D(const QFlatpakTheme); - - if (d->baseTheme) - return d->baseTheme->createPlatformMenuItem(); - - return QPlatformTheme::createPlatformMenuItem(); + return d->baseTheme->createPlatformMenuItem(); } QPlatformMenu* QFlatpakTheme::createPlatformMenu() const { Q_D(const QFlatpakTheme); - - if (d->baseTheme) - return d->baseTheme->createPlatformMenu(); - - return QPlatformTheme::createPlatformMenu(); + return d->baseTheme->createPlatformMenu(); } QPlatformMenuBar* QFlatpakTheme::createPlatformMenuBar() const { Q_D(const QFlatpakTheme); - - if (d->baseTheme) - return d->baseTheme->createPlatformMenuBar(); - - return QFlatpakTheme::createPlatformMenuBar(); + return d->baseTheme->createPlatformMenuBar(); } void QFlatpakTheme::showPlatformMenuBar() { Q_D(const QFlatpakTheme); - - if (d->baseTheme) - return d->baseTheme->showPlatformMenuBar(); - - return QFlatpakTheme::showPlatformMenuBar(); + return d->baseTheme->showPlatformMenuBar(); } bool QFlatpakTheme::usePlatformNativeDialog(DialogType type) const @@ -139,10 +123,7 @@ bool QFlatpakTheme::usePlatformNativeDialog(DialogType type) const if (type == FileDialog) return true; - if (d->baseTheme) - return d->baseTheme->usePlatformNativeDialog(type); - - return QFlatpakTheme::usePlatformNativeDialog(type); + return d->baseTheme->usePlatformNativeDialog(type); } QPlatformDialogHelper* QFlatpakTheme::createPlatformDialogHelper(DialogType type) const @@ -152,103 +133,64 @@ QPlatformDialogHelper* QFlatpakTheme::createPlatformDialogHelper(DialogType type if (type == FileDialog) return new QFlatpakFileDialog; - if (d->baseTheme) - return d->baseTheme->createPlatformDialogHelper(type); - - return QFlatpakTheme::createPlatformDialogHelper(type); + return d->baseTheme->createPlatformDialogHelper(type); } #ifndef QT_NO_SYSTEMTRAYICON QPlatformSystemTrayIcon* QFlatpakTheme::createPlatformSystemTrayIcon() const { Q_D(const QFlatpakTheme); - - if (d->baseTheme) - return d->baseTheme->createPlatformSystemTrayIcon(); - - return QPlatformTheme::createPlatformSystemTrayIcon(); + return d->baseTheme->createPlatformSystemTrayIcon(); } #endif const QPalette *QFlatpakTheme::palette(Palette type) const { Q_D(const QFlatpakTheme); - - if (d->baseTheme) - return d->baseTheme->palette(type); - - return QPlatformTheme::palette(type); + return d->baseTheme->palette(type); } const QFont* QFlatpakTheme::font(Font type) const { Q_D(const QFlatpakTheme); - - if (d->baseTheme) - return d->baseTheme->font(type); - - return QPlatformTheme::font(type); + return d->baseTheme->font(type); } QVariant QFlatpakTheme::themeHint(ThemeHint hint) const { Q_D(const QFlatpakTheme); - - if (d->baseTheme) - return d->baseTheme->themeHint(hint); - - return QPlatformTheme::themeHint(hint); + return d->baseTheme->themeHint(hint); } QPixmap QFlatpakTheme::standardPixmap(StandardPixmap sp, const QSizeF &size) const { Q_D(const QFlatpakTheme); - - if (d->baseTheme) - return d->baseTheme->standardPixmap(sp, size); - - return QPlatformTheme::standardPixmap(sp, size); + return d->baseTheme->standardPixmap(sp, size); } QIcon QFlatpakTheme::fileIcon(const QFileInfo &fileInfo, QPlatformTheme::IconOptions iconOptions) const { Q_D(const QFlatpakTheme); - - if (d->baseTheme) - return d->baseTheme->fileIcon(fileInfo, iconOptions); - - return QPlatformTheme::fileIcon(fileInfo, iconOptions); + return d->baseTheme->fileIcon(fileInfo, iconOptions); } QIconEngine * QFlatpakTheme::createIconEngine(const QString &iconName) const { Q_D(const QFlatpakTheme); - - if (d->baseTheme) - return d->baseTheme->createIconEngine(iconName); - - return QPlatformTheme::createIconEngine(iconName); + return d->baseTheme->createIconEngine(iconName); } QList<QKeySequence> QFlatpakTheme::keyBindings(QKeySequence::StandardKey key) const { Q_D(const QFlatpakTheme); - - if (d->baseTheme) - return d->baseTheme->keyBindings(key); - - return QPlatformTheme::keyBindings(key); + return d->baseTheme->keyBindings(key); } QString QFlatpakTheme::standardButtonText(int button) const { Q_D(const QFlatpakTheme); - - if (d->baseTheme) - return d->baseTheme->standardButtonText(button); - - return QPlatformTheme::standardButtonText(button); + return d->baseTheme->standardButtonText(button); } QT_END_NAMESPACE |