3Dickulus / FragM

Derived from https://github.com/Syntopia/Fragmentarium/
GNU General Public License v3.0
344 stars 30 forks source link

crash on mouse release when dragging 2D camera #163

Closed claudeha closed 3 years ago

claudeha commented 3 years ago

Describe the bug FragM segfaults when the mouse is released when dragging 2D camera.

To Reproduce Steps to reproduce the behavior:

  1. Open a 2D frag.
  2. Drag the view with left mouse button.
  3. Release left mouse button.
  4. See error: crash

Expected behavior No crash.

Desktop (please complete the following information):

Additional context Seems to be DisplayWidget::setPerspective() crashing trying to split 3D camera settings, when the camera is 2D? This patch seems to fix the crash but I haven't checked that 3D frags are unaffected with splines etc (not sure how):

diff --git a/Fragmentarium-Source/Fragmentarium/GUI/DisplayWidget.cpp b/Fragmentarium-Source/Fragmentarium/GUI/DisplayWidget.cpp
index ce901b5..cc66277 100644
--- a/Fragmentarium-Source/Fragmentarium/GUI/DisplayWidget.cpp
+++ b/Fragmentarium-Source/Fragmentarium/GUI/DisplayWidget.cpp
@@ -2551,7 +2551,8 @@ void DisplayWidget::drawLookatVector()

 void DisplayWidget::setPerspective()
 {
-
+    CameraControl *cc = getCameraControl();
+    if (! (cc && cc->getID() == QString("3D"))) return;
     QStringList cs = mainWindow->getCameraSettings().split ( "\n" );
     double fov = cs.filter ( "FOV" ).at ( 0 ).split ( "=" ).at ( 1 ).toDouble();
     QStringList cv = cs.filter ( "Eye " ).at ( 0 ).split ( "=" ).at ( 1 ).split ( "," );
3Dickulus commented 3 years ago

setPerspective() is handled... next push, you are using the most recent ?

3Dickulus commented 3 years ago

setPerspective() is for draw3DHints(), spline path points, keyframe points and LookatVector (should be a line between current frame camera and target points, but just highlights those points as yellow)

I had moved it out of the camera3D test, haha, for testing... and forgot to put it back, oops, testing what? MMB click sets target location, CTRL+MMB click sets LightPos, it's not quite right but is adequate for setting the positions of target and light. edit: if you test this try both DepthToAlpha ON and OFF

What I'm trying to setup for is when click and drag on light execute a shader to render XYZ orientation, moving relative to the screen plane with depth on the wheel or WASD?

...and if I can get picking to work then same thing for spline control points (keyframes) :D