Hi all,
I have a problem with using phonon after restarting application.
I have created singleton pattern class which holds voice messages for application. This class inherits from QObject to allow connection of signals and slots. Everything works fine in normal operation. However when i restart the application programatically with use of the following technique:
int main(int argc, char *argv[])
{
int currentExitCode = 0;
do{
qApp->setQuitOnLastWindowClosed(true);
SoundPlayer::instance()->loadSounds();
bool success;
MainWindow w(success);
if(success)
currentExitCode=a.exec();
else
qApp->exit();
}while( currentExitCode == MainWindow::EXIT_CODE_REBOOT );
return currentExitCode;
}
(..)
void SoundPlayer::loadSounds()
{
unloadSounds();
if(QFile::exists(dirfilename
)) {
qDebug()<<Phonon::phononVersion();
sounds.insert(estSound1 ,Phonon::createPlayer(Phonon::MusicCategory,Phonon::MediaSource(dirfilename)));
connect(sounds[estSound1],SIGNAL(finished()),this, SLOT(rewindPlayer()));
}
}
int main(int argc, char *argv[])
{
int currentExitCode = 0;
do{
QApplication a(argc, argv);
qApp->setQuitOnLastWindowClosed(true);
SoundPlayer::instance()->loadSounds();
bool success;
MainWindow w(success);
if(success)
currentExitCode=a.exec();
else
qApp->exit();
}while( currentExitCode == MainWindow::EXIT_CODE_REBOOT );
return currentExitCode;
}
(..)
void SoundPlayer::loadSounds()
{
unloadSounds();
QString dirfilename = "sound.mp3";
if(QFile::exists(dirfilename))
{
qDebug()<<Phonon::phononVersion();
sounds.insert(estSound1 ,Phonon::createPlayer(Phonon::MusicCategory,Phonon::MediaSource(dirfilename)));
connect(sounds[estSound1],SIGNAL(finished()),this, SLOT(rewindPlayer()));
}
}
To copy to clipboard, switch view to plain text mode
When the application restarts and the execution reaches loadSounds(), the error arises at:
Phonon::createPlayer(Phonon::MusicCategory,Phonon::MediaSource(dirfilename))
Phonon::createPlayer(Phonon::MusicCategory,Phonon::MediaSource(dirfilename))
To copy to clipboard, switch view to plain text mode
with message:
Fatal Error: Accessed global static 'Phonon::FactoryPrivate *globalFactory()' after destruction. Defined at ../3rdparty/phonon/phonon/factory.cpp:84
the same error appears when i try to execute any of:
Phonon::AudioOutput *audioOutput = new Phonon::AudioOutput();
Phonon::MediaObject *mo = new Phonon::MediaObject(this);
Phonon::AudioOutput *audioOutput = new Phonon::AudioOutput();
Phonon::MediaObject *mo = new Phonon::MediaObject(this);
To copy to clipboard, switch view to plain text mode
after restart.
Do you have any idea what can be wrong?
Best regards,
Konrad
Bookmarks