1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

Merge pull request #3134

Diadlo (1):
      fix(core, widget): Added checks
This commit is contained in:
sudden6 2016-04-15 19:35:53 +02:00
commit 27c4873dc5
No known key found for this signature in database
GPG Key ID: 279509B499E032B9
2 changed files with 28 additions and 2 deletions

View File

@ -978,6 +978,12 @@ ToxId Core::getGroupPeerToxId(int groupId, int peerId) const
QList<QString> Core::getGroupPeerNames(int groupId) const QList<QString> Core::getGroupPeerNames(int groupId) const
{ {
QList<QString> names; QList<QString> names;
if (!tox)
{
qWarning() << "Can't get group peer names, tox is null";
return names;
}
int result = getGroupNumberPeers(groupId); int result = getGroupNumberPeers(groupId);
if (result < 0) if (result < 0)
{ {

View File

@ -1502,8 +1502,11 @@ void Widget::onGroupNamelistChanged(int groupnumber, int peernumber, uint8_t Cha
{ {
qDebug() << "onGroupNamelistChanged: Group "<<groupnumber<<" not found, creating it"; qDebug() << "onGroupNamelistChanged: Group "<<groupnumber<<" not found, creating it";
g = createGroup(groupnumber); g = createGroup(groupnumber);
if (!g)
return;
} }
TOX_CHAT_CHANGE change = static_cast<TOX_CHAT_CHANGE>(Change); TOX_CHAT_CHANGE change = static_cast<TOX_CHAT_CHANGE>(Change);
if (change == TOX_CHAT_CHANGE_PEER_ADD) if (change == TOX_CHAT_CHANGE_PEER_ADD)
{ {
@ -1586,14 +1589,29 @@ Group *Widget::createGroup(int groupId)
Group* g = GroupList::findGroup(groupId); Group* g = GroupList::findGroup(groupId);
if (g) if (g)
{ {
qWarning() << "createGroup: Group already exists"; qWarning() << "Group already exists";
return g; return g;
} }
Core* core = Nexus::getCore(); Core* core = Nexus::getCore();
if (!core)
{
qWarning() << "Can't create group. Core does not exist";
return nullptr;
}
QString groupName = QString("Groupchat #%1").arg(groupId); QString groupName = QString("Groupchat #%1").arg(groupId);
Group* newgroup = GroupList::addGroup(groupId, groupName, core->getAv()->isGroupAvEnabled(groupId)); CoreAV* coreAv = core->getAv();
if (!coreAv)
{
qWarning() << "Can't create group. CoreAv does not exist";
return nullptr;
}
bool enabled = coreAv->isGroupAvEnabled(groupId);
Group* newgroup = GroupList::addGroup(groupId, groupName, enabled);
contactListWidget->addGroupWidget(newgroup->getGroupWidget()); contactListWidget->addGroupWidget(newgroup->getGroupWidget());
newgroup->getGroupWidget()->updateStatusLight(); newgroup->getGroupWidget()->updateStatusLight();
@ -1616,6 +1634,8 @@ Group *Widget::createGroup(int groupId)
void Widget::onEmptyGroupCreated(int groupId) void Widget::onEmptyGroupCreated(int groupId)
{ {
Group* group = createGroup(groupId); Group* group = createGroup(groupId);
if (!group)
return;
// Only rename group if groups are visible. // Only rename group if groups are visible.
if (Widget::getInstance()->groupsVisible()) if (Widget::getInstance()->groupsVisible())