2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 14:38:15 +00:00

Dependent items clearing done better

Fixed crash on launch if audio playback could not be started
This commit is contained in:
John Preston
2016-03-25 23:46:35 +03:00
parent 40ab82e4bd
commit 29c6b8e2d2
3 changed files with 14 additions and 11 deletions

View File

@@ -67,7 +67,8 @@ namespace {
SharedContactItems sharedContactItems;
GifItems gifItems;
typedef QMap<HistoryItem*, OrderedSet<HistoryItem*> > DependentItems;
typedef OrderedSet<HistoryItem*> DependentItemsSet;
typedef QMap<HistoryItem*, DependentItemsSet> DependentItems;
DependentItems dependentItems;
Histories histories;
@@ -1803,10 +1804,13 @@ namespace App {
historyItemDetached(item);
auto j = ::dependentItems.find(item);
if (j != ::dependentItems.cend()) {
for_const (HistoryItem *dependent, j.value()) {
DependentItemsSet items;
std::swap(items, j.value());
::dependentItems.erase(j);
for_const (HistoryItem *dependent, items) {
dependent->dependencyItemRemoved(item);
}
::dependentItems.erase(j);
}
if (App::main() && !App::quitting()) {
App::main()->itemRemoved(item);
@@ -1903,7 +1907,7 @@ namespace App {
}
void historyUnregDependency(HistoryItem *dependent, HistoryItem *dependency) {
DependentItems::iterator i = ::dependentItems.find(dependency);
auto i = ::dependentItems.find(dependency);
if (i != ::dependentItems.cend()) {
i.value().remove(dependent);
if (i.value().isEmpty()) {