diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp index cad697ff0f..ac106ed288 100644 --- a/src/slic3r/GUI/GUI_App.cpp +++ b/src/slic3r/GUI/GUI_App.cpp @@ -1256,6 +1256,10 @@ bool GUI_App::on_init_inner() // Set initialization of image handlers before any UI actions - See GH issue #7469 wxInitAllImageHandlers(); + // Set our own gui log as an active target + m_log_gui = new LogGui(); + wxLog::SetActiveTarget(m_log_gui); + #if defined(_WIN32) && ! defined(_WIN64) // Win32 32bit build. if (wxPlatformInfo::Get().GetArchName().substr(0, 2) == "64") { @@ -4146,5 +4150,31 @@ void GUI_App::show_printer_webview_tab() mainframe->show_printer_webview_tab(preset_bundle->physical_printers.get_selected_printer_config()); } + + +bool LogGui::ignorred_message(const wxString& msg) +{ + for(const wxString& err : std::initializer_list{ wxString("cHRM chunk does not match sRGB"), + wxString("known incorrect sRGB profile") }) { + if (msg.Contains(err)) + return true; + } + return false; +} + +void LogGui::DoLogText(const wxString& msg) +{ + if (ignorred_message(msg)) + return; + wxLogGui::DoLogText(msg); +} + +void LogGui::DoLogRecord(wxLogLevel level, const wxString& msg, const wxLogRecordInfo& info) +{ + if (ignorred_message(msg)) + return; + wxLogGui::DoLogRecord(level, msg, info); +} + } // GUI } //Slic3r diff --git a/src/slic3r/GUI/GUI_App.hpp b/src/slic3r/GUI/GUI_App.hpp index e915576943..56fc09c8ff 100644 --- a/src/slic3r/GUI/GUI_App.hpp +++ b/src/slic3r/GUI/GUI_App.hpp @@ -119,6 +119,20 @@ static wxString dots("…", wxConvUTF8); #define SUPPORTS_MARKUP #endif + +// A wrapper class to allow ignoring some known warnings +// and not bothering users with redundant messages. +// see https://github.com/prusa3d/PrusaSlicer/issues/12920 +class LogGui : public wxLogGui +{ +protected: + void DoLogText(const wxString& msg) override; + void DoLogRecord(wxLogLevel level, const wxString& msg, const wxLogRecordInfo& info) override; + +private: + bool ignorred_message(const wxString& msg); +}; + class GUI_App : public wxApp { public: @@ -181,6 +195,7 @@ private: size_t m_instance_hash_int; Search::OptionsSearcher* m_searcher{ nullptr }; + LogGui* m_log_gui { nullptr }; public: bool OnInit() override;