From c70cb1ac15d532096a5f4ae9a2afe30abd24b7e8 Mon Sep 17 00:00:00 2001 From: David Kocik Date: Fri, 22 Nov 2024 13:01:32 +0100 Subject: [PATCH] Fix of asserts --- src/slic3r/GUI/GUI_App.cpp | 2 +- src/slic3r/GUI/PresetArchiveDatabase.cpp | 20 ++++++++++---------- src/slic3r/GUI/UserAccount.cpp | 2 +- src/slic3r/GUI/WebViewDialog.cpp | 8 ++++---- src/slic3r/GUI/WebViewDialog.hpp | 2 +- src/slic3r/GUI/WebViewPanel.cpp | 2 +- src/slic3r/GUI/WebViewPanel.hpp | 2 +- src/slic3r/Utils/PresetUpdaterWrapper.cpp | 4 ++-- 8 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp index a5d3c120ee..65e36517ee 100644 --- a/src/slic3r/GUI/GUI_App.cpp +++ b/src/slic3r/GUI/GUI_App.cpp @@ -3924,7 +3924,7 @@ const Preset* find_preset_by_nozzle_and_options( case coStrings: opt_val = static_cast(preset.config.option(opt.first))->values[0]; break; case coBools: opt_val = static_cast(preset.config.option(opt.first))->values[0] ? "1" : "0"; break; default: - assert(true); + assert(false); continue; } } diff --git a/src/slic3r/GUI/PresetArchiveDatabase.cpp b/src/slic3r/GUI/PresetArchiveDatabase.cpp index b76d6bc802..2a62a79cfe 100644 --- a/src/slic3r/GUI/PresetArchiveDatabase.cpp +++ b/src/slic3r/GUI/PresetArchiveDatabase.cpp @@ -418,14 +418,14 @@ void PresetArchiveDatabase::set_installed_printer_repositories(const std::vector if (selected_uuid.empty() && unselected_uuid.empty()) { // there is id in used_ids that is not in m_archive_repositories - BAD - assert(true); + assert(false); continue; } else if (selected_uuid.size() == 1){ // regular case m_has_installed_printer_repositories_uuid[selected_uuid.front()] = true; } else if (selected_uuid.size() > 1) { // this should not happen, only one repo of same id should be selected (online / local conflict) - assert(true); + assert(false); // select first one to solve the conflict m_has_installed_printer_repositories_uuid[selected_uuid.front()] = true; // unselect the rest @@ -517,7 +517,7 @@ void PresetArchiveDatabase::load_app_manifest_json() file.close(); } else { - assert(true); + assert(false); BOOST_LOG_TRIVIAL(error) << "Failed to read Archive Source Manifest at " << path; } if (data.empty()) { @@ -544,14 +544,14 @@ void PresetArchiveDatabase::load_app_manifest_json() if(const auto used = subtree.second.get_optional("selected"); used) { m_selected_repositories_uuid[uuid] = extracted && *used; } else { - assert(true); + assert(false); m_selected_repositories_uuid[uuid] = extracted; } // "has_installed_printers" flag if (const auto used = subtree.second.get_optional("has_installed_printers"); used) { m_has_installed_printer_repositories_uuid[uuid] = extracted && *used; } else { - assert(true); + assert(false); m_has_installed_printer_repositories_uuid[uuid] = false; } m_archive_repositories.emplace_back(std::make_unique(std::move(uuid), std::move(manifest), extracted)); @@ -562,7 +562,7 @@ void PresetArchiveDatabase::load_app_manifest_json() ArchiveRepository::RepositoryManifest manifest; std::string uuid = get_next_uuid(); if (!extract_repository_header(subtree.second, manifest)) { - assert(true); + assert(false); BOOST_LOG_TRIVIAL(error) << "Failed to read one of source headers."; continue; } @@ -570,14 +570,14 @@ void PresetArchiveDatabase::load_app_manifest_json() if (const auto used = subtree.second.get_optional("selected"); used) { m_selected_repositories_uuid[uuid] = *used; } else { - assert(true); + assert(false); m_selected_repositories_uuid[uuid] = true; } // "has_installed_printers" flag if (const auto used = subtree.second.get_optional("has_installed_printers"); used) { m_has_installed_printer_repositories_uuid[uuid] = *used; } else { - assert(true); + assert(false); m_has_installed_printer_repositories_uuid[uuid] = false; } m_archive_repositories.emplace_back(std::make_unique(std::move(uuid), std::move(manifest))); @@ -679,7 +679,7 @@ void PresetArchiveDatabase::save_app_manifest_json() const file << data; file.close(); } else { - assert(true); + assert(false); BOOST_LOG_TRIVIAL(error) << "Failed to write Archive Repository Manifest to " << path; } } @@ -757,7 +757,7 @@ void PresetArchiveDatabase::read_server_manifest(const std::string& json_body) for (const auto& subtree : ptree) { ArchiveRepository::RepositoryManifest manifest; if (!extract_repository_header(subtree.second, manifest)) { - assert(true); + assert(false); BOOST_LOG_TRIVIAL(error) << "Failed to read one of repository headers."; continue; } diff --git a/src/slic3r/GUI/UserAccount.cpp b/src/slic3r/GUI/UserAccount.cpp index 2ac4a47980..7fe0e9c03a 100644 --- a/src/slic3r/GUI/UserAccount.cpp +++ b/src/slic3r/GUI/UserAccount.cpp @@ -203,7 +203,7 @@ bool UserAccount::on_connect_printers_success(const std::string& data, AppConfig if (auto pair = printer_state_table.find(*printer_state); pair != printer_state_table.end()) { state = pair->second; } else { - assert(true); // On this assert, printer_state_table needs to be updated with *state_opt and correct ConnectPrinterState + assert(false); // On this assert, printer_state_table needs to be updated with *state_opt and correct ConnectPrinterState continue; } if (m_printer_uuid_map.find(*printer_uuid) == m_printer_uuid_map.end()) { diff --git a/src/slic3r/GUI/WebViewDialog.cpp b/src/slic3r/GUI/WebViewDialog.cpp index 1b7740f630..c244fe79d6 100644 --- a/src/slic3r/GUI/WebViewDialog.cpp +++ b/src/slic3r/GUI/WebViewDialog.cpp @@ -487,7 +487,7 @@ void PrinterPickWebViewDialog::on_script_message(wxWebViewEvent& evt) void PrinterPickWebViewDialog::on_connect_action_select_printer(const std::string& message_data) { // SELECT_PRINTER request is not defined for PrinterPickWebViewDialog - assert(true); + assert(false); } void PrinterPickWebViewDialog::on_connect_action_print(const std::string& message_data) { @@ -673,17 +673,17 @@ void PrintablesConnectUploadDialog::on_script_message(wxWebViewEvent& evt) void PrintablesConnectUploadDialog::on_connect_action_select_printer(const std::string& message_data) { // SELECT_PRINTER request is not defined for PrintablesConnectUploadDialog - assert(true); + assert(false); } void PrintablesConnectUploadDialog::on_connect_action_print(const std::string& message_data) { - assert(true); + assert(false); } void PrintablesConnectUploadDialog::on_connect_action_webapp_ready(const std::string& message_data) { // WEBAPP_READY request is not defined for PrintablesConnectUploadDialog - assert(true); + assert(false); } void PrintablesConnectUploadDialog::on_reload_event(const std::string& message_data) diff --git a/src/slic3r/GUI/WebViewDialog.hpp b/src/slic3r/GUI/WebViewDialog.hpp index 318fd9cefa..e7d4c529d8 100644 --- a/src/slic3r/GUI/WebViewDialog.hpp +++ b/src/slic3r/GUI/WebViewDialog.hpp @@ -105,7 +105,7 @@ protected: void run_script_bridge(const wxString& script) override { run_script(script); } void on_dpi_changed(const wxRect &suggested_rect) override; void on_reload_event(const std::string& message_data) override; - void on_connect_action_close_dialog(const std::string& message_data) override {assert(true);} + void on_connect_action_close_dialog(const std::string& message_data) override {assert(false);} private: std::string& m_ret_val; }; diff --git a/src/slic3r/GUI/WebViewPanel.cpp b/src/slic3r/GUI/WebViewPanel.cpp index bb254645ce..7666e799b7 100644 --- a/src/slic3r/GUI/WebViewPanel.cpp +++ b/src/slic3r/GUI/WebViewPanel.cpp @@ -866,7 +866,7 @@ void ConnectWebViewPanel::on_connect_action_select_printer(const std::string& me void ConnectWebViewPanel::on_connect_action_print(const std::string& message_data) { // PRINT request is not defined for ConnectWebViewPanel - assert(true); + assert(false); } PrinterWebViewPanel::PrinterWebViewPanel(wxWindow* parent, const wxString& default_url) diff --git a/src/slic3r/GUI/WebViewPanel.hpp b/src/slic3r/GUI/WebViewPanel.hpp index 1611ad545c..7997bbc40f 100644 --- a/src/slic3r/GUI/WebViewPanel.hpp +++ b/src/slic3r/GUI/WebViewPanel.hpp @@ -141,7 +141,7 @@ protected: void on_page_will_load() override; void on_connect_action_error(const std::string &message_data) override; void on_reload_event(const std::string& message_data) override; - void on_connect_action_close_dialog(const std::string& message_data) override {assert(true);} + void on_connect_action_close_dialog(const std::string& message_data) override {assert(false);} void on_user_token(UserAccountSuccessEvent& e); private: static wxString get_login_script(bool refresh); diff --git a/src/slic3r/Utils/PresetUpdaterWrapper.cpp b/src/slic3r/Utils/PresetUpdaterWrapper.cpp index ca7072d41e..481a81fe13 100644 --- a/src/slic3r/Utils/PresetUpdaterWrapper.cpp +++ b/src/slic3r/Utils/PresetUpdaterWrapper.cpp @@ -206,7 +206,7 @@ void PresetUpdaterWrapper::cancel_worker_thread() if (m_worker_thread.joinable()) { if (m_ui_status) { m_ui_status->set_canceled(true); - } else assert(true); + } else assert(false); m_worker_thread.join(); @@ -226,7 +226,7 @@ PresetUpdaterUIStatus::PresetUpdaterUIStatus(PresetUpdaterUIStatus::PresetUpdate if (auto it = policy_map.find(policy); it != policy_map.end()) { m_retry_policy = it->second; } else { - assert(true); + assert(false); m_retry_policy = {0ms}; } }