fredakilla / spkgen

Particle editor using flow graph nodes for the spark particle engine
168 stars 42 forks source link

Problem with FileDialogs on Linux using recent versions of Qt #5

Open JayFoxRox opened 3 years ago

JayFoxRox commented 3 years ago

Spkgen developpement is done with Qt 5.11.1 + QtCharts module for tgraph plot editor widget. WARNING : Do not use Qt 5.11.2, I experienced some bugs with FileDialogs on linux...

The problem mentioned in https://github.com/fredakilla/spkgen/blob/master/README.md#build does still exist in Qt 5.15 I strongly suspect this is a problem in Spkgen, not in Qt5.

JayFoxRox commented 3 years ago

This is related to the timers somehow. I assume the timer event somehow takes away the GL context?

Oddly enough, disabling the code inside the void MainWindow::timerEvent(QTimerEvent* event) is not enough. However, this is a functional workaround:

diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp
index a6ec52e..596dc2a 100644
--- a/src/MainWindow.cpp
+++ b/src/MainWindow.cpp
@@ -196,10 +196,12 @@ void MainWindow::onNewProject()

 void MainWindow::onOpen()
 {
+    killTimer(_gameLoopTimerId);
     QString fileName = QFileDialog::getOpenFileName(nullptr,
                                          tr("Open Flow Scene"),
                                          QDir::currentPath(),
                                          tr("Flow Scene Files (*.flow)"));
+    _gameLoopTimerId = startTimer(0);

     if (!QFileInfo::exists(fileName))
         return;
@@ -227,10 +229,12 @@ void MainWindow::onOpen()

 void MainWindow::onSaveAs()
 {
+    killTimer(_gameLoopTimerId);
     QString fileName = QFileDialog::getSaveFileName(nullptr,
                                          tr("Open Flow Scene"),
                                          QDir::currentPath(),
                                          tr("Flow Scene Files (*.flow)"));
+    _gameLoopTimerId = startTimer(0);

     if (!fileName.isEmpty())
     {