summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDenis Shienkov <denis.shienkov@gmail.com>2013-12-19 18:28:50 +0400
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-12-30 13:08:01 +0100
commit25a17db97a8549e5415d23ba1064e4259930ce7f (patch)
tree8a787e09893899d1d3ef49127872f0c513f21fad
parent4e15aa6d7c4f9a03f4ae57b3ba04ade3400cccf1 (diff)
Remove unused variables
* actualWriteBufferSize variable - it is a wrong old heritage related with the implementation of a code with the analogy from the the QWindowsPipeReader (where actualReadBufferSize is present). * acyncWritePosition variable - it is a old heritage when the write notifier could operate with a multiple writing operations at the same time. For this purpose it is necessary to know the following write position in the ring buffer. But currently all write operations happen sequentially, i.e. forbidden to carry out startAsyncWrite() several times without completeAsyncWrite() completion. Change-Id: I25b665b638649e6002fb194babfaa73f5ec8a6fa Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com> Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
-rw-r--r--src/serialport/qserialport_win.cpp20
-rw-r--r--src/serialport/qserialport_win_p.h2
2 files changed, 4 insertions, 18 deletions
diff --git a/src/serialport/qserialport_win.cpp b/src/serialport/qserialport_win.cpp
index 506dc94a..f5bf0802 100644
--- a/src/serialport/qserialport_win.cpp
+++ b/src/serialport/qserialport_win.cpp
@@ -101,8 +101,6 @@ QSerialPortPrivate::QSerialPortPrivate(QSerialPort *q)
, descriptor(INVALID_HANDLE_VALUE)
, parityErrorOccurred(false)
, readChunkBuffer(ReadChunkSize, 0)
- , actualWriteBufferSize(0)
- , acyncWritePosition(0)
, readyReadEmitted(0)
, writeSequenceStarted(false)
, communicationNotifier(new QWinEventNotifier(q))
@@ -229,8 +227,6 @@ void QSerialPortPrivate::close()
writeSequenceStarted = false;
writeBuffer.clear();
- actualWriteBufferSize = 0;
- acyncWritePosition = 0;
readyReadEmitted = false;
parityErrorOccurred = false;
@@ -311,8 +307,6 @@ bool QSerialPortPrivate::clear(QSerialPort::Directions directions)
flags |= PURGE_RXABORT | PURGE_RXCLEAR;
if (directions & QSerialPort::Output) {
flags |= PURGE_TXABORT | PURGE_TXCLEAR;
- actualWriteBufferSize = 0;
- acyncWritePosition = 0;
writeSequenceStarted = false;
}
return ::PurgeComm(descriptor, flags);
@@ -369,13 +363,10 @@ qint64 QSerialPortPrivate::systemOutputQueueSize ()
qint64 QSerialPortPrivate::writeToBuffer(const char *data, qint64 maxSize)
{
char *ptr = writeBuffer.reserve(maxSize);
- if (maxSize == 1) {
+ if (maxSize == 1)
*ptr = *data;
- actualWriteBufferSize++;
- } else {
+ else
::memcpy(ptr, data, maxSize);
- actualWriteBufferSize += maxSize;
- }
if (!writeSequenceStarted)
startAsyncWrite(WriteChunkSize);
@@ -657,11 +648,10 @@ bool QSerialPortPrivate::startAsyncWrite(int maxSize)
{
Q_Q(QSerialPort);
- qint64 nextSize = 0;
- const char *ptr = writeBuffer.readPointerAtPosition(acyncWritePosition, nextSize);
+ qint64 nextSize = writeBuffer.nextDataBlockSize();
+ const char *ptr = writeBuffer.readPointer();
nextSize = qMin(nextSize, qint64(maxSize));
- acyncWritePosition += nextSize;
// no more data to write
if (!ptr || nextSize == 0)
@@ -763,8 +753,6 @@ void QSerialPortPrivate::completeAsyncWrite(DWORD numberOfBytes)
Q_Q(QSerialPort);
writeBuffer.free(numberOfBytes);
- actualWriteBufferSize -= qint64(numberOfBytes);
- acyncWritePosition -= qint64(numberOfBytes);
if (numberOfBytes > 0)
emit q->bytesWritten(numberOfBytes);
diff --git a/src/serialport/qserialport_win_p.h b/src/serialport/qserialport_win_p.h
index 059be878..5ae33ae6 100644
--- a/src/serialport/qserialport_win_p.h
+++ b/src/serialport/qserialport_win_p.h
@@ -126,8 +126,6 @@ public:
#ifndef Q_OS_WINCE
QByteArray readChunkBuffer;
- qint64 actualWriteBufferSize;
- qint64 acyncWritePosition;
bool readyReadEmitted;
bool writeSequenceStarted;
QWinEventNotifier *communicationNotifier;