diff options
author | Laszlo Papp <lpapp@kde.org> | 2013-07-27 14:01:00 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-07-28 12:47:56 +0200 |
commit | 0da1b020e3a1826d81334ee1ccda840b00c7a03f (patch) | |
tree | 700940ff9b152c499a242189a2ac03397639aea2 /src/serialport/qserialport_wince.cpp | |
parent | e18de858e60d4a77146dd5f697d6573a00c88d8f (diff) |
Eliminate the "q_ptr->" call by using Q_Q(QSerialPort)
Unfortunately, the q_ptr data member cannot yet be deleted from the internal
data class because QIODevicePrivate would need to be inherited then. That is not
a simple change considering the Qt4 support. Hence, that part of the logic is
put on hold, but can be expected in an upcoming change at some point, soon.
Change-Id: Ic8ba9621dd647f4afa1b91d01c858c836d1cc0c8
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
Diffstat (limited to 'src/serialport/qserialport_wince.cpp')
-rw-r--r-- | src/serialport/qserialport_wince.cpp | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/src/serialport/qserialport_wince.cpp b/src/serialport/qserialport_wince.cpp index 78d2746b..2123d17c 100644 --- a/src/serialport/qserialport_wince.cpp +++ b/src/serialport/qserialport_wince.cpp @@ -164,6 +164,8 @@ QSerialPortPrivate::QSerialPortPrivate(QSerialPort *q) bool QSerialPortPrivate::open(QIODevice::OpenMode mode) { + Q_Q(QSerialPort); + DWORD desiredAccess = 0; DWORD eventMask = EV_ERR; @@ -180,12 +182,12 @@ bool QSerialPortPrivate::open(QIODevice::OpenMode mode) desiredAccess, 0, NULL, OPEN_EXISTING, 0, NULL); if (descriptor == INVALID_HANDLE_VALUE) { - q_ptr->setError(decodeSystemError()); + q->setError(decodeSystemError()); return false; } if (!::GetCommState(descriptor, &restoredDcb)) { - q_ptr->setError(decodeSystemError()); + q->setError(decodeSystemError()); return false; } @@ -201,7 +203,7 @@ bool QSerialPortPrivate::open(QIODevice::OpenMode mode) return false; if (!::GetCommTimeouts(descriptor, &restoredCommTimeouts)) { - q_ptr->setError(decodeSystemError()); + q->setError(decodeSystemError()); return false; } @@ -211,7 +213,7 @@ bool QSerialPortPrivate::open(QIODevice::OpenMode mode) if (!updateCommTimeouts()) return false; - eventNotifier = new CommEventNotifier(eventMask, this, q_ptr); + eventNotifier = new CommEventNotifier(eventMask, this, q); eventNotifier->start(); detectDefaultSettings(); @@ -354,6 +356,8 @@ bool QSerialPortPrivate::waitForBytesWritten(int msec) bool QSerialPortPrivate::notifyRead() { + Q_Q(QSerialPort); + DWORD bytesToRead = (policy == QSerialPort::IgnorePolicy) ? ReadChunkSize : 1; if (readBufferMaxSize && bytesToRead > (readBufferMaxSize - readBuffer.size())) { @@ -372,7 +376,7 @@ bool QSerialPortPrivate::notifyRead() if (!sucessResult) { readBuffer.truncate(bytesToRead); - q_ptr->setError(QSerialPort::ReadError); + q->setError(QSerialPort::ReadError); return false; } @@ -400,27 +404,29 @@ bool QSerialPortPrivate::notifyRead() } if (readBytes > 0) - emit q_ptr->readyRead(); + emit q->readyRead(); return true; } bool QSerialPortPrivate::notifyWrite(int maxSize) { + Q_Q(QSerialPort); + int nextSize = qMin(writeBuffer.nextDataBlockSize(), maxSize); const char *ptr = writeBuffer.readPointer(); DWORD bytesWritten = 0; if (!::WriteFile(descriptor, ptr, nextSize, &bytesWritten, NULL)) { - q_ptr->setError(QSerialPort::WriteError); + q->setError(QSerialPort::WriteError); return false; } writeBuffer.free(bytesWritten); if (bytesWritten > 0) - emit q_ptr->bytesWritten(bytesWritten); + emit q->bytesWritten(bytesWritten); return true; } @@ -458,6 +464,8 @@ bool QSerialPortPrivate::waitForReadOrWrite(bool *selectForRead, bool *selectFor bool QSerialPortPrivate::updateDcb() { + Q_Q(QSerialPort); + QMutexLocker locker(&settingsChangeMutex); DWORD eventMask = 0; @@ -470,7 +478,7 @@ bool QSerialPortPrivate::updateDcb() // Change parameters bool ret = ::SetCommState(descriptor, ¤tDcb); if (!ret) - q_ptr->setError(decodeSystemError()); + q->setError(decodeSystemError()); // Restore the event mask ::SetCommMask(descriptor, eventMask); @@ -479,8 +487,10 @@ bool QSerialPortPrivate::updateDcb() bool QSerialPortPrivate::updateCommTimeouts() { + Q_Q(QSerialPort); + if (!::SetCommTimeouts(descriptor, ¤tCommTimeouts)) { - q_ptr->setError(decodeSystemError()); + q->setError(decodeSystemError()); return false; } return true; |