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>
This commit is contained in:
parent
1718efe8fa
commit
96ba39b1ee
@ -95,41 +95,25 @@ QFlatpakTheme::QFlatpakTheme()
|
|||||||
QPlatformMenuItem* QFlatpakTheme::createPlatformMenuItem() const
|
QPlatformMenuItem* QFlatpakTheme::createPlatformMenuItem() const
|
||||||
{
|
{
|
||||||
Q_D(const QFlatpakTheme);
|
Q_D(const QFlatpakTheme);
|
||||||
|
|
||||||
if (d->baseTheme)
|
|
||||||
return d->baseTheme->createPlatformMenuItem();
|
return d->baseTheme->createPlatformMenuItem();
|
||||||
|
|
||||||
return QPlatformTheme::createPlatformMenuItem();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QPlatformMenu* QFlatpakTheme::createPlatformMenu() const
|
QPlatformMenu* QFlatpakTheme::createPlatformMenu() const
|
||||||
{
|
{
|
||||||
Q_D(const QFlatpakTheme);
|
Q_D(const QFlatpakTheme);
|
||||||
|
|
||||||
if (d->baseTheme)
|
|
||||||
return d->baseTheme->createPlatformMenu();
|
return d->baseTheme->createPlatformMenu();
|
||||||
|
|
||||||
return QPlatformTheme::createPlatformMenu();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QPlatformMenuBar* QFlatpakTheme::createPlatformMenuBar() const
|
QPlatformMenuBar* QFlatpakTheme::createPlatformMenuBar() const
|
||||||
{
|
{
|
||||||
Q_D(const QFlatpakTheme);
|
Q_D(const QFlatpakTheme);
|
||||||
|
|
||||||
if (d->baseTheme)
|
|
||||||
return d->baseTheme->createPlatformMenuBar();
|
return d->baseTheme->createPlatformMenuBar();
|
||||||
|
|
||||||
return QFlatpakTheme::createPlatformMenuBar();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void QFlatpakTheme::showPlatformMenuBar()
|
void QFlatpakTheme::showPlatformMenuBar()
|
||||||
{
|
{
|
||||||
Q_D(const QFlatpakTheme);
|
Q_D(const QFlatpakTheme);
|
||||||
|
|
||||||
if (d->baseTheme)
|
|
||||||
return d->baseTheme->showPlatformMenuBar();
|
return d->baseTheme->showPlatformMenuBar();
|
||||||
|
|
||||||
return QFlatpakTheme::showPlatformMenuBar();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QFlatpakTheme::usePlatformNativeDialog(DialogType type) const
|
bool QFlatpakTheme::usePlatformNativeDialog(DialogType type) const
|
||||||
@ -139,10 +123,7 @@ bool QFlatpakTheme::usePlatformNativeDialog(DialogType type) const
|
|||||||
if (type == FileDialog)
|
if (type == FileDialog)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (d->baseTheme)
|
|
||||||
return d->baseTheme->usePlatformNativeDialog(type);
|
return d->baseTheme->usePlatformNativeDialog(type);
|
||||||
|
|
||||||
return QFlatpakTheme::usePlatformNativeDialog(type);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QPlatformDialogHelper* QFlatpakTheme::createPlatformDialogHelper(DialogType type) const
|
QPlatformDialogHelper* QFlatpakTheme::createPlatformDialogHelper(DialogType type) const
|
||||||
@ -152,103 +133,64 @@ QPlatformDialogHelper* QFlatpakTheme::createPlatformDialogHelper(DialogType type
|
|||||||
if (type == FileDialog)
|
if (type == FileDialog)
|
||||||
return new QFlatpakFileDialog;
|
return new QFlatpakFileDialog;
|
||||||
|
|
||||||
if (d->baseTheme)
|
|
||||||
return d->baseTheme->createPlatformDialogHelper(type);
|
return d->baseTheme->createPlatformDialogHelper(type);
|
||||||
|
|
||||||
return QFlatpakTheme::createPlatformDialogHelper(type);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef QT_NO_SYSTEMTRAYICON
|
#ifndef QT_NO_SYSTEMTRAYICON
|
||||||
QPlatformSystemTrayIcon* QFlatpakTheme::createPlatformSystemTrayIcon() const
|
QPlatformSystemTrayIcon* QFlatpakTheme::createPlatformSystemTrayIcon() const
|
||||||
{
|
{
|
||||||
Q_D(const QFlatpakTheme);
|
Q_D(const QFlatpakTheme);
|
||||||
|
|
||||||
if (d->baseTheme)
|
|
||||||
return d->baseTheme->createPlatformSystemTrayIcon();
|
return d->baseTheme->createPlatformSystemTrayIcon();
|
||||||
|
|
||||||
return QPlatformTheme::createPlatformSystemTrayIcon();
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
const QPalette *QFlatpakTheme::palette(Palette type) const
|
const QPalette *QFlatpakTheme::palette(Palette type) const
|
||||||
{
|
{
|
||||||
Q_D(const QFlatpakTheme);
|
Q_D(const QFlatpakTheme);
|
||||||
|
|
||||||
if (d->baseTheme)
|
|
||||||
return d->baseTheme->palette(type);
|
return d->baseTheme->palette(type);
|
||||||
|
|
||||||
return QPlatformTheme::palette(type);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const QFont* QFlatpakTheme::font(Font type) const
|
const QFont* QFlatpakTheme::font(Font type) const
|
||||||
{
|
{
|
||||||
Q_D(const QFlatpakTheme);
|
Q_D(const QFlatpakTheme);
|
||||||
|
|
||||||
if (d->baseTheme)
|
|
||||||
return d->baseTheme->font(type);
|
return d->baseTheme->font(type);
|
||||||
|
|
||||||
return QPlatformTheme::font(type);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant QFlatpakTheme::themeHint(ThemeHint hint) const
|
QVariant QFlatpakTheme::themeHint(ThemeHint hint) const
|
||||||
{
|
{
|
||||||
Q_D(const QFlatpakTheme);
|
Q_D(const QFlatpakTheme);
|
||||||
|
|
||||||
if (d->baseTheme)
|
|
||||||
return d->baseTheme->themeHint(hint);
|
return d->baseTheme->themeHint(hint);
|
||||||
|
|
||||||
return QPlatformTheme::themeHint(hint);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QPixmap QFlatpakTheme::standardPixmap(StandardPixmap sp, const QSizeF &size) const
|
QPixmap QFlatpakTheme::standardPixmap(StandardPixmap sp, const QSizeF &size) const
|
||||||
{
|
{
|
||||||
Q_D(const QFlatpakTheme);
|
Q_D(const QFlatpakTheme);
|
||||||
|
|
||||||
if (d->baseTheme)
|
|
||||||
return d->baseTheme->standardPixmap(sp, size);
|
return d->baseTheme->standardPixmap(sp, size);
|
||||||
|
|
||||||
return QPlatformTheme::standardPixmap(sp, size);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QIcon QFlatpakTheme::fileIcon(const QFileInfo &fileInfo,
|
QIcon QFlatpakTheme::fileIcon(const QFileInfo &fileInfo,
|
||||||
QPlatformTheme::IconOptions iconOptions) const
|
QPlatformTheme::IconOptions iconOptions) const
|
||||||
{
|
{
|
||||||
Q_D(const QFlatpakTheme);
|
Q_D(const QFlatpakTheme);
|
||||||
|
|
||||||
if (d->baseTheme)
|
|
||||||
return d->baseTheme->fileIcon(fileInfo, iconOptions);
|
return d->baseTheme->fileIcon(fileInfo, iconOptions);
|
||||||
|
|
||||||
return QPlatformTheme::fileIcon(fileInfo, iconOptions);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QIconEngine * QFlatpakTheme::createIconEngine(const QString &iconName) const
|
QIconEngine * QFlatpakTheme::createIconEngine(const QString &iconName) const
|
||||||
{
|
{
|
||||||
Q_D(const QFlatpakTheme);
|
Q_D(const QFlatpakTheme);
|
||||||
|
|
||||||
if (d->baseTheme)
|
|
||||||
return d->baseTheme->createIconEngine(iconName);
|
return d->baseTheme->createIconEngine(iconName);
|
||||||
|
|
||||||
return QPlatformTheme::createIconEngine(iconName);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<QKeySequence> QFlatpakTheme::keyBindings(QKeySequence::StandardKey key) const
|
QList<QKeySequence> QFlatpakTheme::keyBindings(QKeySequence::StandardKey key) const
|
||||||
{
|
{
|
||||||
Q_D(const QFlatpakTheme);
|
Q_D(const QFlatpakTheme);
|
||||||
|
|
||||||
if (d->baseTheme)
|
|
||||||
return d->baseTheme->keyBindings(key);
|
return d->baseTheme->keyBindings(key);
|
||||||
|
|
||||||
return QPlatformTheme::keyBindings(key);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QString QFlatpakTheme::standardButtonText(int button) const
|
QString QFlatpakTheme::standardButtonText(int button) const
|
||||||
{
|
{
|
||||||
Q_D(const QFlatpakTheme);
|
Q_D(const QFlatpakTheme);
|
||||||
|
|
||||||
if (d->baseTheme)
|
|
||||||
return d->baseTheme->standardButtonText(button);
|
return d->baseTheme->standardButtonText(button);
|
||||||
|
|
||||||
return QPlatformTheme::standardButtonText(button);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
Loading…
x
Reference in New Issue
Block a user