Cleaned up object deletion for notifications

This commit is contained in:
Jordan Sherer 2019-10-12 14:12:16 -04:00
parent b3df2985b7
commit 8ceef83f2e
3 changed files with 12 additions and 10 deletions

View File

@ -2181,6 +2181,9 @@ both here.</string>
</item>
<item>
<widget class="QGroupBox" name="azel_path_group_box">
<property name="visible">
<bool>false</bool>
</property>
<property name="toolTip">
<string>AzEl Directory</string>
</property>

View File

@ -18,11 +18,15 @@ NotificationAudio::NotificationAudio(QObject *parent) :
NotificationAudio::~NotificationAudio(){
stop();
delete m_decoder;
m_decoder = nullptr;
if(m_decoder){
delete m_decoder;
m_decoder = nullptr;
}
delete m_audio;
m_audio = nullptr;
if(m_audio){
delete m_audio;
m_audio = nullptr;
}
}
// initialize an audio device
@ -52,15 +56,11 @@ void NotificationAudio::init(const QAudioDeviceInfo &device, const QAudioFormat&
}
// play an audio file
void NotificationAudio::play(const QString &filePath) {
void NotificationAudio::play(const QString &filePath){
if(m_state == NotificationAudio::Playing){
return;
}
playFile(filePath);
}
void NotificationAudio::playFile(const QString &filePath){
if(!m_init || !m_decoder || !m_audio){
return;
}

View File

@ -49,7 +49,6 @@ private:
bool m_init;
bool m_isDecodingFinished;
void playFile(const QString &filePath);
void resetBuffers();
private slots: