mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-06-25 16:58:46 +02:00
use a QPointer to trigger delayed delete
This commit is contained in:
parent
79674fb94f
commit
43e777163e
4 changed files with 15 additions and 1 deletions
|
@ -55,6 +55,12 @@ void AudioInjector::setIsFinished(bool isFinished) {
|
||||||
|
|
||||||
_isStarted = false;
|
_isStarted = false;
|
||||||
_shouldStop = false;
|
_shouldStop = false;
|
||||||
|
|
||||||
|
if (_shouldDeleteAfterFinish) {
|
||||||
|
// we've been asked to delete after finishing, trigger a queued deleteLater here
|
||||||
|
qDebug() << "triggering the delete since we are finished";
|
||||||
|
QMetaObject::invokeMethod(this, "deleteLater", Qt::QueuedConnection);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -46,7 +46,9 @@ public:
|
||||||
public slots:
|
public slots:
|
||||||
void injectAudio();
|
void injectAudio();
|
||||||
void restart();
|
void restart();
|
||||||
|
|
||||||
void stop();
|
void stop();
|
||||||
|
void triggerDeleteAfterFinish() { _shouldDeleteAfterFinish = true; }
|
||||||
void stopAndDeleteLater();
|
void stopAndDeleteLater();
|
||||||
|
|
||||||
void setOptions(AudioInjectorOptions& options) { _options = options; }
|
void setOptions(AudioInjectorOptions& options) { _options = options; }
|
||||||
|
@ -69,6 +71,7 @@ private:
|
||||||
float _loudness = 0.0f;
|
float _loudness = 0.0f;
|
||||||
bool _isStarted = false;
|
bool _isStarted = false;
|
||||||
bool _isFinished = false;
|
bool _isFinished = false;
|
||||||
|
bool _shouldDeleteAfterFinish = false;
|
||||||
int _currentSendPosition = 0;
|
int _currentSendPosition = 0;
|
||||||
AbstractAudioInterface* _localAudioInterface = NULL;
|
AbstractAudioInterface* _localAudioInterface = NULL;
|
||||||
AudioInjectorLocalBuffer* _localBuffer = NULL;
|
AudioInjectorLocalBuffer* _localBuffer = NULL;
|
||||||
|
|
|
@ -29,6 +29,11 @@ ScriptAudioInjector::ScriptAudioInjector(AudioInjector* injector) :
|
||||||
}
|
}
|
||||||
|
|
||||||
ScriptAudioInjector::~ScriptAudioInjector() {
|
ScriptAudioInjector::~ScriptAudioInjector() {
|
||||||
|
if (!_injector.isNull()) {
|
||||||
|
// we've been asked to delete after finishing, trigger a queued deleteLater here
|
||||||
|
QMetaObject::invokeMethod(_injector.data(), "triggerDeleteAfterFinish", Qt::QueuedConnection);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScriptAudioInjector::stopInjectorImmediately() {
|
void ScriptAudioInjector::stopInjectorImmediately() {
|
||||||
|
|
|
@ -39,7 +39,7 @@ signals:
|
||||||
protected slots:
|
protected slots:
|
||||||
void stopInjectorImmediately();
|
void stopInjectorImmediately();
|
||||||
private:
|
private:
|
||||||
AudioInjector* _injector;
|
QPointer<AudioInjector> _injector;
|
||||||
|
|
||||||
friend QScriptValue injectorToScriptValue(QScriptEngine* engine, ScriptAudioInjector* const& in);
|
friend QScriptValue injectorToScriptValue(QScriptEngine* engine, ScriptAudioInjector* const& in);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue