diff --git a/src/log.h b/src/log.h index a0b21f69..9d2a4b70 100644 --- a/src/log.h +++ b/src/log.h @@ -1,6 +1,8 @@ #pragma once #include +#include +#include #include #include #include @@ -108,6 +110,18 @@ struct QDLLEXPORT converter static std::string convert(const QVariant& v); }; +template <> +struct QDLLEXPORT converter +{ + static int convert(const QFlag& v) { return v; } +}; + +template +struct QDLLEXPORT converter> +{ + static auto convert(const QFlags& v) { return v.toInt(); } +}; + // custom converter for enum and enum class that seems to not work with latest fmt template struct QDLLEXPORT converter>> @@ -133,9 +147,18 @@ void doLog(spdlog::logger& logger, Levels lv, if constexpr (sizeof...(Args) == 0) { s = fmt::format("{}", std::forward(format)); } else { + // fmt::make_format_args takes lvalue-reference, so we cannot pass the converted + // arguments directly, instead, converted values are stored in a tuple<> and + // std::apply is used to call make_format_args + // + const auto converted_args = std::make_tuple( + converter>::convert(std::forward(args))...); s = fmt::vformat(std::forward(format), - fmt::make_format_args(converter>::convert( - std::forward(args))...)); + std::apply( + [](auto&... values) { + return fmt::make_format_args(values...); + }, + converted_args)); } // check the blacklist diff --git a/src/report.cpp b/src/report.cpp index 205eab44..83d2f2ef 100644 --- a/src/report.cpp +++ b/src/report.cpp @@ -383,8 +383,9 @@ QPixmap TaskDialog::standardIcon(QMessageBox::Icon icon) const break; case QMessageBox::Question: i = s->standardIcon(QStyle::SP_MessageBoxQuestion, 0, m_dialog.get()); - - case QMessageBox::NoIcon: // fall-through + break; + case QMessageBox::NoIcon: + [[fallthrough]]; default: break; } diff --git a/src/utility.cpp b/src/utility.cpp index 7f94001f..ba5cefb6 100644 --- a/src/utility.cpp +++ b/src/utility.cpp @@ -715,15 +715,7 @@ bool copyFileRecursive(const QString& source, const QString& baseDir, std::wstring ToWString(const QString& source) { - // FIXME - // why not source.toStdWString() ? - wchar_t* buffer = new wchar_t[static_cast(source.count()) + 1]; - source.toWCharArray(buffer); - buffer[source.count()] = L'\0'; - std::wstring result(buffer); - delete[] buffer; - - return result; + return source.toStdWString(); } std::string ToString(const QString& source, bool utf8)