mirror of https://github.com/procxx/kepka.git
				
				
				
			three crashes fixed
This commit is contained in:
		
							parent
							
								
									bbc804bd56
								
							
						
					
					
						commit
						01c26cedb1
					
				| 
						 | 
					@ -2403,7 +2403,7 @@ public:
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	bool open(qint64 position = 0) {
 | 
						bool open(qint64 position = 0) {
 | 
				
			||||||
		if (!AbstractFFMpegLoader::openFile()) {
 | 
							if (!AbstractFFMpegLoader::open()) {
 | 
				
			||||||
			return false;
 | 
								return false;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -2536,13 +2536,14 @@ void History::clear(bool leaveItems) {
 | 
				
			||||||
			if (App::wnd() && !App::quiting()) App::wnd()->mediaOverviewUpdated(peer, MediaOverviewType(i));
 | 
								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) {
 | 
							if (leaveItems) {
 | 
				
			||||||
			(*i)->clear(true);
 | 
								(*i)->clear(true);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		delete *i;
 | 
							delete *i;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	blocks.clear();
 | 
					 | 
				
			||||||
	if (leaveItems) {
 | 
						if (leaveItems) {
 | 
				
			||||||
		lastKeyboardInited = false;
 | 
							lastKeyboardInited = false;
 | 
				
			||||||
	} else {
 | 
						} else {
 | 
				
			||||||
| 
						 | 
					@ -2698,16 +2699,17 @@ int32 HistoryBlock::geomResize(int32 newWidth, int32 *ytransform, const HistoryI
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void HistoryBlock::clear(bool leaveItems) {
 | 
					void HistoryBlock::clear(bool leaveItems) {
 | 
				
			||||||
 | 
						Items lst = items;
 | 
				
			||||||
 | 
						items.clear();
 | 
				
			||||||
	if (leaveItems) {
 | 
						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();
 | 
								(*i)->detachFast();
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	} else {
 | 
						} 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;
 | 
								delete *i;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	items.clear();
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void HistoryBlock::removeItem(HistoryItem *item) {
 | 
					void HistoryBlock::removeItem(HistoryItem *item) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -546,21 +546,21 @@ void MTPabstractTcpConnection::socketRead() {
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	do {
 | 
						do {
 | 
				
			||||||
		char *readTo = currentPos;
 | 
					 | 
				
			||||||
		uint32 toRead = packetLeft ? packetLeft : (readingToShort ? (MTPShortBufferSize * sizeof(mtpPrime)-packetRead) : 4);
 | 
							uint32 toRead = packetLeft ? packetLeft : (readingToShort ? (MTPShortBufferSize * sizeof(mtpPrime)-packetRead) : 4);
 | 
				
			||||||
		if (readingToShort) {
 | 
							if (readingToShort) {
 | 
				
			||||||
			if (currentPos + toRead > ((char*)shortBuffer) + MTPShortBufferSize * sizeof(mtpPrime)) {
 | 
								if (currentPos + toRead > ((char*)shortBuffer) + MTPShortBufferSize * sizeof(mtpPrime)) {
 | 
				
			||||||
				longBuffer.resize(((packetRead + toRead) >> 2) + 1);
 | 
									longBuffer.resize(((packetRead + toRead) >> 2) + 1);
 | 
				
			||||||
				memcpy(&longBuffer[0], shortBuffer, packetRead);
 | 
									memcpy(&longBuffer[0], shortBuffer, packetRead);
 | 
				
			||||||
				readTo = ((char*)&longBuffer[0]) + packetRead;
 | 
									currentPos = ((char*)&longBuffer[0]) + packetRead;
 | 
				
			||||||
 | 
									readingToShort = false;
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		} else {
 | 
							} else {
 | 
				
			||||||
			if (longBuffer.size() * sizeof(mtpPrime) < packetRead + toRead) {
 | 
								if (longBuffer.size() * sizeof(mtpPrime) < packetRead + toRead) {
 | 
				
			||||||
				longBuffer.resize(((packetRead + toRead) >> 2) + 1);
 | 
									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) {
 | 
							if (bytes > 0) {
 | 
				
			||||||
			TCP_LOG(("TCP Info: read %1 bytes").arg(bytes));
 | 
								TCP_LOG(("TCP Info: read %1 bytes").arg(bytes));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -573,6 +573,7 @@ void MTPabstractTcpConnection::socketRead() {
 | 
				
			||||||
					currentPos = (char*)shortBuffer;
 | 
										currentPos = (char*)shortBuffer;
 | 
				
			||||||
					packetRead = packetLeft = 0;
 | 
										packetRead = packetLeft = 0;
 | 
				
			||||||
					readingToShort = true;
 | 
										readingToShort = true;
 | 
				
			||||||
 | 
										longBuffer.clear();
 | 
				
			||||||
				} else {
 | 
									} else {
 | 
				
			||||||
					TCP_LOG(("TCP Info: not enough %1 for packet! read %2").arg(packetLeft).arg(packetRead));
 | 
										TCP_LOG(("TCP Info: not enough %1 for packet! read %2").arg(packetLeft).arg(packetRead));
 | 
				
			||||||
					emit receivedSome();
 | 
										emit receivedSome();
 | 
				
			||||||
| 
						 | 
					@ -602,10 +603,12 @@ void MTPabstractTcpConnection::socketRead() {
 | 
				
			||||||
					if (!packetRead) {
 | 
										if (!packetRead) {
 | 
				
			||||||
						currentPos = (char*)shortBuffer;
 | 
											currentPos = (char*)shortBuffer;
 | 
				
			||||||
						readingToShort = true;
 | 
											readingToShort = true;
 | 
				
			||||||
 | 
											longBuffer.clear();
 | 
				
			||||||
					} else if (!readingToShort && packetRead < MTPShortBufferSize * sizeof(mtpPrime)) {
 | 
										} else if (!readingToShort && packetRead < MTPShortBufferSize * sizeof(mtpPrime)) {
 | 
				
			||||||
						memcpy(shortBuffer, currentPos - packetRead, packetRead);
 | 
											memcpy(shortBuffer, currentPos - packetRead, packetRead);
 | 
				
			||||||
						currentPos = (char*)shortBuffer;
 | 
											currentPos = (char*)shortBuffer;
 | 
				
			||||||
						readingToShort = true;
 | 
											readingToShort = true;
 | 
				
			||||||
 | 
											longBuffer.clear();
 | 
				
			||||||
					}
 | 
										}
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue