From 9ba63d1460db41c219b638212b42476164fcfdff Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Tue, 24 Jul 2018 13:08:25 +0200 Subject: Update code style, fix compiler warnings - Use nullptr instead of NULL for better warnings in case of mistakes - Get rid of VLAs which are not in C++11 actually - Fix implicit signed <-> unsigned mismatches by adding checks and casts --- src/client/vnc/vncwindow.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'src/client/vnc/vncwindow.cpp') diff --git a/src/client/vnc/vncwindow.cpp b/src/client/vnc/vncwindow.cpp index 79352ae..a9d85f4 100644 --- a/src/client/vnc/vncwindow.cpp +++ b/src/client/vnc/vncwindow.cpp @@ -37,7 +37,7 @@ static int gcd(int a, int b) VncWindow::VncWindow(QWidget *parent) : QWidget(parent), _srcStepX(1), _srcStepY(1), _dstStepX(1), _dstStepY(1), - _vncWorker(NULL), _viewOnly(true), _multiScreen(false), _clientId(0), _redrawTimer(0), _tcpTimeoutTimer(0) + _vncWorker(nullptr), _viewOnly(true), _multiScreen(false), _clientId(0), _redrawTimer(0), _tcpTimeoutTimer(0) { QTimer *upper = new QTimer(this); connect(upper, SIGNAL(timeout()), this, SLOT(timer_moveToTop())); @@ -55,13 +55,13 @@ VncWindow::~VncWindow() /** * Terminates the vnc worker thread and stops all related timers. * The thread will be signalled to stop, but we don't wait for it - * to actually terminate. All signals of the thread are blocked, and we NULL + * to actually terminate. All signals of the thread are blocked, and we nullptr * our reference to it. It will finish running in a detached state and finally * delete itself upon completion. */ void VncWindow::terminateVncThread() { - if (_vncWorker == NULL) + if (_vncWorker == nullptr) return; disconnect(_vncWorker, SIGNAL(projectionStopped()), this, SLOT(onProjectionStopped())); @@ -69,7 +69,7 @@ void VncWindow::terminateVncThread() disconnect(_vncWorker, SIGNAL(imageUpdated(const int, const int, const int, const int)), this, SLOT(onUpdateImage(const int, const int, const int, const int))); _vncWorker->stop(); - _vncWorker = NULL; + _vncWorker = nullptr; if (_redrawTimer != 0) { killTimer(_redrawTimer); _redrawTimer = 0; @@ -96,7 +96,7 @@ void VncWindow::deleteVncThread() */ void VncWindow::draw(const int x, const int y, const int w, const int h) { - if (_vncWorker == NULL) + if (_vncWorker == nullptr) return; QSharedPointer buffer = _vncWorker->getFrameBuffer(); if (buffer.isNull()) @@ -147,10 +147,10 @@ void VncWindow::draw(const int x, const int y, const int w, const int h) bool VncWindow::calcScaling(const QImage *remote) { if (this->size() == _desiredSize && - (remote == NULL || remote->size() == _remoteSize)) + (remote == nullptr || remote->size() == _remoteSize)) return false; const QSize mySize = this->size(); - const QSize remoteSize = remote == NULL ? _remoteSize : remote->size(); + const QSize remoteSize = remote == nullptr ? _remoteSize : remote->size(); if (mySize.isEmpty()) return false; if (remoteSize.isEmpty()) @@ -270,7 +270,7 @@ void VncWindow::closeEvent(QCloseEvent * /* e */ ) */ void VncWindow::onUpdateImage(const int x, const int y, const int w, const int h) { - if (_vncWorker == NULL) + if (_vncWorker == nullptr) return; if (!this->calcScaling(_vncWorker->getFrameBuffer().data()) && !_remoteSize.isEmpty()) { if (_srcStepX > 1 || _srcStepY > 1) { @@ -345,7 +345,7 @@ void VncWindow::timerEvent(QTimerEvent *event) } else if (event->timerId() == _tcpTimeoutTimer) { killTimer(_tcpTimeoutTimer); _tcpTimeoutTimer = 0; - if (_vncWorker != NULL && !_vncWorker->isConnected()) { + if (_vncWorker != nullptr && !_vncWorker->isConnected()) { this->close(); } } else @@ -362,7 +362,7 @@ void VncWindow::timerEvent(QTimerEvent *event) */ void VncWindow::paintEvent(QPaintEvent *event) { - if (_vncWorker == NULL || !_vncWorker->isConnected()) { + if (_vncWorker == nullptr || !_vncWorker->isConnected()) { QPainter painter(this); if (!_remoteThumb.isNull() && _remoteThumb.height() > 0) { painter.drawPixmap(0, 0, this->width(), this->height(), _remoteThumb); -- cgit v1.2.3-55-g7522