~ken-vandine/unity/make-quicklists-work-again

« back to all changes in this revision

Viewing changes to src/IconTexture.cpp

  • Committer: Gord Allott
  • Date: 2011-04-10 15:46:33 UTC
  • mfrom: (1090.1.2 fixes-08-04)
  • Revision ID: gord.allott@canonical.com-20110410154633-5a11qi1pzn8nmmad
fixes lp:749890 and a few mem leaks

Show diffs side-by-side

added added

removed removed

Lines of Context:
70
70
IconTexture::~IconTexture ()
71
71
{
72
72
  g_free (_icon_name);
73
 
 
74
73
  if (_texture_cached)
 
74
  {   
75
75
    _texture_cached->UnReference ();
 
76
    if (_texture_cached->GetReferenceCount () == 1)
 
77
    {
 
78
      _texture_cached->UnReference ();
 
79
    }
 
80
  }
76
81
}
77
82
 
78
83
void
138
143
{
139
144
  TextureCache *cache = TextureCache::GetDefault ();
140
145
  char *id = NULL;
141
 
 
142
146
  _pixbuf_cached = pixbuf;
143
147
 
144
148
  // Cache the pixbuf dimensions so we scale correctly
148
152
  // Try and get a texture from the texture cache
149
153
  id = g_strdup_printf ("IconTexture.%s", _icon_name);
150
154
  if (_texture_cached)
 
155
  {
151
156
    _texture_cached->UnReference ();
 
157
     if (_texture_cached->GetReferenceCount () == 1)
 
158
       _texture_cached->UnReference (); 
 
159
  }
152
160
 
153
161
  _texture_cached = cache->FindTexture (id,
154
162
                                        _texture_width,
224
232
IconTexture::SetTexture (nux::BaseTexture *texture)
225
233
{
226
234
  if (_texture_cached)
 
235
  {
227
236
    _texture_cached->UnReference ();
 
237
    if (_texture_cached->GetReferenceCount () == 1)
 
238
      _texture_cached->UnReference (); 
 
239
  }
 
240
  
228
241
  _texture_cached = texture;
229
242
  _texture_cached->Reference ();
230
243
}