summaryrefslogtreecommitdiff
path: root/unity-shared
diff options
authorMarco Trevisan (TreviƱo) <mail@3v1n0.net>2014-10-15 12:56:34 +0000
committerCI bot <ps-jenkins@lists.canonical.com>2014-10-15 12:56:34 +0000
commit405070d2d20785043812e29ca577c276379bee96 (patch)
treecc898ff7cee6b55ce8fc04c3fe17ed481b88dd3f /unity-shared
parentc466489c48bbceea093d132aa0fc898a8cb1611b (diff)
parent404b023492210d709661027f2f92d5eb3dd32ec6 (diff)
GLibSignal: don't call callback function if the object_ value is not matching the CB Fixes: 1366351
Approved by: Christopher Townsend (bzr r3880)
Diffstat (limited to 'unity-shared')
-rw-r--r--unity-shared/StaticCairoText.cpp27
1 files changed, 4 insertions, 23 deletions
diff --git a/unity-shared/StaticCairoText.cpp b/unity-shared/StaticCairoText.cpp
index 804ad1006..ebb634f6e 100644
--- a/unity-shared/StaticCairoText.cpp
+++ b/unity-shared/StaticCairoText.cpp
@@ -34,6 +34,7 @@
#include <pango/pangocairo.h>
#include <UnityCore/GLibWrapper.h>
+#include <UnityCore/GLibSignal.h>
#include "CairoTexture.h"
#include "UnitySettings.h"
@@ -45,7 +46,6 @@ namespace unity
struct StaticCairoText::Impl : sigc::trackable
{
Impl(StaticCairoText* parent, std::string const& text);
- ~Impl();
PangoEllipsizeMode GetPangoEllipsizeMode() const;
PangoAlignment GetPangoAlignment() const;
@@ -77,8 +77,6 @@ struct StaticCairoText::Impl : sigc::trackable
void UpdateTexture();
void OnFontChanged();
- static void FontChanged(GObject* gobject, GParamSpec* pspec, gpointer data);
-
StaticCairoText* parent_;
bool accept_key_nav_focus_;
mutable bool need_new_extent_cache_;
@@ -106,6 +104,8 @@ struct StaticCairoText::Impl : sigc::trackable
int actual_lines_;
float line_spacing_;
double scale_;
+
+ glib::Signal<void, GtkSettings*, GParamSpec*> font_changed_;
};
StaticCairoText::Impl::Impl(StaticCairoText* parent, std::string const& text)
@@ -126,21 +126,10 @@ StaticCairoText::Impl::Impl(StaticCairoText* parent, std::string const& text)
, line_spacing_(0.5)
, scale_(1.0f)
{
- GtkSettings* settings = gtk_settings_get_default(); // not ref'ed
- g_signal_connect(settings, "notify::gtk-font-name",
- (GCallback)FontChanged, this);
-
+ font_changed_.Connect(gtk_settings_get_default(), "notify::gtk-font-name", sigc::hide(sigc::hide(sigc::mem_fun(this, &Impl::OnFontChanged))));
Settings::Instance().font_scaling.changed.connect(sigc::hide(sigc::mem_fun(this, &Impl::OnFontChanged)));
}
-StaticCairoText::Impl::~Impl()
-{
- GtkSettings* settings = gtk_settings_get_default(); // not ref'ed
- g_signal_handlers_disconnect_by_func(settings,
- (void*)FontChanged,
- this);
-}
-
PangoEllipsizeMode StaticCairoText::Impl::GetPangoEllipsizeMode() const
{
switch (ellipsize_)
@@ -780,14 +769,6 @@ void StaticCairoText::Impl::UpdateTexture()
}
}
-void StaticCairoText::Impl::FontChanged(GObject* gobject,
- GParamSpec* pspec,
- gpointer data)
-{
- StaticCairoText::Impl* self = static_cast<StaticCairoText::Impl*>(data);
- self->OnFontChanged();
-}
-
void StaticCairoText::Impl::OnFontChanged()
{
need_new_extent_cache_ = true;