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

View File

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