Skip to content

Commit

Permalink
crash fix for 0.9.11.dev version
Browse files Browse the repository at this point in the history
  • Loading branch information
john-preston committed Nov 22, 2015
1 parent 204977d commit 032ca37
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Telegram/SourceFiles/historywidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6516,7 +6516,7 @@ void HistoryWidget::onAnimActiveStep() {
return _animActiveTimer.stop();
}

HistoryItem *item = (_activeAnimMsgId > 0) ? App::histItemById(_channel, _activeAnimMsgId) : App::histItemById(_migrated->channelId(), -_activeAnimMsgId);
HistoryItem *item = (_activeAnimMsgId < 0 && -_activeAnimMsgId < ServerMaxMsgId && _migrated) ? App::histItemById(_migrated->channelId(), -_activeAnimMsgId) : App::histItemById(_channel, _activeAnimMsgId);
if (!item || item->detached()) return _animActiveTimer.stop();

if (getms() - _animActiveStart > st::activeFadeInDuration + st::activeFadeOutDuration) {
Expand Down
28 changes: 16 additions & 12 deletions Telegram/SourceFiles/mediaview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1538,12 +1538,14 @@ void MediaView::preloadData(int32 delta) {
for (int32 i = from; i <= to; ++i) {
History *previewHistory = _msgmigrated ? _migrated : _history;
int32 previewIndex = i;
if (_msgmigrated && previewIndex >= _migrated->overview[_overview].size()) {
previewHistory = _history;
previewIndex -= _migrated->overview[_overview].size() + (_history->overviewCount(_overview) - _history->overview[_overview].size());
} else if (!_msgmigrated && previewIndex < 0) {
previewHistory = _migrated;
previewIndex += _migrated->overview[_overview].size();
if (_migrated) {
if (_msgmigrated && previewIndex >= _migrated->overview[_overview].size()) {
previewHistory = _history;
previewIndex -= _migrated->overview[_overview].size() + (_history->overviewCount(_overview) - _history->overview[_overview].size());
} else if (!_msgmigrated && previewIndex < 0) {
previewHistory = _migrated;
previewIndex += _migrated->overview[_overview].size();
}
}
if (previewIndex >= 0 && previewIndex < previewHistory->overview[_overview].size() && (previewHistory != (_msgmigrated ? _migrated : _history) || previewIndex != _index)) {
if (HistoryItem *item = App::histItemById(previewHistory->channelId(), previewHistory->overview[_overview][previewIndex])) {
Expand All @@ -1559,12 +1561,14 @@ void MediaView::preloadData(int32 delta) {
}
int32 forgetIndex = _index - delta * 2;
History *forgetHistory = _msgmigrated ? _migrated : _history;
if (_msgmigrated && forgetIndex >= _migrated->overview[_overview].size()) {
forgetHistory = _history;
forgetIndex -= _migrated->overview[_overview].size() + (_history->overviewCount(_overview) - _history->overview[_overview].size());
} else if (!_msgmigrated && forgetIndex < 0) {
forgetHistory = _migrated;
forgetIndex += _migrated->overview[_overview].size();
if (_migrated) {
if (_msgmigrated && forgetIndex >= _migrated->overview[_overview].size()) {
forgetHistory = _history;
forgetIndex -= _migrated->overview[_overview].size() + (_history->overviewCount(_overview) - _history->overview[_overview].size());
} else if (!_msgmigrated && forgetIndex < 0) {
forgetHistory = _migrated;
forgetIndex += _migrated->overview[_overview].size();
}
}
if (forgetIndex >= 0 && forgetIndex < forgetHistory->overview[_overview].size() && (forgetHistory != (_msgmigrated ? _migrated : _history) || forgetIndex != _index)) {
if (HistoryItem *item = App::histItemById(forgetHistory->channelId(), forgetHistory->overview[_overview][forgetIndex])) {
Expand Down

0 comments on commit 032ca37

Please sign in to comment.