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:
commit
80fa36e134
|
@ -1490,8 +1490,8 @@ method_call (GDBusConnection *conn,
|
||||||
g_dbus_method_invocation_return_value (invocation, NULL);
|
g_dbus_method_invocation_return_value (invocation, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static GVariantBuilder *
|
static GVariant *
|
||||||
get_builder_for_icon_pixmap (StatusNotifier *sn, StatusNotifierIcon icon)
|
get_icon_pixmap (StatusNotifier *sn, StatusNotifierIcon icon)
|
||||||
{
|
{
|
||||||
StatusNotifierPrivate *priv = sn->priv;
|
StatusNotifierPrivate *priv = sn->priv;
|
||||||
GVariantBuilder *builder;
|
GVariantBuilder *builder;
|
||||||
|
@ -1535,7 +1535,11 @@ get_builder_for_icon_pixmap (StatusNotifier *sn, StatusNotifierIcon icon)
|
||||||
(GDestroyNotify) cairo_surface_destroy,
|
(GDestroyNotify) cairo_surface_destroy,
|
||||||
surface));
|
surface));
|
||||||
g_variant_builder_close (builder);
|
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 *
|
static GVariant *
|
||||||
|
@ -1585,22 +1589,19 @@ get_prop (GDBusConnection *conn,
|
||||||
? ((priv->icon[STATUS_NOTIFIER_ICON].icon_name)
|
? ((priv->icon[STATUS_NOTIFIER_ICON].icon_name)
|
||||||
? priv->icon[STATUS_NOTIFIER_ICON].icon_name : "") : "");
|
? priv->icon[STATUS_NOTIFIER_ICON].icon_name : "") : "");
|
||||||
else if (!g_strcmp0 (property, "IconPixmap"))
|
else if (!g_strcmp0 (property, "IconPixmap"))
|
||||||
return g_variant_new ("a(iiay)",
|
return get_icon_pixmap (sn, STATUS_NOTIFIER_ICON);
|
||||||
get_builder_for_icon_pixmap (sn, STATUS_NOTIFIER_ICON));
|
|
||||||
else if (!g_strcmp0 (property, "OverlayIconName"))
|
else if (!g_strcmp0 (property, "OverlayIconName"))
|
||||||
return g_variant_new ("s", (!priv->icon[STATUS_NOTIFIER_OVERLAY_ICON].has_pixbuf)
|
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)
|
||||||
? priv->icon[STATUS_NOTIFIER_OVERLAY_ICON].icon_name : "") : "");
|
? priv->icon[STATUS_NOTIFIER_OVERLAY_ICON].icon_name : "") : "");
|
||||||
else if (!g_strcmp0 (property, "OverlayIconPixmap"))
|
else if (!g_strcmp0 (property, "OverlayIconPixmap"))
|
||||||
return g_variant_new ("a(iiay)",
|
return get_icon_pixmap (sn, STATUS_NOTIFIER_OVERLAY_ICON);
|
||||||
get_builder_for_icon_pixmap (sn, STATUS_NOTIFIER_OVERLAY_ICON));
|
|
||||||
else if (!g_strcmp0 (property, "AttentionIconName"))
|
else if (!g_strcmp0 (property, "AttentionIconName"))
|
||||||
return g_variant_new ("s", (!priv->icon[STATUS_NOTIFIER_ATTENTION_ICON].has_pixbuf)
|
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)
|
||||||
? priv->icon[STATUS_NOTIFIER_ATTENTION_ICON].icon_name : "") : "");
|
? priv->icon[STATUS_NOTIFIER_ATTENTION_ICON].icon_name : "") : "");
|
||||||
else if (!g_strcmp0 (property, "AttentionIconPixmap"))
|
else if (!g_strcmp0 (property, "AttentionIconPixmap"))
|
||||||
return g_variant_new ("a(iiay)",
|
return get_icon_pixmap (sn, STATUS_NOTIFIER_ATTENTION_ICON);
|
||||||
get_builder_for_icon_pixmap (sn, STATUS_NOTIFIER_ATTENTION_ICON));
|
|
||||||
else if (!g_strcmp0 (property, "AttentionMovieName"))
|
else if (!g_strcmp0 (property, "AttentionMovieName"))
|
||||||
return g_variant_new ("s", (priv->attention_movie_name)
|
return g_variant_new ("s", (priv->attention_movie_name)
|
||||||
? priv->attention_movie_name : "");
|
? priv->attention_movie_name : "");
|
||||||
|
@ -1620,7 +1621,7 @@ get_prop (GDBusConnection *conn,
|
||||||
return variant;
|
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)",
|
variant = g_variant_new ("(sa(iiay)ss)",
|
||||||
"",
|
"",
|
||||||
builder,
|
builder,
|
||||||
|
|
|
@ -73,12 +73,14 @@ void ContentLayout::clear()
|
||||||
{
|
{
|
||||||
item->widget()->hide();
|
item->widget()->hide();
|
||||||
item->widget()->setParent(nullptr);
|
item->widget()->setParent(nullptr);
|
||||||
|
delete item;
|
||||||
}
|
}
|
||||||
|
|
||||||
while ((item = mainContent->layout()->takeAt(0)) != 0)
|
while ((item = mainContent->layout()->takeAt(0)) != 0)
|
||||||
{
|
{
|
||||||
item->widget()->hide();
|
item->widget()->hide();
|
||||||
item->widget()->setParent(nullptr);
|
item->widget()->setParent(nullptr);
|
||||||
|
delete item;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -72,6 +72,7 @@ void GenericChatroomWidget::compactChange(bool _compact)
|
||||||
// avatar
|
// avatar
|
||||||
if (isCompact())
|
if (isCompact())
|
||||||
{
|
{
|
||||||
|
delete textLayout; // Not needed
|
||||||
setFixedHeight(25);
|
setFixedHeight(25);
|
||||||
avatar->setSize(QSize(20,20));
|
avatar->setSize(QSize(20,20));
|
||||||
mainLayout->addSpacing(18);
|
mainLayout->addSpacing(18);
|
||||||
|
|
|
@ -107,12 +107,12 @@ SystemTrayIcon::SystemTrayIcon()
|
||||||
{
|
{
|
||||||
delete reinterpret_cast<QImage*>(image);
|
delete reinterpret_cast<QImage*>(image);
|
||||||
};
|
};
|
||||||
QImage* image = new QImage(":/img/icon.png");
|
QImage image(":/img/icon.png");
|
||||||
if (image->format() != QImage::Format_RGBA8888_Premultiplied)
|
if (image.format() != QImage::Format_RGBA8888_Premultiplied)
|
||||||
*image = image->convertToFormat(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(),
|
GdkPixbuf* pixbuf = gdk_pixbuf_new_from_data(image.bits(), GDK_COLORSPACE_RGB, image.hasAlphaChannel(),
|
||||||
8, image->width(), image->height(),
|
8, image.width(), image.height(),
|
||||||
image->bytesPerLine(), callbackFreeImage, image);
|
image.bytesPerLine(), callbackFreeImage, &image);
|
||||||
|
|
||||||
statusNotifier = status_notifier_new_from_pixbuf("qtox",
|
statusNotifier = status_notifier_new_from_pixbuf("qtox",
|
||||||
STATUS_NOTIFIER_CATEGORY_APPLICATION_STATUS, pixbuf);
|
STATUS_NOTIFIER_CATEGORY_APPLICATION_STATUS, pixbuf);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user