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

fix segfaults

This commit is contained in:
sudden6 2016-02-21 13:46:45 +01:00
parent 44ea20f921
commit fca7972b86
2 changed files with 14 additions and 10 deletions

View File

@ -217,7 +217,8 @@ void AddFriendForm::setIdFromClipboard()
void AddFriendForm::onFriendRequestAccepted()
{
QWidget* friendWidget = static_cast<QWidget*>(sender());
QPushButton* acceptButton = static_cast<QPushButton*>(sender());
QWidget* friendWidget = acceptButton->parentWidget();
int index = requestsLayout->indexOf(friendWidget);
friendWidget->deleteLater();
requestsLayout->removeWidget(friendWidget);
@ -228,7 +229,8 @@ void AddFriendForm::onFriendRequestAccepted()
void AddFriendForm::onFriendRequestRejected()
{
QWidget* friendWidget = static_cast<QWidget*>(sender());
QPushButton* rejectButton = static_cast<QPushButton*>(sender());
QWidget* friendWidget = rejectButton->parentWidget();
int index = requestsLayout->indexOf(friendWidget);
friendWidget->deleteLater();
requestsLayout->removeWidget(friendWidget);
@ -285,13 +287,13 @@ void AddFriendForm::addFriendRequestWidget(const QString &friendAddress, const Q
QPushButton* acceptButton = new QPushButton(friendWidget);
acceptButtons.insert(acceptButton);
connect(acceptButton, &QPushButton::released, this, &AddFriendForm::onFriendRequestAccepted);
connect(acceptButton, &QPushButton::clicked, this, &AddFriendForm::onFriendRequestAccepted);
friendLayout->addWidget(acceptButton);
retranslateAcceptButton(acceptButton);
QPushButton* rejectButton = new QPushButton(friendWidget);
acceptButtons.insert(acceptButton);
connect(acceptButton, &QPushButton::released, this, &AddFriendForm::onFriendRequestAccepted);
acceptButtons.insert(rejectButton);
connect(rejectButton, &QPushButton::clicked, this, &AddFriendForm::onFriendRequestRejected);
friendLayout->addWidget(rejectButton);
retranslateRejectButton(rejectButton);

View File

@ -67,7 +67,7 @@ GroupInviteForm::GroupInviteForm()
void GroupInviteForm::show(ContentLayout* contentLayout)
{
contentLayout->mainContent->layout()->addWidget(this);
//contentLayout->mainHead->layout()->addWidget(head);
contentLayout->mainHead->layout()->addWidget(headWidget);
QWidget::show();
headWidget->show();
}
@ -83,13 +83,13 @@ void GroupInviteForm::addGroupInvite(int32_t friendId, uint8_t type, QByteArray
QPushButton* acceptButton = new QPushButton(this);
acceptButtons.insert(acceptButton);
connect(acceptButton, &QPushButton::released, this, &GroupInviteForm::onGroupInviteAccepted);
connect(acceptButton, &QPushButton::clicked, this, &GroupInviteForm::onGroupInviteAccepted);
groupLayout->addWidget(acceptButton);
retranslateAcceptButton(acceptButton);
QPushButton* rejectButton = new QPushButton(this);
rejectButtons.insert(rejectButton);
connect(rejectButton, &QPushButton::released, this, &GroupInviteForm::onGroupInviteRejected);
connect(rejectButton, &QPushButton::clicked, this, &GroupInviteForm::onGroupInviteRejected);
groupLayout->addWidget(rejectButton);
retranslateRejectButton(rejectButton);
@ -113,7 +113,8 @@ void GroupInviteForm::showEvent(QShowEvent* event)
void GroupInviteForm::onGroupInviteAccepted()
{
QWidget* groupWidget = static_cast<QWidget*>(sender());
QPushButton* acceptButton = static_cast<QPushButton*>(sender());
QWidget* groupWidget = acceptButton->parentWidget();
int index = inviteLayout->indexOf(groupWidget);
GroupInvite invite = groupInvites.at(index);
groupInvites.removeAt(index);
@ -126,7 +127,8 @@ void GroupInviteForm::onGroupInviteAccepted()
void GroupInviteForm::onGroupInviteRejected()
{
QWidget* groupWidget = static_cast<QWidget*>(sender());
QPushButton* rejectButton = static_cast<QPushButton*>(sender());
QWidget* groupWidget = rejectButton->parentWidget();
int index = inviteLayout->indexOf(groupWidget);
groupInvites.removeAt(index);