fixed crash in recording

This commit is contained in:
John Preston 2015-07-25 01:43:11 +02:00
parent 5fe1b7b51f
commit 021fbb8ad4
1 changed files with 4 additions and 2 deletions

View File

@ -2460,6 +2460,8 @@ void HistoryWidget::onRecordError() {
} }
void HistoryWidget::onRecordDone(QByteArray result, qint32 samples) { void HistoryWidget::onRecordDone(QByteArray result, qint32 samples) {
if (!_peer) return;
App::wnd()->activateWindow(); App::wnd()->activateWindow();
int32 duration = samples / AudioVoiceMsgFrequency; int32 duration = samples / AudioVoiceMsgFrequency;
_imageLoader.append(result, duration, _peer->id, replyToId(), ToPrepareAudio); _imageLoader.append(result, duration, _peer->id, replyToId(), ToPrepareAudio);
@ -2475,7 +2477,7 @@ void HistoryWidget::onRecordUpdate(qint16 level, qint32 samples) {
_recordingAnim.start(); _recordingAnim.start();
_recordingSamples = samples; _recordingSamples = samples;
if (samples < 0 || samples >= AudioVoiceMsgFrequency * AudioVoiceMsgMaxLength) { if (samples < 0 || samples >= AudioVoiceMsgFrequency * AudioVoiceMsgMaxLength) {
stopRecording(samples > 0 && _inField); stopRecording(_peer && samples > 0 && _inField);
} }
updateField(); updateField();
} }
@ -3588,7 +3590,7 @@ void HistoryWidget::mouseReleaseEvent(QMouseEvent *e) {
updateDragAreas(); updateDragAreas();
} }
if (_recording && cHasAudioCapture()) { if (_recording && cHasAudioCapture()) {
stopRecording(_inField); stopRecording(_peer && _inField);
} }
} }