Skip to content

Commit

Permalink
fix colling crash & more fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
supermerill committed Dec 31, 2023
2 parents 5baf04a + ffb3273 commit 5813490
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 50 deletions.
44 changes: 3 additions & 41 deletions src/libslic3r/AppConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -662,54 +662,16 @@ void AppConfig::init_ui_layout() {
} else {
get_versions(data_dir_path, datadir_map);
}
// TODO test the version of the datadir_map layout to see if compatible


//copy all resources that aren't in datadir or newer
std::string current_name = get("ui_layout");
bool find_current = false;
std::string error_message;
for (const auto& layout : resources_map) {
auto it_datadir_layout = datadir_map.find(layout.first);
if (it_datadir_layout != datadir_map.end()) {
// compare version
if (it_datadir_layout->second.version < layout.second.version) {
//erase and copy
for (boost::filesystem::directory_entry& file : boost::filesystem::directory_iterator(it_datadir_layout->second.path)) {
boost::filesystem::remove_all(file.path());
}
for (boost::filesystem::directory_entry& file : boost::filesystem::directory_iterator(layout.second.path)) {
if (copy_file_inner(file.path(), it_datadir_layout->second.path / file.path().filename(), error_message))
throw FileIOError(error_message);
}
//update for saving
it_datadir_layout->second.version = layout.second.version;
it_datadir_layout->second.description = layout.second.description;
} else if (it_datadir_layout->second.version == layout.second.version) {
//if same verison, only erase files more recent
//this is useful when there is many rapid changes, to test modifications.
for (boost::filesystem::directory_entry& resources_file : boost::filesystem::directory_iterator(layout.second.path)) {
boost::filesystem::path datadir_path = it_datadir_layout->second.path / resources_file.path().filename();
std::time_t resources_last_mod = boost::filesystem::last_write_time(resources_file.path());
std::time_t datadir_last_mod = boost::filesystem::last_write_time(datadir_path);
if (datadir_last_mod < resources_last_mod) {
boost::filesystem::remove_all(datadir_path);
if (copy_file_inner(resources_file.path(), datadir_path, error_message))
throw FileIOError(error_message);
}
}

}
} else {
// Doesn't exists, copy
boost::filesystem::create_directory(data_dir_path / layout.second.path.filename());
for (boost::filesystem::directory_entry& file : boost::filesystem::directory_iterator(layout.second.path)) {
if (copy_file_inner(file.path(), data_dir_path / layout.second.path.filename() / file.path().filename(), error_message))
throw FileIOError(error_message);
}
//update for saving
datadir_map[layout.first] = layout.second;
datadir_map[layout.first].path = data_dir_path / layout.second.path.filename();
}
// don't use the datadir version, the one in my resources is the one adapated to my version.
datadir_map[layout.first] = layout.second;
}

//save installed
Expand Down
16 changes: 9 additions & 7 deletions src/libslic3r/PerimeterGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1686,7 +1686,8 @@ ProcessSurfaceResult PerimeterGenerator::process_classic(int& loop_number, const
//remove too small gaps that are too hard to fill.
//ie one that are smaller than an extrusion with width of min and a length of max.
if (expoly.area() > minarea) {
ExPolygons expoly_after_shrink_test = offset_ex(ExPolygons{ expoly }, double(-min * 0.5));
const coordf_t offset_test = min * 0.5;
ExPolygons expoly_after_shrink_test = offset_ex(ExPolygons{expoly}, -offset_test);
//if the shrink split the area in multipe bits
if (expoly_after_shrink_test.size() > 1) {
//remove too small bits
Expand All @@ -1695,22 +1696,23 @@ ProcessSurfaceResult PerimeterGenerator::process_classic(int& loop_number, const
expoly_after_shrink_test.erase(expoly_after_shrink_test.begin() + exp_idx);
exp_idx--;
} else {
ExPolygons wider = offset_ex(ExPolygons{ expoly_after_shrink_test[exp_idx] }, min * 0.5);
ExPolygons wider = offset_ex(ExPolygons{ expoly_after_shrink_test[exp_idx] }, offset_test);
if (wider.empty() || wider[0].area() < minarea) {
expoly_after_shrink_test.erase(expoly_after_shrink_test.begin() + exp_idx);
exp_idx--;
}
}
}
//maybe some areas are a just bit too thin, try with just a little more offset to remove them.
ExPolygons expoly_after_shrink_test2 = offset_ex(ExPolygons{ expoly }, double(-min * 0.8));
const coordf_t offset_test_2 = min * 0.8;
ExPolygons expoly_after_shrink_test2 = offset_ex(ExPolygons{expoly}, -offset_test_2);
for (int exp_idx = 0; exp_idx < expoly_after_shrink_test2.size(); exp_idx++) {
if (expoly_after_shrink_test2[exp_idx].area() < (SCALED_EPSILON * SCALED_EPSILON * 4)) {
expoly_after_shrink_test2.erase(expoly_after_shrink_test2.begin() + exp_idx);
exp_idx--;

} else {
ExPolygons wider = offset_ex(ExPolygons{ expoly_after_shrink_test2[exp_idx] }, min * 0.5);
ExPolygons wider = offset_ex(ExPolygons{ expoly_after_shrink_test2[exp_idx] }, offset_test_2);
if (wider.empty() || wider[0].area() < minarea) {
expoly_after_shrink_test2.erase(expoly_after_shrink_test2.begin() + exp_idx);
exp_idx--;
Expand All @@ -1719,15 +1721,15 @@ ProcessSurfaceResult PerimeterGenerator::process_classic(int& loop_number, const
}
//it's better if there are significantly less extrusions
if (expoly_after_shrink_test.size() / 1.42 > expoly_after_shrink_test2.size()) {
expoly_after_shrink_test2 = offset_ex(expoly_after_shrink_test2, double(min * 0.8));
expoly_after_shrink_test2 = offset_ex(expoly_after_shrink_test2, offset_test_2);
//insert with move instead of copy
std::move(expoly_after_shrink_test2.begin(), expoly_after_shrink_test2.end(), std::back_inserter(gaps_ex));
} else {
expoly_after_shrink_test = offset_ex(expoly_after_shrink_test, double(min * 0.8));
expoly_after_shrink_test = offset_ex(expoly_after_shrink_test, offset_test);
std::move(expoly_after_shrink_test.begin(), expoly_after_shrink_test.end(), std::back_inserter(gaps_ex));
}
} else {
expoly_after_shrink_test = offset_ex(expoly_after_shrink_test, double(min * 0.8));
expoly_after_shrink_test = offset_ex(expoly_after_shrink_test, offset_test);
std::move(expoly_after_shrink_test.begin(), expoly_after_shrink_test.end(), std::back_inserter(gaps_ex));
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/slic3r/GUI/DoubleSlider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1191,7 +1191,7 @@ void Control::draw_ruler(wxDC& dc)
break;
// short ticks from the last tick to the end of current sequence
//note: first sequence can be empty.
if(!std::isnan(short_tick));
if(!std::isnan(short_tick))
draw_short_ticks(dc, short_tick, tick);
if (sequence < m_ruler.count() - 1) sequence++;
}
Expand Down
2 changes: 1 addition & 1 deletion src/slic3r/GUI/Preferences.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ namespace GUI {

PreferencesDialog::PreferencesDialog(wxWindow* parent, int selected_tab, const std::string& highlight_opt_key) :
DPIDialog(parent, wxID_ANY, _L("Preferences"), wxDefaultPosition,
wxDefaultSize, wxDEFAULT_DIALOG_STYLE)
wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER )
{
#ifdef __WXOSX__
isOSX = true;
Expand Down

0 comments on commit 5813490

Please sign in to comment.