From 51dfccf1157c566b1cbb8891ecedefaa1e79269d Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Fri, 29 Jan 2021 07:39:27 +0100 Subject: Fixing GCC warnings 3 --- src/slic3r/GUI/BonjourDialog.cpp | 24 ++++++++++++++++-------- src/slic3r/GUI/BonjourDialog.hpp | 1 + src/slic3r/GUI/DoubleSlider.cpp | 22 +++++++++++----------- src/slic3r/GUI/GCodeViewer.cpp | 21 +++++++++++---------- src/slic3r/GUI/GCodeViewer.hpp | 2 +- src/slic3r/GUI/GLCanvas3D.cpp | 2 +- src/slic3r/GUI/GUI_App.cpp | 2 +- src/slic3r/GUI/GUI_Preview.cpp | 14 +++++++------- src/slic3r/GUI/InstanceCheck.cpp | 4 ++-- src/slic3r/GUI/Plater.cpp | 12 +++++++----- src/slic3r/GUI/PresetComboBoxes.cpp | 2 +- src/slic3r/GUI/Search.cpp | 6 ------ src/slic3r/GUI/Selection.cpp | 2 +- src/slic3r/GUI/UnsavedChangesDialog.cpp | 2 +- src/slic3r/GUI/fts_fuzzy_match.h | 13 +++++++------ 15 files changed, 68 insertions(+), 61 deletions(-) diff --git a/src/slic3r/GUI/BonjourDialog.cpp b/src/slic3r/GUI/BonjourDialog.cpp index 8ee01c949..51f18dce7 100644 --- a/src/slic3r/GUI/BonjourDialog.cpp +++ b/src/slic3r/GUI/BonjourDialog.cpp @@ -108,8 +108,7 @@ bool BonjourDialog::show_and_lookup() timer->SetOwner(this); timer_state = 1; timer->Start(1000); - wxTimerEvent evt_dummy; - on_timer(evt_dummy); + on_timer_process(); // The background thread needs to queue messages for this dialog // and for that it needs a valid pointer to it (mandated by the wxWidgets API). @@ -214,18 +213,27 @@ void BonjourDialog::on_reply(BonjourReplyEvent &e) } void BonjourDialog::on_timer(wxTimerEvent &) +{ + on_timer_process(); +} + +// This is here so the function can be bound to wxEVT_TIMER and also called +// explicitly (wxTimerEvent should not be created by user code). +void BonjourDialog::on_timer_process() { const auto search_str = _utf8(L("Searching for devices")); - if (timer_state > 0) { - const std::string dots(timer_state, '.'); + if (timer_state > 0) { + const std::string dots(timer_state, '.'); label->SetLabel(GUI::from_u8((boost::format("%1% %2%") % search_str % dots).str())); - timer_state = (timer_state) % 3 + 1; - } else { + timer_state = (timer_state) % 3 + 1; + } else { label->SetLabel(GUI::from_u8((boost::format("%1%: %2%") % search_str % (_utf8(L("Finished"))+".")).str())); - timer->Stop(); - } + timer->Stop(); + } } + + } diff --git a/src/slic3r/GUI/BonjourDialog.hpp b/src/slic3r/GUI/BonjourDialog.hpp index a9a33d522..def0838d7 100644 --- a/src/slic3r/GUI/BonjourDialog.hpp +++ b/src/slic3r/GUI/BonjourDialog.hpp @@ -43,6 +43,7 @@ private: void on_reply(BonjourReplyEvent &); void on_timer(wxTimerEvent &); + void on_timer_process(); }; diff --git a/src/slic3r/GUI/DoubleSlider.cpp b/src/slic3r/GUI/DoubleSlider.cpp index 8a2257274..ee589c94a 100644 --- a/src/slic3r/GUI/DoubleSlider.cpp +++ b/src/slic3r/GUI/DoubleSlider.cpp @@ -297,7 +297,7 @@ double Control::get_double_value(const SelectedSlider& selection) { if (m_values.empty() || m_lower_value<0) return 0.0; - if (m_values.size() <= m_higher_value) { + if (m_values.size() <= size_t(m_higher_value)) { correct_higher_value(); return m_values.back(); } @@ -601,7 +601,7 @@ static std::string short_and_splitted_time(const std::string& time) ::sprintf(buffer, "%dh%dm%ds", hours, minutes, seconds); else if (hours > 10 && minutes > 10 && seconds > 10) ::sprintf(buffer, "%dh\n%dm\n%ds", hours, minutes, seconds); - else if (minutes < 10 && seconds > 10 || minutes > 10 && seconds < 10) + else if ((minutes < 10 && seconds > 10) || (minutes > 10 && seconds < 10)) ::sprintf(buffer, "%dh\n%dm%ds", hours, minutes, seconds); else ::sprintf(buffer, "%dh%dm\n%ds", hours, minutes, seconds); @@ -619,15 +619,15 @@ static std::string short_and_splitted_time(const std::string& time) wxString Control::get_label(int tick, LabelType label_type/* = ltHeightWithLayer*/) const { - const int value = tick; + const size_t value = tick; if (m_label_koef == 1.0 && m_values.empty()) - return wxString::Format("%d", value); + return wxString::Format("%lu", static_cast(value)); if (value >= m_values.size()) return "ErrVal"; if (m_draw_mode == dmSequentialGCodeView) - return wxString::Format("%d", static_cast(m_values[value])); + return wxString::Format("%lu", static_cast(m_values[value])); else { if (label_type == ltEstimatedTime) { return (value < m_layers_times.size()) ? short_and_splitted_time(get_time_dhms(m_layers_times[value])) : ""; @@ -742,7 +742,7 @@ void Control::draw_ticks_pair(wxDC& dc, wxCoord pos, wxCoord mid, int tick_len) dc.DrawLine(mid - (mid_space + tick_len), pos, mid - mid_space, pos); is_horizontal() ? dc.DrawLine(pos, mid + (mid_space + tick_len), pos, mid + mid_space) : dc.DrawLine(mid + (mid_space + tick_len), pos, mid + mid_space, pos); -}; +} void Control::draw_ticks(wxDC& dc) { @@ -753,8 +753,8 @@ void Control::draw_ticks(wxDC& dc) int height, width; get_size(&width, &height); const wxCoord mid = is_horizontal() ? 0.5*height : 0.5*width; - for (auto tick : m_ticks.ticks) { - if (tick.tick >= m_values.size()) { + for (const TickCode& tick : m_ticks.ticks) { + if (size_t(tick.tick) >= m_values.size()) { // The case when OnPaint is called before m_ticks.ticks data are updated (specific for the vase mode) break; } @@ -907,7 +907,6 @@ void Control::Ruler::update(wxWindow* win, const std::vector& values, do auto end_it = count == 1 ? values.end() : values.begin() + lround(values.size() / count); while (pow < 3) { - int tick = 0; for (int istep : {1, 2, 5}) { double val = (double)istep * std::pow(10,pow); auto val_it = std::lower_bound(values.begin(), end_it, val - epsilon()); @@ -950,7 +949,7 @@ void Control::draw_ruler(wxDC& dc) dc.SetTextForeground(GREY_PEN.GetColour()); if (m_ruler.long_step < 0) - for (int tick = 1; tick < m_values.size(); tick++) { + for (size_t tick = 1; tick < m_values.size(); tick++) { wxCoord pos = get_position_from_value(tick); draw_ticks_pair(dc, pos, mid, 5); draw_tick_text(dc, wxPoint(mid, pos), tick); @@ -966,7 +965,7 @@ void Control::draw_ruler(wxDC& dc) } }; - double short_tick; + double short_tick = std::nan(""); int tick = 0; double value = 0.0; int sequence = 0; @@ -983,6 +982,7 @@ void Control::draw_ruler(wxDC& dc) if (m_values[tick] < value) break; // short ticks from the last tick to the end of current sequence + assert(! std::isnan(short_tick)); draw_short_ticks(dc, short_tick, tick); sequence++; } diff --git a/src/slic3r/GUI/GCodeViewer.cpp b/src/slic3r/GUI/GCodeViewer.cpp index a9e9d6a03..8fac13733 100644 --- a/src/slic3r/GUI/GCodeViewer.cpp +++ b/src/slic3r/GUI/GCodeViewer.cpp @@ -1596,8 +1596,6 @@ void GCodeViewer::load_toolpaths(const GCodeProcessor::Result& gcode_result) Vec3f prev_up = prev_right.cross(prev_dir); Vec3f next_dir = (next - curr).normalized(); - Vec3f next_right = Vec3f(next_dir[1], -next_dir[0], 0.0f).normalized(); - Vec3f next_up = next_right.cross(next_dir); bool is_right_turn = prev_up.dot(prev_dir.cross(next_dir)) <= 0.0f; float cos_dir = prev_dir.dot(next_dir); @@ -2671,13 +2669,13 @@ void GCodeViewer::refresh_render_paths(bool keep_sequential_current_first, bool }; auto is_travel_in_layers_range = [this](size_t path_id, size_t min_id, size_t max_id) { - auto is_in_z_range = [](const Path& path, double min_z, double max_z) { - auto in_z_range = [min_z, max_z](double z) { - return min_z - EPSILON < z && z < max_z + EPSILON; - }; - - return in_z_range(path.sub_paths.front().first.position[2]) || in_z_range(path.sub_paths.back().last.position[2]); - }; + // auto is_in_z_range = [](const Path& path, double min_z, double max_z) { + // auto in_z_range = [min_z, max_z](double z) { + // return min_z - EPSILON < z && z < max_z + EPSILON; + // }; + // + // return in_z_range(path.sub_paths.front().first.position[2]) || in_z_range(path.sub_paths.back().last.position[2]); + // }; const TBuffer& buffer = m_buffers[buffer_id(EMoveType::Travel)]; if (path_id >= buffer.paths.size()) @@ -3396,7 +3394,7 @@ void GCodeViewer::render_toolpaths() const { case TBuffer::ERenderPrimitiveType::Point: { - EOptionsColors color; + EOptionsColors color = EOptionsColors(0); switch (buffer_type(i)) { case EMoveType::Tool_change: { color = EOptionsColors::ToolChanges; break; } @@ -3405,6 +3403,7 @@ void GCodeViewer::render_toolpaths() const case EMoveType::Custom_GCode: { color = EOptionsColors::CustomGCodes; break; } case EMoveType::Retract: { color = EOptionsColors::Retractions; break; } case EMoveType::Unretract: { color = EOptionsColors::Unretractions; break; } + default: { assert(false); break; } } render_as_points(buffer, static_cast(j), color, *shader); break; @@ -4101,6 +4100,7 @@ void GCodeViewer::render_legend() const imgui.text(_u8L("Estimated printing time") + " [" + _u8L("Stealth mode") + "]:"); break; } + default : { assert(false); break; } } ImGui::SameLine(); imgui.text(short_time(get_time_dhms(time_mode.time))); @@ -4132,6 +4132,7 @@ void GCodeViewer::render_legend() const show_mode_button(_L("Show normal mode"), PrintEstimatedTimeStatistics::ETimeMode::Normal); break; } + default : { assert(false); break; } } } diff --git a/src/slic3r/GUI/GCodeViewer.hpp b/src/slic3r/GUI/GCodeViewer.hpp index 836014ad3..a4663dc04 100644 --- a/src/slic3r/GUI/GCodeViewer.hpp +++ b/src/slic3r/GUI/GCodeViewer.hpp @@ -610,7 +610,7 @@ public: const BoundingBoxf3& get_paths_bounding_box() const { return m_paths_bounding_box; } const BoundingBoxf3& get_max_bounding_box() const { return m_max_bounding_box; } - const std::vector& get_layers_zs() const { return m_layers.get_zs(); }; + const std::vector& get_layers_zs() const { return m_layers.get_zs(); } const SequentialView& get_sequential_view() const { return m_sequential_view; } void update_sequential_view_current(unsigned int first, unsigned int last); diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index 388db4a27..c4e836daf 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -5822,7 +5822,7 @@ void GLCanvas3D::_load_print_object_toolpaths(const PrintObject& print_object, c int get_color_idx_for_tool_change(std::vector::const_iterator it, const int extruder) const { const int current_extruder = it->extruder == 0 ? extruder : it->extruder; - if (number_tools() == extruders_cnt + 1) // there is no one "M600" + if (number_tools() == size_t(extruders_cnt + 1)) // there is no one "M600" return std::min(extruders_cnt - 1, std::max(current_extruder - 1, 0)); auto it_n = it; diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp index 1be2495ca..18f193f3b 100644 --- a/src/slic3r/GUI/GUI_App.cpp +++ b/src/slic3r/GUI/GUI_App.cpp @@ -325,7 +325,7 @@ private: size_t cur_len = 0; wxString longest_sub_string; - auto get_longest_sub_string = [longest_sub_string, input](wxString &longest_sub_str, int cur_len, size_t i) { + auto get_longest_sub_string = [input](wxString &longest_sub_str, size_t cur_len, size_t i) { if (cur_len > longest_sub_str.Len()) longest_sub_str = input.SubString(i - cur_len + 1, i); }; diff --git a/src/slic3r/GUI/GUI_Preview.cpp b/src/slic3r/GUI/GUI_Preview.cpp index bca27fa21..e301a9c3e 100644 --- a/src/slic3r/GUI/GUI_Preview.cpp +++ b/src/slic3r/GUI/GUI_Preview.cpp @@ -493,13 +493,6 @@ void Preview::on_combochecklist_features(wxCommandEvent& evt) void Preview::on_combochecklist_options(wxCommandEvent& evt) { - auto xored = [](unsigned int flags1, unsigned int flags2, unsigned int flag) { - auto is_flag_set = [](unsigned int flags, unsigned int flag) { - return (flags & (1 << flag)) != 0; - }; - return !is_flag_set(flags1, flag) != !is_flag_set(flags2, flag); - }; - unsigned int curr_flags = m_canvas->get_gcode_options_visibility_flags(); unsigned int new_flags = Slic3r::GUI::combochecklist_get_flags(m_combochecklist_options); if (curr_flags == new_flags) @@ -510,6 +503,13 @@ void Preview::on_combochecklist_options(wxCommandEvent& evt) #if ENABLE_RENDER_PATH_REFRESH_AFTER_OPTIONS_CHANGE m_canvas->refresh_gcode_preview_render_paths(); #else + auto xored = [](unsigned int flags1, unsigned int flags2, unsigned int flag) { + auto is_flag_set = [](unsigned int flags, unsigned int flag) { + return (flags & (1 << flag)) != 0; + }; + return !is_flag_set(flags1, flag) != !is_flag_set(flags2, flag); + }; + bool skip_refresh = xored(curr_flags, new_flags, static_cast(OptionType::Shells)) || xored(curr_flags, new_flags, static_cast(OptionType::ToolMarker)); diff --git a/src/slic3r/GUI/InstanceCheck.cpp b/src/slic3r/GUI/InstanceCheck.cpp index 6cfa879c8..73bbeda35 100644 --- a/src/slic3r/GUI/InstanceCheck.cpp +++ b/src/slic3r/GUI/InstanceCheck.cpp @@ -41,7 +41,7 @@ namespace instance_check_internal //if (argc < 2) // return ret; std::vector arguments { argv[0] }; - for (size_t i = 1; i < argc; ++i) { + for (int i = 1; i < argc; ++i) { const std::string token = argv[i]; // Processing of boolean command line arguments shall match DynamicConfig::read_cli(). if (token == "--single-instance") @@ -180,7 +180,7 @@ namespace instance_check_internal if ( !checker->IsAnotherRunning() ) */ { DBusMessage* msg; - DBusMessageIter args; + // DBusMessageIter args; DBusConnection* conn; DBusError err; dbus_uint32_t serial = 0; diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 7824dcfdf..af36bf7d3 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -2523,7 +2523,7 @@ std::vector Plater::priv::load_model_objects(const ModelObjectPtrs &mode const Vec3d bed_size = Slic3r::to_3d(bed_shape.size().cast(), 1.0) - 2.0 * Vec3d::Ones(); #ifndef AUTOPLACEMENT_ON_LOAD - bool need_arrange = false; + // bool need_arrange = false; #endif /* AUTOPLACEMENT_ON_LOAD */ bool scaled_down = false; std::vector obj_idxs; @@ -2543,7 +2543,7 @@ std::vector Plater::priv::load_model_objects(const ModelObjectPtrs &mode new_instances.emplace_back(object->add_instance()); #else /* AUTOPLACEMENT_ON_LOAD */ // if object has no defined position(s) we need to rearrange everything after loading - need_arrange = true; + // need_arrange = true; // add a default instance and center object around origin object->center_around_origin(); // also aligns object to Z = 0 ModelInstance* instance = object->add_instance(); @@ -3686,9 +3686,8 @@ bool Plater::priv::warnings_dialog() if (current_warnings.empty()) return true; std::string text = _u8L("There are active warnings concerning sliced models:") + "\n"; - bool empt = true; for (auto const& it : current_warnings) { - int next_n = it.first.message.find_first_of('\n', 0); + size_t next_n = it.first.message.find_first_of('\n', 0); text += "\n"; if (next_n != std::string::npos) text += it.first.message.substr(0, next_n); @@ -5051,6 +5050,10 @@ bool Plater::load_files(const wxArrayString& filenames) load_files(in_paths, false, true); break; } + case LoadType::Unknown : { + assert(false); + break; + } } return true; @@ -5919,7 +5922,6 @@ void Plater::force_print_bed_update() void Plater::on_activate() { #if defined(__linux__) || defined(_WIN32) - wxWindow *focus_window = wxWindow::FindFocus(); // Activating the main frame, and no window has keyboard focus. // Set the keyboard focus to the visible Canvas3D. if (this->p->view3D->IsShown() && wxWindow::FindFocus() != this->p->view3D->get_wxglcanvas()) diff --git a/src/slic3r/GUI/PresetComboBoxes.cpp b/src/slic3r/GUI/PresetComboBoxes.cpp index 8dd35a591..880a4cb6a 100644 --- a/src/slic3r/GUI/PresetComboBoxes.cpp +++ b/src/slic3r/GUI/PresetComboBoxes.cpp @@ -759,7 +759,7 @@ void PlaterPresetComboBox::update() this->Clear(); invalidate_selection(); - const Preset* selected_filament_preset; + const Preset* selected_filament_preset = nullptr; std::string extruder_color; if (m_type == Preset::TYPE_FILAMENT) { diff --git a/src/slic3r/GUI/Search.cpp b/src/slic3r/GUI/Search.cpp index 738d5e435..2b7b3f3d9 100644 --- a/src/slic3r/GUI/Search.cpp +++ b/src/slic3r/GUI/Search.cpp @@ -117,12 +117,6 @@ void OptionsSearcher::append_options(DynamicPrintConfig* config, Preset::Type ty } } -// Wrap a string with ColorMarkerStart and ColorMarkerEnd symbols -static wxString wrap_string(const wxString& str) -{ - return wxString::Format("%c%s%c", ImGui::ColorMarkerStart, str, ImGui::ColorMarkerEnd); -} - // Mark a string using ColorMarkerStart and ColorMarkerEnd symbols static std::wstring mark_string(const std::wstring &str, const std::vector &matches, Preset::Type type, PrinterTechnology pt) { diff --git a/src/slic3r/GUI/Selection.cpp b/src/slic3r/GUI/Selection.cpp index cdd3ebe85..1cb599fc8 100644 --- a/src/slic3r/GUI/Selection.cpp +++ b/src/slic3r/GUI/Selection.cpp @@ -2092,7 +2092,7 @@ static bool is_rotation_xy_synchronized(const Vec3d &rot_xyz_from, const Vec3d & static void verify_instances_rotation_synchronized(const Model &model, const GLVolumePtrs &volumes) { - for (size_t idx_object = 0; idx_object < model.objects.size(); ++idx_object) { + for (int idx_object = 0; idx_object < int(model.objects.size()); ++idx_object) { int idx_volume_first = -1; for (int i = 0; i < (int)volumes.size(); ++i) { if (volumes[i]->object_idx() == idx_object) { diff --git a/src/slic3r/GUI/UnsavedChangesDialog.cpp b/src/slic3r/GUI/UnsavedChangesDialog.cpp index b4b38b4bd..cd5183cb3 100644 --- a/src/slic3r/GUI/UnsavedChangesDialog.cpp +++ b/src/slic3r/GUI/UnsavedChangesDialog.cpp @@ -989,7 +989,7 @@ wxString UnsavedChangesDialog::get_short_string(wxString full_string) { int max_len = 30; if (full_string.IsEmpty() || full_string.StartsWith("#") || - (full_string.Find("\n") == wxNOT_FOUND && full_string.Length() < max_len)) + (full_string.Find("\n") == wxNOT_FOUND && full_string.Length() < size_t(max_len))) return full_string; m_has_long_strings = true; diff --git a/src/slic3r/GUI/fts_fuzzy_match.h b/src/slic3r/GUI/fts_fuzzy_match.h index 4b474451c..379fd9c74 100644 --- a/src/slic3r/GUI/fts_fuzzy_match.h +++ b/src/slic3r/GUI/fts_fuzzy_match.h @@ -62,13 +62,13 @@ namespace fts { } // Public interface - static bool fuzzy_match(char_type const * pattern, char_type const * str, int & outScore) { + [[maybe_unused]] static bool fuzzy_match(char_type const * pattern, char_type const * str, int & outScore) { pos_type matches[max_matches + 1]; // with the room for the stopper matches[0] = stopper; return fuzzy_match(pattern, str, outScore, matches); } - static bool fuzzy_match(char_type const * pattern, char_type const * str, int & outScore, pos_type * matches) { + [[maybe_unused]] static bool fuzzy_match(char_type const * pattern, char_type const * str, int & outScore, pos_type * matches) { int recursionCount = 0; static constexpr int recursionLimit = 10; return fuzzy_internal::fuzzy_match_recursive(pattern, str, outScore, str, nullptr, matches, 0, recursionCount, recursionLimit); @@ -114,14 +114,15 @@ namespace fts { while (*pattern != '\0' && *str != '\0') { int num_matched = std::towlower(*pattern) == std::towlower(*str) ? 1 : 0; - bool folded_match = false; - if (! num_matched) { + // bool folded_match = false; + + if (! num_matched) { wchar_t tmp[4]; wchar_t *end = Slic3r::fold_to_ascii(*str, tmp); wchar_t *c = tmp; for (const wchar_t* d = pattern; c != end && *d != 0 && std::towlower(*c) == std::towlower(*d); ++c, ++d); if (c == end) { - folded_match = true; + // folded_match = true; num_matched = end - tmp; } } @@ -169,7 +170,7 @@ namespace fts { if (matched) { static constexpr int sequential_bonus = 15; // bonus for adjacent matches static constexpr int separator_bonus = 10/*30*/; // bonus if match occurs after a separator - static constexpr int camel_bonus = 30; // bonus if match is uppercase and prev is lower + // static constexpr int camel_bonus = 30; // bonus if match is uppercase and prev is lower static constexpr int first_letter_bonus = 15; // bonus if the first letter is matched static constexpr int leading_letter_penalty = -1/*-5*/; // penalty applied for every letter in str before the first match -- cgit v1.2.3