Fix of asserts

This commit is contained in:
David Kocik 2024-11-22 13:01:32 +01:00
parent fc27654827
commit c70cb1ac15
8 changed files with 21 additions and 21 deletions

View File

@ -3924,7 +3924,7 @@ const Preset* find_preset_by_nozzle_and_options(
case coStrings: opt_val = static_cast<const ConfigOptionStrings*>(preset.config.option(opt.first))->values[0]; break;
case coBools: opt_val = static_cast<const ConfigOptionBools*>(preset.config.option(opt.first))->values[0] ? "1" : "0"; break;
default:
assert(true);
assert(false);
continue;
}
}

View File

@ -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<bool>("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<bool>("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<LocalArchiveRepository>(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<bool>("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<bool>("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<OnlineArchiveRepository>(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;
}

View File

@ -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()) {

View File

@ -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)

View File

@ -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;
};

View File

@ -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)

View File

@ -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);

View File

@ -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};
}
}