Skip to content

Commit

Permalink
Fix coverity warnings
Browse files Browse the repository at this point in the history
IB-7929

Signed-off-by: Raul Metsma <raul@metsma.ee>
  • Loading branch information
metsma committed Feb 12, 2025
1 parent 004b233 commit 14aff28
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
7 changes: 3 additions & 4 deletions client/Utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ namespace {
std::exception_ptr exception;
std::invoke_result_t<F,Args...> result{};
QEventLoop l;
// c++20 ... args == std::forward<Args>(args)
std::thread([&, function = std::forward<F>(function)]{
std::thread([&, function = std::forward<F>(function), ...args = std::forward<Args>(args)]{
try {
result = std::invoke(function, args...);
} catch(...) {
Expand All @@ -51,14 +50,14 @@ namespace {
QEventLoop l;
using result_t = typename std::invoke_result_t<F,Args...>;
if constexpr (std::is_void_v<result_t>) {
QMetaObject::invokeMethod(qApp, [&, function = std::forward<F>(function)] {
QMetaObject::invokeMethod(qApp, [&, function = std::forward<F>(function), ...args = std::forward<Args>(args)] {
std::invoke(function, args...);
l.exit();
}, Qt::QueuedConnection);
l.exec();
} else {
result_t result{};
QMetaObject::invokeMethod(qApp, [&, function = std::forward<F>(function)] {
QMetaObject::invokeMethod(qApp, [&, function = std::forward<F>(function), ...args = std::forward<Args>(args)] {
result = std::invoke(function, args...);
l.exit();
}, Qt::QueuedConnection);
Expand Down
14 changes: 7 additions & 7 deletions client/effects/FadeInNotification.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,17 @@ constexpr QRect adjustHeight(QRect rect, int height) noexcept
FadeInNotification::FadeInNotification(QWidget *parent, QRect rect, Type type, const QString &label)
: QLabel(parent)
{
auto bgcolor = [type] {
auto bgcolor = [type]() -> QString {
switch(type) {
case FadeInNotification::Success: return QStringLiteral("#218123");
case FadeInNotification::Warning: return QStringLiteral("#FBAE38");
case FadeInNotification::Error: return QStringLiteral("#AD2A45");
case FadeInNotification::Default: return QStringLiteral("#2F70B6");
case Success: return QStringLiteral("#218123");
case Warning: return QStringLiteral("#FBAE38");
case Error: return QStringLiteral("#AD2A45");
case Default: return QStringLiteral("#2F70B6");
default: return QStringLiteral("none");
}
}();
auto fgcolor = [type] {
return type == FadeInNotification::Warning ? QStringLiteral("#07142A") : QStringLiteral("#FFFFFF");
auto fgcolor = [type]() -> QString {
return type == Warning ? QStringLiteral("#07142A") : QStringLiteral("#FFFFFF");
}();
setStyleSheet(QStringLiteral("color: %1; background-color: %2;").arg(fgcolor, bgcolor));
setFocusPolicy(Qt::TabFocus);
Expand Down
2 changes: 1 addition & 1 deletion client/effects/FadeInNotification.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class FadeInNotification final: public QLabel

public:
using ms = std::chrono::milliseconds;
enum Type {
enum Type : quint8 {
Success,
Warning,
Error,
Expand Down

0 comments on commit 14aff28

Please sign in to comment.