~3v1n0/unity/lim-everywhere

« back to all changes in this revision

Viewing changes to UnityCore/AppmenuIndicator.cpp

  • Committer: Marco Trevisan (Treviño)
  • Date: 2015-02-03 12:40:54 UTC
  • Revision ID: mail@3v1n0.net-20150203124054-5oimzsv95w07uicl
AppmenuIndicator: protect from crashes when parent indicator is destructed

Show diffs side-by-side

added added

removed removed

Lines of Context:
35
35
{
36
36
  Impl(AppmenuIndicator* parent)
37
37
  {
38
 
    parent->on_entry_added.connect([this] (Entry::Ptr const& entry) {
 
38
    connections_.Add(parent->on_entry_added.connect([this] (Entry::Ptr const& entry) {
39
39
      auto it = window_entries_.find(entry->parent_window());
40
40
 
41
41
      if (it != window_entries_.end())
48
48
      {
49
49
        window_entries_.insert({entry->parent_window(), {entry}});
50
50
      }
51
 
    });
 
51
    }));
52
52
 
53
 
    parent->on_entry_removed.connect([this] (Entry::Ptr const& entry) {
 
53
    connections_.Add(parent->on_entry_removed.connect([this] (Entry::Ptr const& entry) {
54
54
      auto it = window_entries_.find(entry->parent_window());
55
55
 
56
56
      if (it != window_entries_.end())
61
61
        if (entries.empty())
62
62
          window_entries_.erase(it);
63
63
      }
64
 
    });
 
64
    }));
65
65
  }
66
66
 
 
67
  connection::Manager connections_;
67
68
  std::unordered_map<uint32_t, Indicator::Entries> window_entries_;
68
69
};
69
70