Fix memory leak in QGtk3Interface::themeName

Pick-to: 6.6 6.5
Change-Id: Ib8c90f7ef66c095f0c1fc04f4cc72bf5eea72ddb
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
This commit is contained in:
Thorbjørn Lindeijer 2023-08-03 16:09:49 +02:00
parent 40b063cd74
commit 233e7e6be3
2 changed files with 11 additions and 8 deletions

View File

@ -475,15 +475,18 @@ QBrush QGtk3Interface::brush(QGtkWidget wtype, QGtkColorSource source, GtkStateF
\internal
\brief Returns the name of the current GTK theme.
*/
const QString QGtk3Interface::themeName() const
QString QGtk3Interface::themeName() const
{
gchar *theme_name;
GtkSettings *settings = gtk_settings_get_default();
if (!settings)
return QString();
QString name;
g_object_get(settings, "gtk-theme-name", &theme_name, nullptr);
return QLatin1StringView(theme_name);
if (GtkSettings *settings = gtk_settings_get_default()) {
gchar *theme_name;
g_object_get(settings, "gtk-theme-name", &theme_name, nullptr);
name = QLatin1StringView(theme_name);
g_free(theme_name);
}
return name;
}
/*!

View File

@ -134,7 +134,7 @@ public:
QIcon fileIcon(const QFileInfo &fileInfo) const;
// Return current GTK theme name
const QString themeName() const;
QString themeName() const;
// Derive color scheme from default colors
Qt::ColorScheme colorSchemeByColors() const;