Skip to content

Commit

Permalink
Measure, fix segfault when compile not successful (openscad#4916)
Browse files Browse the repository at this point in the history
* only enable measurement when compilation was successful
* fixing instead of preventing the segfault
  • Loading branch information
gsohler authored Jan 2, 2024
1 parent 38e21ce commit a19d03f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
7 changes: 4 additions & 3 deletions src/gui/MainWindow.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2247,9 +2247,6 @@ void MainWindow::actionRender()
if (GuiLocker::isLocked()) return;
GuiLocker::lock();

this->designActionMeasureDist->setEnabled(true);
this->designActionMeasureAngle->setEnabled(true);

prepareCompile("cgalRender", true, false);
compile(false);
}
Expand Down Expand Up @@ -2300,7 +2297,11 @@ void MainWindow::actionRenderDone(const std::shared_ptr<const Geometry>& root_ge
// Go to CGAL view mode
if (viewActionWireframe->isChecked()) viewModeWireframe();
else viewModeSurface();
this->designActionMeasureDist->setEnabled(true);
this->designActionMeasureAngle->setEnabled(true);
} else {
this->designActionMeasureDist->setEnabled(false);
this->designActionMeasureAngle->setEnabled(false);
LOG(message_group::UI_Warning, "No top level geometry to render");
}

Expand Down
7 changes: 4 additions & 3 deletions src/gui/QGLView.cc
Original file line number Diff line number Diff line change
Expand Up @@ -540,10 +540,11 @@ std::vector<SelectedObject> QGLView::findObject(int mouse_x,int mouse_y)
Vector3d eyedir=far_pt-near_pt;

Vector3d testpt(0,0,0);

std::vector<SelectedObject> result;
auto renderer = this->getRenderer();
return renderer->findModelObject(near_pt, far_pt, mouse_x, mouse_y, cam.zoomValue()/300);

if(renderer == nullptr) return result;
result = renderer->findModelObject(near_pt, far_pt, mouse_x, mouse_y, cam.zoomValue()/300);
return result;
}

void QGLView::selectPoint(int mouse_x, int mouse_y)
Expand Down

0 comments on commit a19d03f

Please sign in to comment.