1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

Merge pull request #2323 from dmshynk:fix_memory_leaks

This commit is contained in:
Nils Fenner 2015-10-01 22:25:07 +02:00
commit 80fa36e134
No known key found for this signature in database
GPG Key ID: 9591A163FF9BE04C
4 changed files with 20 additions and 16 deletions

View File

@ -1490,8 +1490,8 @@ method_call (GDBusConnection *conn,
g_dbus_method_invocation_return_value (invocation, NULL);
}
static GVariantBuilder *
get_builder_for_icon_pixmap (StatusNotifier *sn, StatusNotifierIcon icon)
static GVariant *
get_icon_pixmap (StatusNotifier *sn, StatusNotifierIcon icon)
{
StatusNotifierPrivate *priv = sn->priv;
GVariantBuilder *builder;
@ -1535,7 +1535,11 @@ get_builder_for_icon_pixmap (StatusNotifier *sn, StatusNotifierIcon icon)
(GDestroyNotify) cairo_surface_destroy,
surface));
g_variant_builder_close (builder);
return builder;
GVariant *pixmap = g_variant_new ("a(iiay)", builder);
g_variant_builder_unref(builder); // Allow the builder to be deallocated
return pixmap;
}
static GVariant *
@ -1585,22 +1589,19 @@ get_prop (GDBusConnection *conn,
? ((priv->icon[STATUS_NOTIFIER_ICON].icon_name)
? priv->icon[STATUS_NOTIFIER_ICON].icon_name : "") : "");
else if (!g_strcmp0 (property, "IconPixmap"))
return g_variant_new ("a(iiay)",
get_builder_for_icon_pixmap (sn, STATUS_NOTIFIER_ICON));
return get_icon_pixmap (sn, STATUS_NOTIFIER_ICON);
else if (!g_strcmp0 (property, "OverlayIconName"))
return g_variant_new ("s", (!priv->icon[STATUS_NOTIFIER_OVERLAY_ICON].has_pixbuf)
? ((priv->icon[STATUS_NOTIFIER_OVERLAY_ICON].icon_name)
? priv->icon[STATUS_NOTIFIER_OVERLAY_ICON].icon_name : "") : "");
else if (!g_strcmp0 (property, "OverlayIconPixmap"))
return g_variant_new ("a(iiay)",
get_builder_for_icon_pixmap (sn, STATUS_NOTIFIER_OVERLAY_ICON));
return get_icon_pixmap (sn, STATUS_NOTIFIER_OVERLAY_ICON);
else if (!g_strcmp0 (property, "AttentionIconName"))
return g_variant_new ("s", (!priv->icon[STATUS_NOTIFIER_ATTENTION_ICON].has_pixbuf)
? ((priv->icon[STATUS_NOTIFIER_ATTENTION_ICON].icon_name)
? priv->icon[STATUS_NOTIFIER_ATTENTION_ICON].icon_name : "") : "");
else if (!g_strcmp0 (property, "AttentionIconPixmap"))
return g_variant_new ("a(iiay)",
get_builder_for_icon_pixmap (sn, STATUS_NOTIFIER_ATTENTION_ICON));
return get_icon_pixmap (sn, STATUS_NOTIFIER_ATTENTION_ICON);
else if (!g_strcmp0 (property, "AttentionMovieName"))
return g_variant_new ("s", (priv->attention_movie_name)
? priv->attention_movie_name : "");
@ -1620,7 +1621,7 @@ get_prop (GDBusConnection *conn,
return variant;
}
builder = get_builder_for_icon_pixmap (sn, STATUS_NOTIFIER_TOOLTIP_ICON);
builder = get_icon_pixmap (sn, STATUS_NOTIFIER_TOOLTIP_ICON);
variant = g_variant_new ("(sa(iiay)ss)",
"",
builder,

View File

@ -73,12 +73,14 @@ void ContentLayout::clear()
{
item->widget()->hide();
item->widget()->setParent(nullptr);
delete item;
}
while ((item = mainContent->layout()->takeAt(0)) != 0)
{
item->widget()->hide();
item->widget()->setParent(nullptr);
delete item;
}
}

View File

@ -72,6 +72,7 @@ void GenericChatroomWidget::compactChange(bool _compact)
// avatar
if (isCompact())
{
delete textLayout; // Not needed
setFixedHeight(25);
avatar->setSize(QSize(20,20));
mainLayout->addSpacing(18);

View File

@ -107,12 +107,12 @@ SystemTrayIcon::SystemTrayIcon()
{
delete reinterpret_cast<QImage*>(image);
};
QImage* image = new QImage(":/img/icon.png");
if (image->format() != QImage::Format_RGBA8888_Premultiplied)
*image = image->convertToFormat(QImage::Format_RGBA8888_Premultiplied);
GdkPixbuf* pixbuf = gdk_pixbuf_new_from_data(image->bits(), GDK_COLORSPACE_RGB, image->hasAlphaChannel(),
8, image->width(), image->height(),
image->bytesPerLine(), callbackFreeImage, image);
QImage image(":/img/icon.png");
if (image.format() != QImage::Format_RGBA8888_Premultiplied)
image = image.convertToFormat(QImage::Format_RGBA8888_Premultiplied);
GdkPixbuf* pixbuf = gdk_pixbuf_new_from_data(image.bits(), GDK_COLORSPACE_RGB, image.hasAlphaChannel(),
8, image.width(), image.height(),
image.bytesPerLine(), callbackFreeImage, &image);
statusNotifier = status_notifier_new_from_pixbuf("qtox",
STATUS_NOTIFIER_CATEGORY_APPLICATION_STATUS, pixbuf);