mirror of
https://github.com/tnodir/fort
synced 2024-11-15 07:15:39 +00:00
UI: LogManager: Fix buffers handling.
This commit is contained in:
parent
7b03e56576
commit
19344e8d8c
@ -22,15 +22,20 @@ void DriverWorker::run()
|
||||
} while (!m_aborted);
|
||||
}
|
||||
|
||||
void DriverWorker::readLogAsync(LogBuffer *logBuffer)
|
||||
bool DriverWorker::readLogAsync(LogBuffer *logBuffer)
|
||||
{
|
||||
QMutexLocker locker(&m_mutex);
|
||||
|
||||
if (m_logBuffer)
|
||||
return false;
|
||||
|
||||
m_cancelled = false;
|
||||
|
||||
m_logBuffer = logBuffer;
|
||||
|
||||
m_waitCondition.wakeOne();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void DriverWorker::cancelAsyncIo()
|
||||
|
@ -23,7 +23,7 @@ signals:
|
||||
const QString &errorMessage);
|
||||
|
||||
public slots:
|
||||
void readLogAsync(LogBuffer *logBuffer);
|
||||
bool readLogAsync(LogBuffer *logBuffer);
|
||||
void cancelAsyncIo();
|
||||
void abort();
|
||||
|
||||
|
@ -27,10 +27,9 @@ void LogManager::setActive(bool active)
|
||||
m_active = active;
|
||||
|
||||
if (m_active) {
|
||||
readLogAsync(getFreeBuffer());
|
||||
readLogAsync();
|
||||
} else {
|
||||
cancelAsyncIo();
|
||||
readLogAsync(nullptr);
|
||||
}
|
||||
|
||||
emit activeChanged();
|
||||
@ -56,9 +55,13 @@ void LogManager::setupDriverWorker()
|
||||
this, &LogManager::processLogBuffer, Qt::QueuedConnection);
|
||||
}
|
||||
|
||||
void LogManager::readLogAsync(LogBuffer *logBuffer)
|
||||
void LogManager::readLogAsync()
|
||||
{
|
||||
m_driverWorker->readLogAsync(logBuffer);
|
||||
LogBuffer *logBuffer = getFreeBuffer();
|
||||
|
||||
if (!m_driverWorker->readLogAsync(logBuffer)) {
|
||||
addFreeBuffer(logBuffer);
|
||||
}
|
||||
}
|
||||
|
||||
void LogManager::cancelAsyncIo()
|
||||
@ -84,7 +87,7 @@ void LogManager::processLogBuffer(LogBuffer *logBuffer, bool success,
|
||||
const QString &errorMessage)
|
||||
{
|
||||
if (m_active) {
|
||||
readLogAsync(getFreeBuffer());
|
||||
readLogAsync();
|
||||
}
|
||||
|
||||
if (success) {
|
||||
@ -124,6 +127,7 @@ void LogManager::readLogEntries(LogBuffer *logBuffer)
|
||||
break;
|
||||
}
|
||||
default:
|
||||
Q_ASSERT(logBuffer->offset() != 0);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ private:
|
||||
|
||||
void setupDriverWorker();
|
||||
|
||||
void readLogAsync(LogBuffer *logBuffer);
|
||||
void readLogAsync();
|
||||
void cancelAsyncIo();
|
||||
|
||||
LogBuffer *getFreeBuffer();
|
||||
|
Loading…
Reference in New Issue
Block a user