refactor: use more if and switch init-statements
This commit is contained in:
parent
36e985d8ab
commit
c6778dc9be
3 changed files with 8 additions and 10 deletions
|
|
@ -124,22 +124,24 @@ bool ScreenSetupModel::dropMimeData(
|
||||||
stream >> sourceColumn;
|
stream >> sourceColumn;
|
||||||
stream >> sourceRow;
|
stream >> sourceRow;
|
||||||
|
|
||||||
|
const auto pColumn = parent.column();
|
||||||
|
const auto pRow = parent.row();
|
||||||
|
|
||||||
// don't drop screen onto itself
|
// don't drop screen onto itself
|
||||||
if (sourceColumn == parent.column() && sourceRow == parent.row())
|
if (sourceColumn == pColumn && sourceRow == pRow)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
Screen droppedScreen;
|
Screen droppedScreen;
|
||||||
stream >> droppedScreen;
|
stream >> droppedScreen;
|
||||||
|
|
||||||
auto oldScreen = Screen(screen(parent.column(), parent.row()));
|
if (auto oldScreen = Screen(screen(pColumn, pRow)); !oldScreen.isNull() && sourceColumn != -1 && sourceRow != -1) {
|
||||||
if (!oldScreen.isNull() && sourceColumn != -1 && sourceRow != -1) {
|
|
||||||
// mark the screen so it isn't deleted after the dragndrop succeeded
|
// mark the screen so it isn't deleted after the dragndrop succeeded
|
||||||
// see ScreenSetupView::startDrag()
|
// see ScreenSetupView::startDrag()
|
||||||
oldScreen.setSwapped(true);
|
oldScreen.setSwapped(true);
|
||||||
screen(sourceColumn, sourceRow) = oldScreen;
|
screen(sourceColumn, sourceRow) = oldScreen;
|
||||||
}
|
}
|
||||||
|
|
||||||
screen(parent.column(), parent.row()) = droppedScreen;
|
screen(pColumn, pRow) = droppedScreen;
|
||||||
|
|
||||||
Q_EMIT screensChanged();
|
Q_EMIT screensChanged();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -32,8 +32,7 @@ bool TlsCertificate::generateCertificate(const QString &path, int keyLength) con
|
||||||
qDebug("generating tls certificate: %s", qUtf8Printable(path));
|
qDebug("generating tls certificate: %s", qUtf8Printable(path));
|
||||||
|
|
||||||
QFileInfo info(path);
|
QFileInfo info(path);
|
||||||
QDir dir(info.absolutePath());
|
if (QDir dir(info.absolutePath()); !dir.exists() && !dir.mkpath(".")) {
|
||||||
if (!dir.exists() && !dir.mkpath(".")) {
|
|
||||||
qCritical("failed to create directory for tls certificate");
|
qCritical("failed to create directory for tls certificate");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -546,10 +546,7 @@ void SecureSocket::checkResult(int status, int &retry)
|
||||||
{
|
{
|
||||||
// ssl errors are a little quirky. the "want" errors are normal and
|
// ssl errors are a little quirky. the "want" errors are normal and
|
||||||
// should result in a retry.
|
// should result in a retry.
|
||||||
|
switch (auto errorCode = SSL_get_error(m_ssl->m_ssl, status); errorCode) {
|
||||||
int errorCode = SSL_get_error(m_ssl->m_ssl, status);
|
|
||||||
|
|
||||||
switch (errorCode) {
|
|
||||||
case SSL_ERROR_NONE:
|
case SSL_ERROR_NONE:
|
||||||
retry = 0;
|
retry = 0;
|
||||||
// operation completed
|
// operation completed
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue