3Dickulus / FragM

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

crash when moving camera after text editor closed #162

Closed claudeha closed 3 years ago

claudeha commented 3 years ago

Describe the bug FragM segfaults when navigating the camera when all the text editor tabs have been closed.

To Reproduce Steps to reproduce the behavior:

  1. Start FragM
  2. Close all text editor tabs.
  3. Drag camera view
  4. See error: crash

Expected behavior No crash.

Desktop (please complete the following information):

Additional context This fix prevents the crash (but changing post variables now restart rendering; no big deal...)

diff --git a/Fragmentarium-Source/Fragmentarium/GUI/MainWindow.cpp b/Fragmentarium-Source/Fragmentarium/GUI/MainWindow.cpp
index 6232295..eb98252 100644
--- a/Fragmentarium-Source/Fragmentarium/GUI/MainWindow.cpp
+++ b/Fragmentarium-Source/Fragmentarium/GUI/MainWindow.cpp
@@ -885,6 +885,7 @@ void MainWindow::showWelcomeNote()
 bool MainWindow::isChangedUniformInBuffershaderOnly()
 {
     if(!engine->hasShader() || !engine->hasBufferShader()) return false;
+    if(!getTextEdit()) return false;
     QStringList lastSet = getTextEdit()->testParms().split("\n");
     bool inBufferShaderOnly = false;
     if (!lastSet.isEmpty()) {
3Dickulus commented 3 years ago

a better fix would be to shut down all attempted shader program interaction when there are no tabs open.

no tabs means it shouldn't be calling isChangedUniformInBuffershaderOnly()