mirror of https://github.com/procxx/kepka.git
				
				
				
			fixed animation deinit, fixed retina animations
This commit is contained in:
		
							parent
							
								
									79d65c1828
								
							
						
					
					
						commit
						f88dd15647
					
				|  | @ -313,7 +313,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 (fill) p.fillRect(0, 0, cache.width() / factor, cache.height() / factor, st::black); | ||||||
| 			if (smooth && badSize) p.setRenderHint(QPainter::SmoothPixmapTransform); | 			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 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); | 			p.drawImage(to, original, from, Qt::ColorOnly); | ||||||
| 		} | 		} | ||||||
| 		if (request.rounded) { | 		if (request.rounded) { | ||||||
|  | @ -349,6 +349,9 @@ ClipReader::ClipReader(const FileLocation &location, const QByteArray &data) : _ | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void ClipReader::start(int32 framew, int32 frameh, int32 outerw, int32 outerh, bool rounded) { | 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()); | 	int32 factor(cIntRetinaFactor()); | ||||||
| 	_request.factor = factor; | 	_request.factor = factor; | ||||||
| 	_request.framew = framew * factor; | 	_request.framew = framew * factor; | ||||||
|  | @ -377,7 +380,10 @@ QPixmap ClipReader::current(int32 framew, int32 frameh, int32 outerw, int32 oute | ||||||
| 	result = _current = QPixmap(); | 	result = _current = QPixmap(); | ||||||
| 	result = _current = _prepareFrame(_request, current, _cacheForResize, true); | 	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; | 	return result; | ||||||
| } | } | ||||||
|  | @ -406,8 +412,11 @@ ClipState ClipReader::state() const { | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void ClipReader::stop() { | void ClipReader::stop() { | ||||||
| 	_clipManagers.at(_threadIndex)->stop(this); | 	if (_clipManagers.size() <= _threadIndex) error(); | ||||||
| 	_width = _height = 0; | 	if (_state != ClipError) { | ||||||
|  | 		_clipManagers.at(_threadIndex)->stop(this); | ||||||
|  | 		_width = _height = 0; | ||||||
|  | 	} | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void ClipReader::error() { | void ClipReader::error() { | ||||||
|  | @ -752,3 +761,20 @@ void ClipReadManager::process() { | ||||||
| 
 | 
 | ||||||
| 	_processingInThread = 0; | 	_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(); | ||||||
|  | 	} | ||||||
|  | } | ||||||
|  |  | ||||||
|  | @ -559,6 +559,7 @@ public: | ||||||
| 	void start(ClipReader *reader); | 	void start(ClipReader *reader); | ||||||
| 	void update(ClipReader *reader); | 	void update(ClipReader *reader); | ||||||
| 	void stop(ClipReader *reader); | 	void stop(ClipReader *reader); | ||||||
|  | 	~ClipReadManager(); | ||||||
| 
 | 
 | ||||||
| signals: | signals: | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue