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

fix(groupinviteform): remove deleted buttons from set

Fix #3087.
This commit is contained in:
Diadlo 2016-04-10 13:25:27 +03:00
parent 0a2f541945
commit f137ba710c
2 changed files with 24 additions and 4 deletions

View File

@ -20,6 +20,7 @@
#include "groupinviteform.h"
#include <tox/tox.h>
#include <QDebug>
#include <QSignalMapper>
#include <QPushButton>
#include <QBoxLayout>
@ -136,8 +137,7 @@ void GroupInviteForm::onGroupInviteAccepted()
GroupInvite invite = groupInvites.at(index);
groupInvites.removeAt(index);
groupWidget->deleteLater();
inviteLayout->removeWidget(groupWidget);
deleteInviteButtons(groupWidget);
emit groupInviteAccepted(invite.friendId, invite.type, invite.invite);
}
@ -149,8 +149,27 @@ void GroupInviteForm::onGroupInviteRejected()
int index = inviteLayout->indexOf(groupWidget);
groupInvites.removeAt(index);
groupWidget->deleteLater();
inviteLayout->removeWidget(groupWidget);
deleteInviteButtons(groupWidget);
}
void GroupInviteForm::deleteInviteButtons(QWidget *widget)
{
QList<QPushButton*> buttons = widget->findChildren<QPushButton*>();
if (acceptButtons.contains(buttons.at(0)))
{
acceptButtons.remove(buttons.at(0));
rejectButtons.remove(buttons.at(1));
}
else
{
acceptButtons.remove(buttons.at(1));
rejectButtons.remove(buttons.at(0));
}
widget->deleteLater();
inviteLayout->removeWidget(widget);
}
void GroupInviteForm::retranslateUi()

View File

@ -78,6 +78,7 @@ private:
QSet<QPushButton*> acceptButtons;
QSet<QPushButton*> rejectButtons;
QList<GroupInvite> groupInvites;
void deleteInviteButtons(QWidget *widget);
};
#endif // GROUPINVITEFORM_H