refactor: use more if and switch init-statements

This commit is contained in:
sithlord48 2025-07-03 19:58:34 -04:00 committed by Nick Bolton
parent 36e985d8ab
commit c6778dc9be
3 changed files with 8 additions and 10 deletions

View file

@ -124,22 +124,24 @@ bool ScreenSetupModel::dropMimeData(
stream >> sourceColumn;
stream >> sourceRow;
const auto pColumn = parent.column();
const auto pRow = parent.row();
// don't drop screen onto itself
if (sourceColumn == parent.column() && sourceRow == parent.row())
if (sourceColumn == pColumn && sourceRow == pRow)
return false;
Screen droppedScreen;
stream >> droppedScreen;
auto oldScreen = Screen(screen(parent.column(), parent.row()));
if (!oldScreen.isNull() && sourceColumn != -1 && sourceRow != -1) {
if (auto oldScreen = Screen(screen(pColumn, pRow)); !oldScreen.isNull() && sourceColumn != -1 && sourceRow != -1) {
// mark the screen so it isn't deleted after the dragndrop succeeded
// see ScreenSetupView::startDrag()
oldScreen.setSwapped(true);
screen(sourceColumn, sourceRow) = oldScreen;
}
screen(parent.column(), parent.row()) = droppedScreen;
screen(pColumn, pRow) = droppedScreen;
Q_EMIT screensChanged();

View file

@ -32,8 +32,7 @@ bool TlsCertificate::generateCertificate(const QString &path, int keyLength) con
qDebug("generating tls certificate: %s", qUtf8Printable(path));
QFileInfo info(path);
QDir dir(info.absolutePath());
if (!dir.exists() && !dir.mkpath(".")) {
if (QDir dir(info.absolutePath()); !dir.exists() && !dir.mkpath(".")) {
qCritical("failed to create directory for tls certificate");
return false;
}

View file

@ -546,10 +546,7 @@ void SecureSocket::checkResult(int status, int &retry)
{
// ssl errors are a little quirky. the "want" errors are normal and
// should result in a retry.
int errorCode = SSL_get_error(m_ssl->m_ssl, status);
switch (errorCode) {
switch (auto errorCode = SSL_get_error(m_ssl->m_ssl, status); errorCode) {
case SSL_ERROR_NONE:
retry = 0;
// operation completed