Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix some errors uncovered via compiler warnings #7954

Merged
merged 8 commits into from
Jan 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/libslic3r/Support/TreeSupport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2380,7 +2380,7 @@ void TreeSupport::draw_circles(const std::vector<std::vector<Node*>>& contact_no
ExPolygons& base_areas = ts_layer->base_areas;

int layer_nr_lower = layer_nr - 1;
for (layer_nr_lower; layer_nr_lower >= 0; layer_nr_lower--) {
for (; layer_nr_lower >= 0; layer_nr_lower--) {
if (!m_object->get_support_layer(layer_nr_lower + m_raft_layers)->area_groups.empty()) break;
}
if (layer_nr_lower <= 0) continue;
Expand Down Expand Up @@ -2470,7 +2470,7 @@ void TreeSupport::draw_circles(const std::vector<std::vector<Node*>>& contact_no
if (ts_layer->area_groups.empty()) continue;

int layer_nr_lower = layer_nr - 1;
for (layer_nr_lower; layer_nr_lower >= 0; layer_nr_lower--) {
for (; layer_nr_lower >= 0; layer_nr_lower--) {
if (!m_object->get_support_layer(layer_nr_lower + m_raft_layers)->area_groups.empty()) break;
}
if (layer_nr_lower < 0) continue;
Expand Down
4 changes: 2 additions & 2 deletions src/libslic3r/calib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -453,8 +453,8 @@ std::string CalibPressureAdvanceLine::generate_test(double start_pa /*= 0*/, dou
}

auto bed_sizes = mp_gcodegen->config().printable_area.values;
const auto &w = bed_ext.size().x();
const auto &h = bed_ext.size().y();
const auto w = bed_ext.size().x();
const auto h = bed_ext.size().y();
count = std::min(count, int((h - 10) / m_space_y));

m_length_long = 40 + std::min(w - 120.0, 0.0);
Expand Down
4 changes: 2 additions & 2 deletions src/slic3r/GUI/DeviceManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3873,10 +3873,10 @@ int MachineObject::parse_json(std::string payload, bool key_field_only)
}
}
if (ams_exist_bits != last_ams_exist_bits
|| last_tray_exist_bits != last_tray_exist_bits
|| tray_exist_bits != last_tray_exist_bits
|| tray_is_bbl_bits != last_is_bbl_bits
|| tray_read_done_bits != last_read_done_bits
|| last_ams_version != ams_version) {
|| ams_version != last_ams_version) {
is_ams_need_update = true;
}
else {
Expand Down
4 changes: 2 additions & 2 deletions src/slic3r/GUI/Gizmos/GLGizmosManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -915,7 +915,7 @@ bool GLGizmosManager::on_key(wxKeyEvent& evt)
}
else if (m_current == FdmSupports) {
GLGizmoFdmSupports* fdm_support = dynamic_cast<GLGizmoFdmSupports*>(get_current());
if (fdm_support != nullptr && keyCode == 'F' || keyCode == 'S' || keyCode == 'C' || keyCode == 'G') {
if (fdm_support != nullptr && (keyCode == 'F' || keyCode == 'S' || keyCode == 'C' || keyCode == 'G')) {
processed = fdm_support->on_key_down_select_tool_type(keyCode);
}
if (processed) {
Expand All @@ -925,7 +925,7 @@ bool GLGizmosManager::on_key(wxKeyEvent& evt)
}
else if (m_current == Seam) {
GLGizmoSeam* seam = dynamic_cast<GLGizmoSeam*>(get_current());
if (seam != nullptr && keyCode == 'S' || keyCode == 'C') {
if (seam != nullptr && (keyCode == 'S' || keyCode == 'C')) {
processed = seam->on_key_down_select_tool_type(keyCode);
}
if (processed) {
Expand Down
10 changes: 4 additions & 6 deletions src/slic3r/GUI/Jobs/PrintJob.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,10 @@ void PrintJob::prepare()
{
if (job_data.is_from_plater)
m_plater->get_print_job_data(&job_data);
if (&job_data) {
std::string temp_file = Slic3r::resources_dir() + "/check_access_code.txt";
auto check_access_code_path = temp_file.c_str();
BOOST_LOG_TRIVIAL(trace) << "sned_job: check_access_code_path = " << check_access_code_path;
job_data._temp_path = fs::path(check_access_code_path);
}
std::string temp_file = Slic3r::resources_dir() + "/check_access_code.txt";
auto check_access_code_path = temp_file.c_str();
BOOST_LOG_TRIVIAL(trace) << "sned_job: check_access_code_path = " << check_access_code_path;
job_data._temp_path = fs::path(check_access_code_path);
}

void PrintJob::on_success(std::function<void()> success)
Expand Down
10 changes: 4 additions & 6 deletions src/slic3r/GUI/Jobs/SendJob.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,10 @@ SendJob::SendJob(std::string dev_id)
void SendJob::prepare()
{
m_plater->get_print_job_data(&job_data);
if (&job_data) {
std::string temp_file = Slic3r::resources_dir() + "/check_access_code.txt";
auto check_access_code_path = temp_file.c_str();
BOOST_LOG_TRIVIAL(trace) << "sned_job: check_access_code_path = " << check_access_code_path;
job_data._temp_path = fs::path(check_access_code_path);
}
std::string temp_file = Slic3r::resources_dir() + "/check_access_code.txt";
auto check_access_code_path = temp_file.c_str();
BOOST_LOG_TRIVIAL(trace) << "sned_job: check_access_code_path = " << check_access_code_path;
job_data._temp_path = fs::path(check_access_code_path);
}

wxString SendJob::get_http_error_msg(unsigned int status, std::string body)
Expand Down
1 change: 0 additions & 1 deletion src/slic3r/GUI/MainFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -916,7 +916,6 @@ void MainFrame::update_title_colour_after_set_title()

void MainFrame::show_option(bool show)
{
if (!this) { return; }
if (!show) {
if (m_slice_btn->IsShown()) {
m_slice_btn->Hide();
Expand Down
2 changes: 1 addition & 1 deletion src/slic3r/GUI/MediaPlayCtrl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ void MediaPlayCtrl::Stop(wxString const &msg)
}

auto tunnel = m_url.empty() ? "" : into_u8(wxURI(m_url).GetPath()).substr(1);
if (auto n = tunnel.find_first_of('/_'); n != std::string::npos)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't even know c++ allows this!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I was also surprised this is allowed

if (auto n = tunnel.find_first_of("/_"); n != std::string::npos)
tunnel = tunnel.substr(0, n);
if (last_state != wxMEDIASTATE_PLAYING && m_failed_code != 0
&& m_last_failed_codes.find(m_failed_code) == m_last_failed_codes.end()
Expand Down
2 changes: 1 addition & 1 deletion src/slic3r/GUI/ReleaseNote.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -786,7 +786,7 @@ void SecondaryCheckDialog::on_hide()

void SecondaryCheckDialog::update_title_style(wxString title, SecondaryCheckDialog::ButtonStyle style, wxWindow* parent)
{
if (m_button_style == style && title == GetTitle() == title) return;
if (m_button_style == style && title == GetTitle()) return;

SetTitle(title);

Expand Down
10 changes: 4 additions & 6 deletions src/slic3r/GUI/SendMultiMachinePage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -473,12 +473,10 @@ BBL::PrintParams SendMultiMachinePage::request_params(MachineObject* obj)
PrintPrepareData job_data;
m_plater->get_print_job_data(&job_data);

if (&job_data) {
std::string temp_file = Slic3r::resources_dir() + "/check_access_code.txt";
auto check_access_code_path = temp_file.c_str();
BOOST_LOG_TRIVIAL(trace) << "sned_job: check_access_code_path = " << check_access_code_path;
job_data._temp_path = fs::path(check_access_code_path);
}
std::string temp_file = Slic3r::resources_dir() + "/check_access_code.txt";
auto check_access_code_path = temp_file.c_str();
BOOST_LOG_TRIVIAL(trace) << "sned_job: check_access_code_path = " << check_access_code_path;
job_data._temp_path = fs::path(check_access_code_path);

int curr_plate_idx;
if (job_data.plate_idx >= 0)
Expand Down
2 changes: 1 addition & 1 deletion src/slic3r/GUI/Tab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -881,7 +881,7 @@ void TabPrinter::init_options_list()

for (const std::string& opt_key : m_config->keys())
{
if (opt_key == "printable_area" || opt_key == "bed_exclude_area" | opt_key == "thumbnails") {
if (opt_key == "printable_area" || opt_key == "bed_exclude_area" || opt_key == "thumbnails") {
m_options_list.emplace(opt_key, m_opt_status_value);
continue;
}
Expand Down
6 changes: 3 additions & 3 deletions src/slic3r/Utils/UndoRedo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1071,7 +1071,7 @@ bool StackImpl::has_redo_snapshot() const

// BBS: undo-redo until modify record
auto it = std::lower_bound(m_snapshots.begin(), m_snapshots.end(), Snapshot(m_active_snapshot_time));
for (it; it != m_snapshots.end(); ++it) {
for (; it != m_snapshots.end(); ++it) {
if (snapshot_modifies_project(*it))
return true;
}
Expand Down Expand Up @@ -1340,12 +1340,12 @@ bool StackImpl::has_real_change_from(size_t time) const
Snapshot(m_active_snapshot_time));
if (it_active == m_snapshots.end()) return true;
if (it_active > it_time) {
for (it_time; it_time < it_active; ++it_time) {
for (; it_time < it_active; ++it_time) {
if (snapshot_modifies_project(*it_time))
return true;
}
} else {
for (it_active; it_active < it_time; ++it_active) {
for (; it_active < it_time; ++it_active) {
if (snapshot_modifies_project(*it_active))
return true;
}
Expand Down
Loading