diff --git a/audiobuffer.cpp b/audiobuffer.cpp index 354aabf15..80680d963 100644 --- a/audiobuffer.cpp +++ b/audiobuffer.cpp @@ -34,3 +34,8 @@ qint64 AudioBuffer::bufferSize() const { return buffer.size(); } + +void AudioBuffer::clear() +{ + buffer.clear(); +} diff --git a/audiobuffer.h b/audiobuffer.h index 5041cc3f6..b5a4b736e 100644 --- a/audiobuffer.h +++ b/audiobuffer.h @@ -15,6 +15,7 @@ public: qint64 writeData(const char *data, qint64 len); qint64 bytesAvailable() const; qint64 bufferSize() const; + void clear(); private: QByteArray buffer; diff --git a/core.cpp b/core.cpp index a2649d4ab..77a76001c 100644 --- a/core.cpp +++ b/core.cpp @@ -1056,17 +1056,19 @@ void Core::prepareCall(int friendId, int callId, ToxAv* toxav) } else qDebug() << QString("Core: Audio started, buffer size %1").arg(calls[callId].audioOutput->bufferSize()); - QtConcurrent::run(playCallAudio, callId, toxav); + calls[callId].playFuture = QtConcurrent::run(playCallAudio, callId, toxav); } void Core::cleanupCall(int callId) { qDebug() << QString("Core: cleaning up call %1").arg(callId); calls[callId].active = false; + calls[callId].playFuture.waitForFinished(); if (calls[callId].audioOutput != nullptr) { delete calls[callId].audioOutput; } + calls[callId].audioBuffer.clear(); } void Core::playCallAudio(int callId, ToxAv* toxav) diff --git a/core.h b/core.h index ed03a9837..2f48ecd16 100644 --- a/core.h +++ b/core.h @@ -89,6 +89,7 @@ public: int callId; int friendId; bool active; + QFuture playFuture; }; class Core : public QObject diff --git a/friendlist.cpp b/friendlist.cpp index 997372f8b..35da62f2a 100644 --- a/friendlist.cpp +++ b/friendlist.cpp @@ -6,6 +6,9 @@ QList FriendList::friendList; Friend* FriendList::addFriend(int friendId, QString userId) { + for (Friend* f : friendList) + if (f->friendId == friendId) + qWarning() << "FriendList::addFriend: friendId already taken"; Friend* newfriend = new Friend(friendId, userId); friendList.append(newfriend); return newfriend; diff --git a/main.cpp b/main.cpp index 8e46d5bb2..261377207 100644 --- a/main.cpp +++ b/main.cpp @@ -33,3 +33,21 @@ int main(int argc, char *argv[]) * An extra side panel for groupchats, like Venom does (?) * */ + +/** NAMES : +Botox +Ricin +Anthrax +Sarin +Cyanide +Polonium +Mercury +Arsenic +qTox +plague +Britney +Nightshade +Belladonna +toxer +GoyIM + */ diff --git a/widget/widget.cpp b/widget/widget.cpp index 7f42c347a..4987b443c 100644 --- a/widget/widget.cpp +++ b/widget/widget.cpp @@ -383,6 +383,8 @@ void Widget::onFriendRequestReceived(const QString& userId, const QString& messa void Widget::removeFriend(int friendId) { Friend* f = FriendList::findFriend(friendId); + if (f->widget == activeFriendWidget) + activeFriendWidget = nullptr; FriendList::removeFriend(friendId); core->removeFriend(friendId); delete f; @@ -449,6 +451,8 @@ void Widget::onGroupWidgetClicked(GroupWidget* widget) void Widget::removeGroup(int groupId) { Group* g = GroupList::findGroup(groupId); + if (g->widget == activeGroupWidget) + activeGroupWidget == nullptr; GroupList::removeGroup(groupId); core->removeGroup(groupId); delete g;