Skip to content

Commit

Permalink
Don't restore terminal settings on close
Browse files Browse the repository at this point in the history
The API for controlling the terminal settings restoration was
deprecated in 5.3, and removed in 6. However, the underlying
code that restores the settings was not removed as planned. This
commit removes the code that was connected to the deprecated API
function.
  • Loading branch information
cibomahto committed Oct 7, 2024
1 parent 2a89cf9 commit d82373c
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 20 deletions.
3 changes: 0 additions & 3 deletions src/serialport/qserialport_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,7 @@ class QSerialPortPrivate : public QIODevicePrivate

void emitReadyRead();

DCB restoredDcb;
COMMTIMEOUTS currentCommTimeouts;
COMMTIMEOUTS restoredCommTimeouts;
HANDLE handle = INVALID_HANDLE_VALUE;
QByteArray readChunkBuffer;
QByteArray writeChunkBuffer;
Expand Down Expand Up @@ -233,7 +231,6 @@ class QSerialPortPrivate : public QIODevicePrivate
bool startAsyncWrite();
bool completeAsyncWrite();

struct termios restoredTermios;
int descriptor = -1;

QSocketNotifier *readNotifier = nullptr;
Expand Down
5 changes: 0 additions & 5 deletions src/serialport/qserialport_unix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -321,9 +321,6 @@ bool QSerialPortPrivate::open(QIODevice::OpenMode mode)

void QSerialPortPrivate::close()
{
if (settingsRestoredOnClose)
::tcsetattr(descriptor, TCSANOW, &restoredTermios);

#ifdef TIOCNXCL
::ioctl(descriptor, TIOCNXCL);
#endif
Expand Down Expand Up @@ -835,8 +832,6 @@ inline bool QSerialPortPrivate::initialize(QIODevice::OpenMode mode)
if (!getTermios(&tio))
return false;

restoredTermios = tio;

qt_set_common_props(&tio, mode);
qt_set_databits(&tio, dataBits);
qt_set_parity(&tio, parity);
Expand Down
12 changes: 0 additions & 12 deletions src/serialport/qserialport_win.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,11 +177,6 @@ void QSerialPortPrivate::close()
writeStarted = false;
writeBuffer.clear();

if (settingsRestoredOnClose) {
::SetCommState(handle, &restoredDcb);
::SetCommTimeouts(handle, &restoredCommTimeouts);
}

::CloseHandle(handle);
handle = INVALID_HANDLE_VALUE;
}
Expand Down Expand Up @@ -631,8 +626,6 @@ inline bool QSerialPortPrivate::initialize(QIODevice::OpenMode mode)
if (!getDcb(&dcb))
return false;

restoredDcb = dcb;

qt_set_common_props(&dcb);
qt_set_baudrate(&dcb, inputBaudRate);
qt_set_databits(&dcb, dataBits);
Expand All @@ -643,11 +636,6 @@ inline bool QSerialPortPrivate::initialize(QIODevice::OpenMode mode)
if (!setDcb(&dcb))
return false;

if (!::GetCommTimeouts(handle, &restoredCommTimeouts)) {
setError(getSystemError());
return false;
}

::ZeroMemory(&currentCommTimeouts, sizeof(currentCommTimeouts));
currentCommTimeouts.ReadIntervalTimeout = MAXDWORD;

Expand Down

0 comments on commit d82373c

Please sign in to comment.