Skip to content
Snippets Groups Projects
Commit 948ff05e authored by Pascal Engeler's avatar Pascal Engeler
Browse files

Fixed two segmentation faults

parent 0209064c
No related branches found
No related tags found
No related merge requests found
...@@ -779,7 +779,7 @@ bool ArmDesigner::input_handle_() { ...@@ -779,7 +779,7 @@ bool ArmDesigner::input_handle_() {
ESC Clear selection ESC Clear selection
*/ */
if (event.key.keysym.sym == SDLK_m) {//m if (event.key.keysym.sym == SDLK_m) {//m
if (selected_nodes_[0].first == 0) { if (selected_nodes_.size() == 0 || selected_nodes_[0].first == 0) {
gui_params_.log_messages.push_back("Sketch segment doesn't allow midpointing."); gui_params_.log_messages.push_back("Sketch segment doesn't allow midpointing.");
continue; continue;
} }
...@@ -1017,6 +1017,9 @@ std::tuple<size_t, size_t, size_t, float> ArmDesigner::find_closest_seg_line_dis ...@@ -1017,6 +1017,9 @@ std::tuple<size_t, size_t, size_t, float> ArmDesigner::find_closest_seg_line_dis
continue; continue;
} }
auto nodes = segs[i].nodes(); auto nodes = segs[i].nodes();
if (nodes.size() == 0) {//fix segmentation fault
continue;
}
for (size_t k = 0; k < nodes.size()-1; ++k){ for (size_t k = 0; k < nodes.size()-1; ++k){
/*Find direction and normal vector of line*/ /*Find direction and normal vector of line*/
std::array<float, 2> dirv { nodes[k+1][0] - nodes[k][0], nodes[k+1][1] - nodes[k][1] }; //rg std::array<float, 2> dirv { nodes[k+1][0] - nodes[k][0], nodes[k+1][1] - nodes[k][1] }; //rg
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment