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>
<item> <item>
<widget class="QGroupBox" name="azel_path_group_box"> <widget class="QGroupBox" name="azel_path_group_box">
<property name="visible">
<bool>false</bool>
</property>
<property name="toolTip"> <property name="toolTip">
<string>AzEl Directory</string> <string>AzEl Directory</string>
</property> </property>

View File

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

View File

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