mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
fix:(chatform): Issue 5115, use QSharedPointer for groupChatForms
This commit is contained in:
parent
a1a50b4bed
commit
37e5b6ce8b
|
@ -525,10 +525,6 @@ Widget::~Widget()
|
||||||
delete form;
|
delete form;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto form : groupChatForms) {
|
|
||||||
delete form;
|
|
||||||
}
|
|
||||||
|
|
||||||
delete icon;
|
delete icon;
|
||||||
delete profileForm;
|
delete profileForm;
|
||||||
delete profileInfo;
|
delete profileInfo;
|
||||||
|
@ -1155,7 +1151,7 @@ void Widget::openDialog(GenericChatroomWidget* widget, bool newWindow)
|
||||||
form = chatForms[id];
|
form = chatForms[id];
|
||||||
} else {
|
} else {
|
||||||
id = group->getId();
|
id = group->getId();
|
||||||
form = groupChatForms[id];
|
form = groupChatForms[id].data();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool chatFormIsSet;
|
bool chatFormIsSet;
|
||||||
|
@ -1303,7 +1299,7 @@ void Widget::addGroupDialog(Group* group, ContentDialog* dialog)
|
||||||
onAddClicked();
|
onAddClicked();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto chatForm = groupChatForms[groupId];
|
auto chatForm = groupChatForms[groupId].data();
|
||||||
auto chatroom = groupChatrooms[groupId];
|
auto chatroom = groupChatrooms[groupId];
|
||||||
auto groupWidget = dialog->addGroup(chatroom, chatForm);
|
auto groupWidget = dialog->addGroup(chatroom, chatForm);
|
||||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 7, 0))
|
#if (QT_VERSION >= QT_VERSION_CHECK(5, 7, 0))
|
||||||
|
@ -1749,7 +1745,7 @@ void Widget::onGroupMessageReceived(int groupnumber, int peernumber, const QStri
|
||||||
const auto targeted = !isSelf && mention;
|
const auto targeted = !isSelf && mention;
|
||||||
const auto groupId = g->getId();
|
const auto groupId = g->getId();
|
||||||
const auto date = QDateTime::currentDateTime();
|
const auto date = QDateTime::currentDateTime();
|
||||||
auto form = groupChatForms[groupId];
|
auto form = groupChatForms[groupId].data();
|
||||||
|
|
||||||
if (targeted && !isAction) {
|
if (targeted && !isAction) {
|
||||||
form->addAlertMessage(author, message, date, true);
|
form->addAlertMessage(author, message, date, true);
|
||||||
|
@ -1816,7 +1812,7 @@ void Widget::onGroupPeerAudioPlaying(int groupnumber, int peernumber)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto form = groupChatForms[g->getId()];
|
auto form = groupChatForms[g->getId()].data();
|
||||||
// TODO(sudden6): switch to ToxPk here
|
// TODO(sudden6): switch to ToxPk here
|
||||||
form->peerAudioPlaying(g->resolvePeerId(peernumber));
|
form->peerAudioPlaying(g->resolvePeerId(peernumber));
|
||||||
}
|
}
|
||||||
|
@ -1851,7 +1847,6 @@ void Widget::removeGroup(Group* g, bool fake)
|
||||||
qWarning() << "Tried to remove group" << groupId << "but GroupChatForm doesn't exist";
|
qWarning() << "Tried to remove group" << groupId << "but GroupChatForm doesn't exist";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
delete groupChatFormIt.value();
|
|
||||||
groupChatForms.erase(groupChatFormIt);
|
groupChatForms.erase(groupChatFormIt);
|
||||||
delete g;
|
delete g;
|
||||||
if (contentLayout && contentLayout->mainHead->layout()->isEmpty()) {
|
if (contentLayout && contentLayout->mainHead->layout()->isEmpty()) {
|
||||||
|
@ -1885,7 +1880,7 @@ Group* Widget::createGroup(int groupId)
|
||||||
auto form = new GroupChatForm(newgroup);
|
auto form = new GroupChatForm(newgroup);
|
||||||
groupWidgets[groupId] = widget;
|
groupWidgets[groupId] = widget;
|
||||||
groupChatrooms[groupId] = chatroom;
|
groupChatrooms[groupId] = chatroom;
|
||||||
groupChatForms[groupId] = form;
|
groupChatForms[groupId] = QSharedPointer<GroupChatForm>(form);
|
||||||
|
|
||||||
contactListWidget->addGroupWidget(widget);
|
contactListWidget->addGroupWidget(widget);
|
||||||
widget->updateStatusLight();
|
widget->updateStatusLight();
|
||||||
|
@ -2091,7 +2086,7 @@ void Widget::onGroupSendFailed(int groupId)
|
||||||
|
|
||||||
const auto message = tr("Message failed to send");
|
const auto message = tr("Message failed to send");
|
||||||
const auto curTime = QDateTime::currentDateTime();
|
const auto curTime = QDateTime::currentDateTime();
|
||||||
auto form = groupChatForms[g->getId()];
|
auto form = groupChatForms[g->getId()].data();
|
||||||
form->addSystemInfoMessage(message, ChatMessage::INFO, curTime);
|
form->addSystemInfoMessage(message, ChatMessage::INFO, curTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -310,7 +310,7 @@ private:
|
||||||
|
|
||||||
QMap<uint32_t, GroupWidget*> groupWidgets;
|
QMap<uint32_t, GroupWidget*> groupWidgets;
|
||||||
QMap<uint32_t, std::shared_ptr<GroupChatroom>> groupChatrooms;
|
QMap<uint32_t, std::shared_ptr<GroupChatroom>> groupChatrooms;
|
||||||
QMap<uint32_t, GroupChatForm*> groupChatForms;
|
QMap<uint32_t, QSharedPointer<GroupChatForm>> groupChatForms;
|
||||||
|
|
||||||
#ifdef Q_OS_MAC
|
#ifdef Q_OS_MAC
|
||||||
QAction* fileMenu;
|
QAction* fileMenu;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user