diff --git a/Telegram/SourceFiles/gui/animation.cpp b/Telegram/SourceFiles/gui/animation.cpp index 700af59918..3a0aa5d654 100644 --- a/Telegram/SourceFiles/gui/animation.cpp +++ b/Telegram/SourceFiles/gui/animation.cpp @@ -315,7 +315,7 @@ QPixmap _prepareFrame(const ClipFrameRequest &request, const QImage &original, Q if (fill) p.fillRect(0, 0, cache.width() / factor, cache.height() / factor, st::black); if (smooth && badSize) p.setRenderHint(QPainter::SmoothPixmapTransform); QRect to((request.outerw - request.framew) / (2 * factor), (request.outerh - request.frameh) / (2 * factor), request.framew / factor, request.frameh / factor); - QRect from(0, 0, original.width() / factor, original.height() / factor); + QRect from(0, 0, original.width(), original.height()); p.drawImage(to, original, from, Qt::ColorOnly); } if (request.rounded) { @@ -351,6 +351,9 @@ ClipReader::ClipReader(const FileLocation &location, const QByteArray &data) : _ } void ClipReader::start(int32 framew, int32 frameh, int32 outerw, int32 outerh, bool rounded) { + if (_clipManagers.size() <= _threadIndex) error(); + if (_state == ClipError) return; + int32 factor(cIntRetinaFactor()); _request.factor = factor; _request.framew = framew * factor; @@ -380,7 +383,10 @@ QPixmap ClipReader::current(int32 framew, int32 frameh, int32 outerw, int32 oute result = _current = QPixmap(); result = _current = _prepareFrame(_request, current, _cacheForResize, true); - _clipManagers.at(_threadIndex)->update(this); + if (_clipManagers.size() <= _threadIndex) error(); + if (_state != ClipError) { + _clipManagers.at(_threadIndex)->update(this); + } return result; } @@ -409,8 +415,11 @@ ClipState ClipReader::state() const { } void ClipReader::stop() { - _clipManagers.at(_threadIndex)->stop(this); - _width = _height = 0; + if (_clipManagers.size() <= _threadIndex) error(); + if (_state != ClipError) { + _clipManagers.at(_threadIndex)->stop(this); + _width = _height = 0; + } } void ClipReader::error() { @@ -761,3 +770,20 @@ void ClipReadManager::process() { _processingInThread = 0; } + +ClipReadManager::~ClipReadManager() { + { + QMutexLocker lock(&_readerPointersMutex); + for (ReaderPointers::iterator i = _readerPointers.begin(), e = _readerPointers.end(); i != e; ++i) { + if (i.value()) { + i.key()->_private = 0; + } + } + _readerPointers.clear(); + + for (Readers::iterator i = _readers.begin(), e = _readers.end(); i != e; ++i) { + delete i.key(); + } + _readers.clear(); + } +} diff --git a/Telegram/SourceFiles/gui/animation.h b/Telegram/SourceFiles/gui/animation.h index bbe1f23968..fce4f1ace2 100644 --- a/Telegram/SourceFiles/gui/animation.h +++ b/Telegram/SourceFiles/gui/animation.h @@ -560,6 +560,7 @@ public: void start(ClipReader *reader); void update(ClipReader *reader); void stop(ClipReader *reader); + ~ClipReadManager(); signals: diff --git a/Telegram/SourceFiles/history.h b/Telegram/SourceFiles/history.h index 21f309fb20..790dff6d3e 100644 --- a/Telegram/SourceFiles/history.h +++ b/Telegram/SourceFiles/history.h @@ -45,7 +45,7 @@ public: typedef QHash Map; Map map; - Histories() : unreadFull(0), unreadMuted(0), _a_typings(animation(this, &Histories::step_typings)) { + Histories() : _a_typings(animation(this, &Histories::step_typings)), unreadFull(0), unreadMuted(0) { } void regSendAction(History *history, UserData *user, const MTPSendMessageAction &action); diff --git a/Telegram/SourceFiles/window.cpp b/Telegram/SourceFiles/window.cpp index 3f067221e3..bdbbb9791d 100644 --- a/Telegram/SourceFiles/window.cpp +++ b/Telegram/SourceFiles/window.cpp @@ -83,8 +83,8 @@ NotifyWindow::NotifyWindow(HistoryItem *msg, int32 x, int32 y, int32 fwdCount) : , hiding(false) , _index(0) , a_opacity(0) -, a_y(y + st::notifyHeight + st::notifyDeltaY) , a_func(anim::linear) +, a_y(y + st::notifyHeight + st::notifyDeltaY) , _a_appearance(animation(this, &NotifyWindow::step_appearance)) { updateNotifyDisplay();