three crashes fixed
This commit is contained in:
		
							parent
							
								
									bbc804bd56
								
							
						
					
					
						commit
						01c26cedb1
					
				
					 3 changed files with 15 additions and 10 deletions
				
			
		| 
						 | 
				
			
			@ -2403,7 +2403,7 @@ public:
 | 
			
		|||
	}
 | 
			
		||||
 | 
			
		||||
	bool open(qint64 position = 0) {
 | 
			
		||||
		if (!AbstractFFMpegLoader::openFile()) {
 | 
			
		||||
		if (!AbstractFFMpegLoader::open()) {
 | 
			
		||||
			return false;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -2536,13 +2536,14 @@ void History::clear(bool leaveItems) {
 | 
			
		|||
			if (App::wnd() && !App::quiting()) App::wnd()->mediaOverviewUpdated(peer, MediaOverviewType(i));
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	for (Blocks::const_iterator i = blocks.cbegin(), e = blocks.cend(); i != e; ++i) {
 | 
			
		||||
	Blocks lst = blocks;
 | 
			
		||||
	blocks.clear();
 | 
			
		||||
	for (Blocks::const_iterator i = lst.cbegin(), e = lst.cend(); i != e; ++i) {
 | 
			
		||||
		if (leaveItems) {
 | 
			
		||||
			(*i)->clear(true);
 | 
			
		||||
		}
 | 
			
		||||
		delete *i;
 | 
			
		||||
	}
 | 
			
		||||
	blocks.clear();
 | 
			
		||||
	if (leaveItems) {
 | 
			
		||||
		lastKeyboardInited = false;
 | 
			
		||||
	} else {
 | 
			
		||||
| 
						 | 
				
			
			@ -2698,16 +2699,17 @@ int32 HistoryBlock::geomResize(int32 newWidth, int32 *ytransform, const HistoryI
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
void HistoryBlock::clear(bool leaveItems) {
 | 
			
		||||
	Items lst = items;
 | 
			
		||||
	items.clear();
 | 
			
		||||
	if (leaveItems) {
 | 
			
		||||
		for (Items::const_iterator i = items.cbegin(), e = items.cend(); i != e; ++i) {
 | 
			
		||||
		for (Items::const_iterator i = lst.cbegin(), e = lst.cend(); i != e; ++i) {
 | 
			
		||||
			(*i)->detachFast();
 | 
			
		||||
		}
 | 
			
		||||
	} else {
 | 
			
		||||
		for (Items::const_iterator i = items.cbegin(), e = items.cend(); i != e; ++i) {
 | 
			
		||||
		for (Items::const_iterator i = lst.cbegin(), e = lst.cend(); i != e; ++i) {
 | 
			
		||||
			delete *i;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	items.clear();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void HistoryBlock::removeItem(HistoryItem *item) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -546,21 +546,21 @@ void MTPabstractTcpConnection::socketRead() {
 | 
			
		|||
	}
 | 
			
		||||
 | 
			
		||||
	do {
 | 
			
		||||
		char *readTo = currentPos;
 | 
			
		||||
		uint32 toRead = packetLeft ? packetLeft : (readingToShort ? (MTPShortBufferSize * sizeof(mtpPrime)-packetRead) : 4);
 | 
			
		||||
		if (readingToShort) {
 | 
			
		||||
			if (currentPos + toRead > ((char*)shortBuffer) + MTPShortBufferSize * sizeof(mtpPrime)) {
 | 
			
		||||
				longBuffer.resize(((packetRead + toRead) >> 2) + 1);
 | 
			
		||||
				memcpy(&longBuffer[0], shortBuffer, packetRead);
 | 
			
		||||
				readTo = ((char*)&longBuffer[0]) + packetRead;
 | 
			
		||||
				currentPos = ((char*)&longBuffer[0]) + packetRead;
 | 
			
		||||
				readingToShort = false;
 | 
			
		||||
			}
 | 
			
		||||
		} else {
 | 
			
		||||
			if (longBuffer.size() * sizeof(mtpPrime) < packetRead + toRead) {
 | 
			
		||||
				longBuffer.resize(((packetRead + toRead) >> 2) + 1);
 | 
			
		||||
				readTo = ((char*)&longBuffer[0]) + packetRead;
 | 
			
		||||
				currentPos = ((char*)&longBuffer[0]) + packetRead;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		int32 bytes = (int32)sock.read(readTo, toRead);
 | 
			
		||||
		int32 bytes = (int32)sock.read(currentPos, toRead);
 | 
			
		||||
		if (bytes > 0) {
 | 
			
		||||
			TCP_LOG(("TCP Info: read %1 bytes").arg(bytes));
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -573,6 +573,7 @@ void MTPabstractTcpConnection::socketRead() {
 | 
			
		|||
					currentPos = (char*)shortBuffer;
 | 
			
		||||
					packetRead = packetLeft = 0;
 | 
			
		||||
					readingToShort = true;
 | 
			
		||||
					longBuffer.clear();
 | 
			
		||||
				} else {
 | 
			
		||||
					TCP_LOG(("TCP Info: not enough %1 for packet! read %2").arg(packetLeft).arg(packetRead));
 | 
			
		||||
					emit receivedSome();
 | 
			
		||||
| 
						 | 
				
			
			@ -602,10 +603,12 @@ void MTPabstractTcpConnection::socketRead() {
 | 
			
		|||
					if (!packetRead) {
 | 
			
		||||
						currentPos = (char*)shortBuffer;
 | 
			
		||||
						readingToShort = true;
 | 
			
		||||
						longBuffer.clear();
 | 
			
		||||
					} else if (!readingToShort && packetRead < MTPShortBufferSize * sizeof(mtpPrime)) {
 | 
			
		||||
						memcpy(shortBuffer, currentPos - packetRead, packetRead);
 | 
			
		||||
						currentPos = (char*)shortBuffer;
 | 
			
		||||
						readingToShort = true;
 | 
			
		||||
						longBuffer.clear();
 | 
			
		||||
					}
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		
		Reference in a new issue