Fix crash with apps reloading. Yeah, we shouldn't delete pointers that are mentioned elsewhere... Signed-off-by: Tomas Janousek <tomi@nomi.cz>
Tomas Janousek tomi@nomi.cz
1 files changed,
8 insertions(+),
3 deletions(-)
jump to
M
src/Remember.cc
→
src/Remember.cc
@@ -593,6 +593,7 @@ ifstream apps_file(apps_string.c_str());
// we merge the old patterns with new ones Patterns *old_pats = m_pats.release(); + set<Application *> reused_apps; m_pats.reset(new Patterns()); m_startups.clear();@@ -621,9 +622,10 @@ ClientPattern *pat = new ClientPattern(line.c_str() + pos, true);
if (!in_group) { if ((err = pat->error()) == 0) { Application *app = findMatchingPatterns(pat, old_pats, false); - if (app) + if (app) { app->reset(); - else + reused_apps.insert(app); + } else app = new Application(false); m_pats->push_back(make_pair(pat, app));@@ -659,6 +661,8 @@ }
if (!app) app = new Application(in_group, pat); + else + reused_apps.insert(app); while (!grouped_pats.empty()) { // associate all the patterns with this app@@ -695,7 +699,8 @@ set<Application *> old_apps; // no duplicates
while (!old_pats->empty()) { it = old_pats->begin(); delete it->first; // ClientPattern - old_apps.insert(it->second); // Application, not necessarily unique + if (reused_apps.find(it->second) == reused_apps.end()) + old_apps.insert(it->second); // Application, not necessarily unique old_pats->erase(it); }