Fixed several bugs appearing on logout-login in player and messages.

This commit is contained in:
John Preston 2016-10-19 11:59:19 +03:00
parent 48a20f0e71
commit 40fc7379bc
9 changed files with 38 additions and 6 deletions

View file

@ -2927,8 +2927,8 @@ namespace {
if (App::main()) {
App::main()->updateScrollColors();
HistoryLayout::serviceColorsUpdated();
}
HistoryLayout::serviceColorsUpdated();
}
const style::color &msgServiceBg() {

View file

@ -161,6 +161,7 @@ void NotificationsBox::paintEvent(QPaintEvent *e) {
p.drawPixmapLeft(sampleLeft, sampleTop, width(), _notificationSampleSmall);
sampleTop += (isTop ? 1 : -1) * (st::notificationSampleSize.height() + st::notificationsSampleMargin);
}
p.setOpacity(1.);
} else {
p.setOpacity(st::notificationSampleOpacity);
p.drawPixmapLeft(sampleLeft, sampleTop, width(), _notificationSampleSmall);
@ -169,6 +170,8 @@ void NotificationsBox::paintEvent(QPaintEvent *e) {
}
auto labelTop = screenRect.y() + screenRect.height() + st::notificationsBoxCountLabelTop;
p.setFont(st::boxTitleFont);
p.setPen(st::boxTitleFg);
p.drawTextLeft(contentLeft, labelTop, width(), lang(lng_settings_notifications_count));
}

View file

@ -30,10 +30,9 @@ inline constexpr size_t array_size(T(&)[N]) {
}
template <typename T>
inline T take(T &source) {
T result = T();
std_::swap_moveable(result, source);
return std_::move(result);
inline T take(T &source, T &&new_value = T()) {
std_::swap_moveable(new_value, source);
return std_::move(new_value);
}
} // namespace base

View file

@ -975,6 +975,9 @@ void HistoryInner::itemRemoved(HistoryItem *item) {
if (_history != item->history() && _migrated != item->history()) {
return;
}
if (!App::main()) {
return;
}
auto i = _selected.find(item);
if (i != _selected.cend()) {

View file

@ -312,6 +312,9 @@ void CoverWidget::updateTimeLabel() {
void CoverWidget::handleSongChange() {
auto &current = instance()->current();
auto song = current.audio()->song();
if (!song) {
return;
}
TextWithEntities textWithEntities;
if (song->performer.isEmpty()) {

View file

@ -59,6 +59,11 @@ Instance::Instance() {
subscribe(Notify::PeerUpdated(), Notify::PeerUpdatedHandler(observeEvents, [this](const Notify::PeerUpdate &update) {
notifyPeerUpdated(update);
}));
subscribe(Global::RefSelfChanged(), [this] {
if (!App::self()) {
handleLogout();
}
});
}
void Instance::notifyPeerUpdated(const Notify::PeerUpdate &update) {
@ -297,5 +302,17 @@ void Instance::preloadNext() {
}
}
void Instance::handleLogout() {
_current = _seeking = AudioMsgId();
_history = nullptr;
_migrated = nullptr;
_repeatEnabled = _isPlaying = false;
_playlist.clear();
_usePanelPlayer.notify(false, true);
}
} // namespace Player
} // namespace Media

View file

@ -105,6 +105,8 @@ public:
void documentLoadProgress(DocumentData *document);
void clear();
private:
Instance();
friend void start();
@ -117,6 +119,7 @@ private:
void rebuildPlaylist();
void moveInPlaylist(int delta);
void preloadNext();
void handleLogout();
template <typename CheckCallback>
void emitUpdate(CheckCallback check);

View file

@ -161,9 +161,10 @@ QRect ListWidget::getCurrentTrackGeometry() const {
if (exists()) {
auto top = marginTop();
auto current = instance()->current();
auto fullMsgId = current.contextId();
for_const (auto layout, _list) {
auto layoutHeight = layout->height();
if (layout->getItem()->fullId() == current.contextId()) {
if (layout->getItem()->fullId() == fullMsgId) {
return QRect(0, top, width(), layoutHeight);
}
top += layoutHeight;

View file

@ -367,6 +367,9 @@ void Widget::updateTimeLabel() {
void Widget::handleSongChange() {
auto &current = instance()->current();
auto song = current.audio()->song();
if (!song) {
return;
}
TextWithEntities textWithEntities;
if (song->performer.isEmpty()) {