From f3cb9bf63b3c14dc51b3d11ee10553770f85ba51 Mon Sep 17 00:00:00 2001 From: Odehan <47688877+zzhmark@users.noreply.github.com> Date: Fri, 27 Mar 2020 13:49:41 +0800 Subject: [PATCH] solve 3d viewer crash The 3d viewer may crash on initialization with some controls' connection on between glwidgets. It can be solved by temporarily disable the connections. The controls are xcmaxslider, ycmaxslider and zcmaxslider. Note that other controls' connections are not revised, as they don't cause crash in the current setting. --- v3d_main/3drenderer/v3dr_control_signal.cpp | 28 +++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/v3d_main/3drenderer/v3dr_control_signal.cpp b/v3d_main/3drenderer/v3dr_control_signal.cpp index 58866e6bd6..e4e6201a4f 100644 --- a/v3d_main/3drenderer/v3dr_control_signal.cpp +++ b/v3d_main/3drenderer/v3dr_control_signal.cpp @@ -1270,6 +1270,20 @@ void V3dR_MainWindow::initVolumeCutRange() { if (! glWidget) return; + // disable the connections before initialization, otherwise may crash --ZZH 2020/3/27 + if (xcmaxSlider) { + disconnect(glWidget, SIGNAL(changeXCut1(int)), xcmaxSlider, SLOT(setValue(int))); + disconnect(xcmaxSlider, SIGNAL(valueChanged(int)), glWidget, SLOT(setXCut1(int))); + } + if (ycmaxSlider) { + disconnect(glWidget, SIGNAL(changeYCut1(int)), ycmaxSlider, SLOT(setValue(int))); + disconnect(ycmaxSlider, SIGNAL(valueChanged(int)), glWidget, SLOT(setYCut1(int))); + } + if (zcmaxSlider) { + disconnect(glWidget, SIGNAL(changeZCut1(int)), zcmaxSlider, SLOT(setValue(int))); + disconnect(zcmaxSlider, SIGNAL(valueChanged(int)), glWidget, SLOT(setZCut1(int))); + } + int d1, d2, d3; d1 = MAX(0, glWidget->dataDim1()-1); d2 = MAX(0, glWidget->dataDim2()-1); @@ -1331,6 +1345,20 @@ void V3dR_MainWindow::initVolumeCutRange() zCSSlider->setMaximum(d3); zCSSlider->setValue((zCSSlider->minimum()+zCSSlider->maximum())/2); } + // reenable the connections --ZZH 2020/3/27 + if (xcmaxSlider) { + connect(glWidget, SIGNAL(changeXCut1(int)), xcmaxSlider, SLOT(setValue(int))); + connect(xcmaxSlider, SIGNAL(valueChanged(int)), glWidget, SLOT(setXCut1(int))); + } + if (ycmaxSlider) { + connect(glWidget, SIGNAL(changeYCut1(int)), ycmaxSlider, SLOT(setValue(int))); + connect(ycmaxSlider, SIGNAL(valueChanged(int)), glWidget, SLOT(setYCut1(int))); + } + + if (zcmaxSlider) { + connect(glWidget, SIGNAL(changeZCut1(int)), zcmaxSlider, SLOT(setValue(int))); + connect(zcmaxSlider, SIGNAL(valueChanged(int)), glWidget, SLOT(setZCut1(int))); + } } void V3dR_MainWindow::initSurfaceCutRange()