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()) {

View File

@ -227,12 +227,15 @@ void audioPlayNotify() {
emit audioPlayer()->faderOnTimer();
}
// can be called at any moment when audio error
void audioFinish() {
if (player) {
deleteAndMark(player);
delete player;
player = nullptr;
}
if (capture) {
deleteAndMark(capture);
delete capture;
capture = nullptr;
}
alSourceStop(notifySource);

View File

@ -6096,11 +6096,7 @@ void HistoryMessageReply::resize(int width) const {
void HistoryMessageReply::itemRemoved(HistoryMessage *holder, HistoryItem *removed) {
if (replyToMsg == removed) {
delete _replyToVia;
_replyToVia = nullptr;
replyToMsg = nullptr;
replyToMsgId = 0;
clearData(holder);
holder->setPendingInitDimensions();
}
}