diff --git a/src/mumble/Messages.cpp b/src/mumble/Messages.cpp index 50eca9b91..98bbdda00 100644 --- a/src/mumble/Messages.cpp +++ b/src/mumble/Messages.cpp @@ -388,12 +388,6 @@ void MainWindow::msgUserState(const MumbleProto::UserState &msg) { if (channel != oldChannel) { pmModel->moveUser(pDst, channel); - if (Global::get().talkingUI) { - // Pass the pointer as QObject in order to avoid having to register ClientUser as a QMetaType - QMetaObject::invokeMethod(Global::get().talkingUI, "on_channelChanged", Qt::QueuedConnection, - Q_ARG(QObject *, pDst)); - } - if (pSelf) { if (pDst == pSelf) { Global::get().mw->updateChatBar(); diff --git a/src/mumble/TalkingUI.cpp b/src/mumble/TalkingUI.cpp index a6838271b..05129a2d7 100644 --- a/src/mumble/TalkingUI.cpp +++ b/src/mumble/TalkingUI.cpp @@ -32,9 +32,11 @@ #include #include +#include TalkingUI::TalkingUI(QWidget *parent) : QWidget(parent), m_containers(), m_currentSelection(nullptr) { setupUI(); + QObject::connect(Global::get().mw->pmModel, &UserModel::userMoved, this, &TalkingUI::on_channelChanged); } int TalkingUI::findContainer(int associatedChannelID, ContainerType type) const { @@ -730,11 +732,12 @@ void TalkingUI::on_serverDisconnected() { updateUI(); } -void TalkingUI::on_channelChanged(QObject *obj) { - // According to this function's doc, the passed object must be of type ClientUser - ClientUser *user = static_cast< ClientUser * >(obj); +void TalkingUI::on_channelChanged(unsigned int sessionID, const std::optional< unsigned int > &, + unsigned int newChannelID) { + ClientUser *user = ClientUser::get(sessionID); + const Channel *channel = Channel::get(newChannelID); - if (!user) { + if (!user || !channel) { return; } @@ -745,8 +748,8 @@ void TalkingUI::on_channelChanged(QObject *obj) { // the channel this particular user is being displayed in. // But first we have to make sure there actually exists and entry for // the new channel. - addChannel(user->cChannel); - moveUserToChannel(user->uiSession, user->cChannel->iId); + addChannel(channel); + moveUserToChannel(user->uiSession, channel->iId); } } diff --git a/src/mumble/TalkingUI.h b/src/mumble/TalkingUI.h index c28c39114..53b196b08 100644 --- a/src/mumble/TalkingUI.h +++ b/src/mumble/TalkingUI.h @@ -13,6 +13,7 @@ #include #include +#include #include #include "Settings.h" @@ -126,7 +127,8 @@ public slots: void on_mainWindowSelectionChanged(const QModelIndex ¤t, const QModelIndex &previous); void on_serverSynchronized(); void on_serverDisconnected(); - void on_channelChanged(QObject *user); + void on_channelChanged(unsigned int sessionID, const std::optional< unsigned int > &prevChannelID, + unsigned int newChannelID); void on_settingsChanged(); void on_clientDisconnected(unsigned int userSession); void on_muteDeafStateChanged();