Unsolved Updated code from 5.4 to 5.8 and dialog.exec(); gives seg fault
-
Running on Linux ? If so, which distribution ?
-
Yes I running on Lubuntu 14.04
-
Hi, some questions:
- What happens if you use
QFileDialog::getSaveFileName()
instead of creating a custom dialog? http://doc.qt.io/qt-5/qfiledialog.html#getSaveFileName - Is your program doing anything else in the background when you open the dialog?
- What happens if you use
-
Hi ,
there's no threads running in the back ground. I tried getSaveFileName but get an error?gamefilename = dialog.getSaveFileName( this, tr("Save File"), "game.xml", tr("Game files (*.xml)"));
error
/home/tony/Dropbox/NewDevelopment/Tools/Game/main_class.cpp:92: error: no matching function for call to ‘QFileDialog::getSaveFileName(Main_Class*, QString, const char [9], QString)’ tr("Game files (*.xml)")); ^ /home/tony/Qt/5.8/gcc_64/include/QtWidgets/qfiledialog.h:225: static QString QFileDialog::getSaveFileName(QWidget*, const QString&, const QString&, const QString&, QString*, QFileDialog::Options) static QString getSaveFileName(QWidget *parent = Q_NULLPTR, ^
even if I copy and paste the example I get the error
egQString fileName = QFileDialog::getSaveFileName(this, tr("Save File"), "/home/jana/untitled.png", tr("Images (*.png *.xpm *.jpg)"));
error
/home/tony/Dropbox/NewDevelopment/Tools/Game/main_class.cpp:92: error: no matching function for call to ‘QFileDialog::getSaveFileName(Main_Class*, QString, const char [24], QString)’ tr("Images (*.png *.xpm *.jpg)")); ^ /home/tony/Qt/5.8/gcc_64/include/QtWidgets/qfiledialog.h:225: static QString QFileDialog::getSaveFileName(QWidget*, const QString&, const QString&, const QString&, QString*, QFileDialog::Options) static QString getSaveFileName(QWidget *parent = Q_NULLPTR, ^
-
Looks like Main_Class is not QWidget based.
-
Hi, My main is a qObject, would this cause the crash in dialog.exec? Or is this just related to getSaveFileName?
class Main_Class : public QObject { Q_OBJECT public: explicit Main_Class(QObject *parent = 0); void set_name( QString name ); QString get_name( void );
-
@tony67 said in Updated code from 5.4 to 5.8 and dialog.exec(); gives seg fault:
Or is this just related to getSaveFileName?
In the example code,
this
is the parent widget. If you don't have a parent widget, just pass anullptr
. -
Yep,
getSaveFileName(QWidget *parent = Q_NULLPTR, const QString &caption = QString(), const QString &dir = QString(), const QString &filter = QString(), QString *selectedFilter = Q_NULLPTR, Options options = Options())
Usually QWidgets inherit QObject, but not the other way around.
Either give it a QWidget as parent or, do it as @JKSH said, and give it no parent.
-
Hi,
did the above with parent, still get the seg faultgamefilename = dialog.getSaveFileName( nullptr, tr("Save File"), "game.xml", tr("Game files (*.xml)"));
fault
1 ?? 0x7fffed985d16 2 ?? 0x7fffed98a44a 3 ?? 0x7fffed00e3c3 4 ?? 0x7fffed00e3f9 5 g_main_context_dispatch 0x7ffff23c4b4d 6 ?? 0x7ffff23c4f20 7 g_main_loop_run 0x7ffff23c5242 8 gtk_dialog_run 0x7fffed95d6a0 9 ?? 0x7fffee0cd73a 10 QDialog::exec() 0x7ffff766492a 11 QFileDialog::getSaveFileUrl(QWidget *, QString const&, QUrl const&, QString const&, QString *, QFlags<QFileDialog::Option>, QStringList const&) 0x7ffff7675ecd 12 QFileDialog::getSaveFileName(QWidget *, QString const&, QString const&, QString const&, QString *, QFlags<QFileDialog::Option>) 0x7ffff7675f8a 13 Main_Class::save_the_game main_class.cpp 90 0x488d53 14 GameSimulation_PerfectGame_Dialog::GameSimulation_PerfectGame_Dialog gamesimulation_perfectgame_dialog.cpp 39 0x492d66 15 MainWindow::on_actionFPerfect_Game_Simulation_triggered mainwindow.cpp 622 0x41646b 16 MainWindow::qt_static_metacall moc_mainwindow.cpp 193 0x59c4c6 17 MainWindow::qt_metacall moc_mainwindow.cpp 232 0x59c620 18 QMetaObject::activate(QObject *, int, int, void * *) 0x7ffff6395564 19 QAction::triggered(bool) 0x7ffff7486cb2 20 QAction::activate(QAction::ActionEvent) 0x7ffff7489150 ... <More>
-
Might be something Ubuntu 14.04 related. This other thread seems to have a similar crash.
-
Thanks You might be right. Just noticed in Unity Engine when I open a save dialogue in Lubuntu 14.04 it causes a crash as well.
Can't upgrade either AMD graphics drivers don't work on grater than 14 and the open sources ones are to slow :s -
Sounds interesting, can you re-build and test your application with your distribution provided Qt development environment ?
-
If I understand what you mean, the qt downloaded with my distro Qt Creator 3.1.1, Based on Qt 5.4.1 (GCC 4.9.2, 64 bit), works fine.