Skip to content
This repository has been archived by the owner on Feb 12, 2023. It is now read-only.

Commit

Permalink
fix(groupinviteform): remove deleted buttons from set
Browse files Browse the repository at this point in the history
Fix #3087.
  • Loading branch information
Diadlo committed Apr 11, 2016
1 parent 0a2f541 commit f137ba7
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
27 changes: 23 additions & 4 deletions src/widget/form/groupinviteform.cpp
Expand Up @@ -20,6 +20,7 @@
#include "groupinviteform.h"

#include <tox/tox.h>
#include <QDebug>
#include <QSignalMapper>
#include <QPushButton>
#include <QBoxLayout>
Expand Down Expand Up @@ -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);
}
Expand All @@ -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()
Expand Down
1 change: 1 addition & 0 deletions src/widget/form/groupinviteform.h
Expand Up @@ -78,6 +78,7 @@ private slots:
QSet<QPushButton*> acceptButtons;
QSet<QPushButton*> rejectButtons;
QList<GroupInvite> groupInvites;
void deleteInviteButtons(QWidget *widget);
};

#endif // GROUPINVITEFORM_H

0 comments on commit f137ba7

Please sign in to comment.