In my application, QFileDialog is used QFileDialog - when choosing a playlist and mp3 file.
Recently, when calling QFileDialog::getOpenFileName() , a SIGSEGV error began to appear. However, if you call QFileDialog::getOpenFileName() in the MainWindow constructor, then all subsequent calls to this method do not give any errors.
MediaplayerCfg - the class in which the first QFileDialog call occurs
class MediaplayerCfg : public QObject { Q_OBJECT public slots: void slot_setPosition(int value); mediaplayer.cpp (cited only a fragment of the function, since the rest of the work only works with the player)
void MediaplayerCfg::slot_playTrack() { filename = QFileDialog::getOpenFileName(&wgt, tr("Открыть mp3 файл"), QDir::homePath(), tr("mp3 файлы (*.mp3)")); qDebug() << filename; // filename = "/home/timur/Downloads/Music/Concorde - Just Kiss Her.mp3"; player->setMedia(QUrl::fromLocalFile(filename) ); player->setVolume(50); Tracklist Functional - class to work with playlist
tracklist.h
class TracklistFunctional : public QObject { Q_OBJECT public: ... void parsePlaylist(); }; tracklist.cpp
// Здесь мы открываем плейлист и записываем пути к трекам в currentTracklist void TracklistFunctional::parsePlaylist() { QString filename = QFileDialog::getOpenFileName(wgt, tr("Открыть файл конфигурации"), QDir::homePath(), tr("mp3 файлы (*.mp3)")); QFile playList(filename); if (playList.open(QIODevice::ReadOnly) == false) { QMessageBox mesError; mesError.setText("\tERROR\n" "Playlist can't be open."); mesError.setStandardButtons(QMessageBox::Cancel); mesError.exec(); } currentTracklist.clear(); QTextStream parseStream(&filename); QString line; while(parseStream.atEnd() ) { line = parseStream.readLine(); currentTracklist.append(line); } playList.close(); }
&wgt, maybe that's the problem. Try passing NULL or nullptr instead. It will become:QString filename = QFileDialog::getOpenFileName(nullptr, tr("Открыть mp3 файл"), QDir::homePath(), tr("mp3 файлы (*.mp3)"));- gil9red&wgt, and in anotherwgt. - vegorov