From e0b4d1edce7c31ca0acb396b42baf44673060612 Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Tue, 19 Sep 2023 17:10:53 +0400 Subject: [PATCH] Avoid unneeded std::string casts in exception handling --- .../platform/linux/file_utilities_linux.cpp | 9 +++------ .../platform/linux/integration_linux.cpp | 2 +- .../platform/linux/notifications_manager_linux.cpp | 3 +-- .../SourceFiles/platform/linux/specific_linux.cpp | 13 +++++-------- 4 files changed, 10 insertions(+), 17 deletions(-) diff --git a/Telegram/SourceFiles/platform/linux/file_utilities_linux.cpp b/Telegram/SourceFiles/platform/linux/file_utilities_linux.cpp index 33b0ad780..e3e582459 100644 --- a/Telegram/SourceFiles/platform/linux/file_utilities_linux.cpp +++ b/Telegram/SourceFiles/platform/linux/file_utilities_linux.cpp @@ -26,8 +26,7 @@ void UnsafeOpenUrl(const QString &url) { base::Platform::AppLaunchContext()); if (!result) { - LOG(("App Error: %1").arg( - QString::fromStdString(result.error().what()))); + LOG(("App Error: %1").arg(result.error().what())); } else if (*result) { return; } @@ -52,8 +51,7 @@ void UnsafeLaunch(const QString &filepath) { if ([&] { const auto filename = GLib::filename_to_uri(filepath.toStdString()); if (!filename) { - LOG(("App Error: %1").arg( - QString::fromStdString(filename.error().what()))); + LOG(("App Error: %1").arg(filename.error().what())); return false; } @@ -63,8 +61,7 @@ void UnsafeLaunch(const QString &filepath) { base::Platform::AppLaunchContext()); if (!result) { - LOG(("App Error: %1").arg( - QString::fromStdString(result.error().what()))); + LOG(("App Error: %1").arg(result.error().what())); return false; } diff --git a/Telegram/SourceFiles/platform/linux/integration_linux.cpp b/Telegram/SourceFiles/platform/linux/integration_linux.cpp index 18f228a3c..dbfec779d 100644 --- a/Telegram/SourceFiles/platform/linux/integration_linux.cpp +++ b/Telegram/SourceFiles/platform/linux/integration_linux.cpp @@ -174,7 +174,7 @@ gi::ref_ptr MakeApplication() { const auto result = gi::make_ref(); if (const auto registered = result->register_(); !registered) { LOG(("App Error: Failed to register: %1").arg( - QString::fromStdString(registered.error().message_()))); + registered.error().message_().c_str())); return nullptr; } return result; diff --git a/Telegram/SourceFiles/platform/linux/notifications_manager_linux.cpp b/Telegram/SourceFiles/platform/linux/notifications_manager_linux.cpp index f173cac01..097f93abd 100644 --- a/Telegram/SourceFiles/platform/linux/notifications_manager_linux.cpp +++ b/Telegram/SourceFiles/platform/linux/notifications_manager_linux.cpp @@ -58,8 +58,7 @@ void Noexcept(Fn callback, Fn failed = nullptr) noexcept { callback(); return; } catch (const std::exception &e) { - LOG(("Native Notification Error: %1").arg( - QString::fromStdString(e.what()))); + LOG(("Native Notification Error: %1").arg(e.what())); } if (failed) { diff --git a/Telegram/SourceFiles/platform/linux/specific_linux.cpp b/Telegram/SourceFiles/platform/linux/specific_linux.cpp index b8ed9893f..41828edbc 100644 --- a/Telegram/SourceFiles/platform/linux/specific_linux.cpp +++ b/Telegram/SourceFiles/platform/linux/specific_linux.cpp @@ -68,8 +68,7 @@ void PortalAutostart(bool enabled, Fn done) { Gio::DBus::BusType::SESSION); } catch (const std::exception &e) { if (done) { - LOG(("Portal Autostart Error: %1").arg( - QString::fromStdString(e.what()))); + LOG(("Portal Autostart Error: %1").arg(e.what())); } return Glib::RefPtr(); } @@ -144,8 +143,7 @@ void PortalAutostart(bool enabled, Fn done) { } } catch (const std::exception &e) { if (done) { - LOG(("Portal Autostart Error: %1").arg( - QString::fromStdString(e.what()))); + LOG(("Portal Autostart Error: %1").arg(e.what())); done(false); } } @@ -174,8 +172,7 @@ void PortalAutostart(bool enabled, Fn done) { connection->call_finish(result); } catch (const std::exception &e) { if (done) { - LOG(("Portal Autostart Error: %1").arg( - QString::fromStdString(e.what()))); + LOG(("Portal Autostart Error: %1").arg(e.what())); done(false); } @@ -286,7 +283,7 @@ bool GenerateDesktopFile( target->save_to_file(targetFile.toStdString()); } catch (const std::exception &e) { if (!silent) { - LOG(("App Error: %1").arg(QString::fromStdString(e.what()))); + LOG(("App Error: %1").arg(e.what())); } return false; } @@ -378,7 +375,7 @@ bool GenerateServiceFile(bool silent = false) { target->save_to_file(targetFile.toStdString()); } catch (const std::exception &e) { if (!silent) { - LOG(("App Error: %1").arg(QString::fromStdString(e.what()))); + LOG(("App Error: %1").arg(e.what())); } return false; }