mirror of
https://github.com/scorpion-26/gBar.git
synced 2024-11-22 11:12:49 +00:00
SNI: Fix crash with ToolTip of type String
TeamViewer exposes ToolTip as String (which is not compliant to the spec). This caused gBar to crash, since we assume, that the tooltip variant is always a container (struct), which glibc doesn't like. We now fallback to g_variant_get_string if it is not according to spec Fixes https://github.com/scorpion-26/gBar/issues/37
This commit is contained in:
parent
1a25dbdec6
commit
ec478dec9c
1 changed files with 21 additions and 4 deletions
25
src/SNI.cpp
25
src/SNI.cpp
|
@ -234,10 +234,27 @@ namespace SNI
|
||||||
{
|
{
|
||||||
GVariant* tooltipVar;
|
GVariant* tooltipVar;
|
||||||
g_variant_get_child(tooltip, 0, "v", &tooltipVar);
|
g_variant_get_child(tooltip, 0, "v", &tooltipVar);
|
||||||
const gchar* title;
|
const gchar* title = nullptr;
|
||||||
// Both telegram and discord only set the "title" component
|
if (g_variant_is_container(tooltipVar) && g_variant_n_children(tooltipVar) >= 4)
|
||||||
g_variant_get_child(tooltipVar, 2, "s", &title);
|
{
|
||||||
item.tooltip = title;
|
// According to spec, ToolTip is of type (sa(iiab)ss) => 4 children
|
||||||
|
// Most icons only set the "title" component (e.g. Discord, KeePassXC, ...)
|
||||||
|
g_variant_get_child(tooltipVar, 2, "s", &title);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// TeamViewer only exposes a string, which is not according to spec!
|
||||||
|
title = g_variant_get_string(tooltipVar, nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (title != nullptr)
|
||||||
|
{
|
||||||
|
item.tooltip = title;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
LOG("SNI: Error querying tooltip");
|
||||||
|
}
|
||||||
LOG("SNI: Title: " << item.tooltip);
|
LOG("SNI: Title: " << item.tooltip);
|
||||||
g_variant_unref(tooltip);
|
g_variant_unref(tooltip);
|
||||||
g_variant_unref(tooltipVar);
|
g_variant_unref(tooltipVar);
|
||||||
|
|
Loading…
Reference in a new issue