mirror of
https://github.com/tnodir/fort
synced 2024-11-14 22:25:40 +00:00
UI: LogManager::addFreeBuffer: Delete excessive buffers
This commit is contained in:
parent
71de47e9ab
commit
1de2b90ae5
@ -95,15 +95,22 @@ void LogManager::cancelAsyncIo()
|
||||
|
||||
LogBuffer *LogManager::getFreeBuffer()
|
||||
{
|
||||
if (m_freeBuffers.isEmpty())
|
||||
return new LogBuffer(DriverCommon::bufferSize(), this);
|
||||
if (!m_freeBuffers.isEmpty()) {
|
||||
return m_freeBuffers.takeLast();
|
||||
}
|
||||
|
||||
return m_freeBuffers.takeLast();
|
||||
return new LogBuffer(DriverCommon::bufferSize(), this);
|
||||
}
|
||||
|
||||
void LogManager::addFreeBuffer(LogBuffer *logBuffer)
|
||||
{
|
||||
m_freeBuffers.append(logBuffer);
|
||||
constexpr int maxBufferCount = 8;
|
||||
if (m_freeBuffers.size() < maxBufferCount) {
|
||||
m_freeBuffers.append(logBuffer);
|
||||
return;
|
||||
}
|
||||
|
||||
delete logBuffer;
|
||||
}
|
||||
|
||||
void LogManager::processLogBuffer(LogBuffer *logBuffer, bool success, quint32 errorCode)
|
||||
|
Loading…
Reference in New Issue
Block a user