~macslow/unity/backported-remote-add-to-5.0

« back to all changes in this revision

Viewing changes to plugins/unityshell/src/PlacesResultsController.cpp

  • Committer: Tim Penhey
  • Date: 2011-07-18 22:49:37 UTC
  • mfrom: (1278.3.2 maybe-leaks)
  • Revision ID: tim.penhey@canonical.com-20110718224937-hxafqjgahez3i739
Fix a leak on closing.

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
 
29
29
#include "PlacesResultsController.h"
30
30
 
31
 
PlacesResultsController::PlacesResultsController ()
32
 
: _make_things_look_nice_id (0)
 
31
PlacesResultsController::PlacesResultsController()
 
32
  : _make_things_look_nice_id(0)
33
33
{
34
34
  _results_view = NULL;
35
35
}
36
36
 
37
 
PlacesResultsController::~PlacesResultsController ()
 
37
PlacesResultsController::~PlacesResultsController()
38
38
{
 
39
  Clear();
39
40
  if (_make_things_look_nice_id)
40
41
    g_source_remove (_make_things_look_nice_id);
41
42
  _results_view->UnReference ();
100
101
    _make_things_look_nice_id = g_idle_add ((GSourceFunc)PlacesResultsController::MakeThingsLookNice, this);
101
102
}
102
103
 
103
 
void
104
 
PlacesResultsController::Clear ()
 
104
void PlacesResultsController::Clear()
105
105
{
106
106
  std::map <const void *, PlacesGroupController *>::iterator it, eit = _id_to_group.end ();
107
 
  
 
107
 
108
108
  for (it = _id_to_group.begin (); it != eit; ++it)
109
109
  {
110
110
    if (it->second)
111
111
      (it->second)->UnReference ();
112
112
  }
113
113
 
114
 
  _id_to_group.erase (_id_to_group.begin (), _id_to_group.end ());
115
 
  _groups.erase (_groups.begin (), _groups.end ());
 
114
  _id_to_group.clear();
 
115
  _groups.clear();
116
116
 
117
117
  if (_results_view)
118
 
    _results_view->Clear ();
 
118
    _results_view->Clear();
119
119
}
120
120
 
121
 
bool
122
 
PlacesResultsController::ActivateFirst ()
 
121
bool PlacesResultsController::ActivateFirst()
123
122
{
124
123
  std::vector<PlacesGroupController *>::iterator it, eit = _groups.end ();
125
 
  
 
124
 
126
125
  for (it = _groups.begin (); it != eit; ++it)
127
126
    if ((*it)->ActivateFirst ())
128
127
      return true;
133
132
//
134
133
// Introspection
135
134
//
136
 
const gchar*
137
 
PlacesResultsController::GetName ()
 
135
const gchar* PlacesResultsController::GetName()
138
136
{
139
137
  return "PlacesResultsController";
140
138
}
141
139
 
142
 
void
143
 
PlacesResultsController::AddProperties (GVariantBuilder *builder)
 
140
void PlacesResultsController::AddProperties(GVariantBuilder *builder)
144
141
{
145
 
 
146
142
}
147
143
 
148
 
gboolean
149
 
PlacesResultsController::MakeThingsLookNice (PlacesResultsController *self)
 
144
gboolean PlacesResultsController::MakeThingsLookNice(PlacesResultsController *self)
150
145
{
151
146
  PlacesGroup *last_active_group = NULL;
152
147
  std::vector<PlacesGroupController *>::iterator it, eit = self->_groups.end ();