From d4acf29fc0c632e4ec409af06b802bddaea521e9 Mon Sep 17 00:00:00 2001 From: TheSpiritXIII Date: Fri, 5 Jun 2015 11:15:59 -0400 Subject: [PATCH] Fix circle settings crash regression --- src/friend.h | 2 +- src/persistence/settings.h | 2 +- src/widget/friendlistwidget.cpp | 9 +++------ src/widget/friendwidget.h | 6 +++--- 4 files changed, 8 insertions(+), 11 deletions(-) diff --git a/src/friend.h b/src/friend.h index cea96499d..5213db341 100644 --- a/src/friend.h +++ b/src/friend.h @@ -25,7 +25,7 @@ #include "src/core/corestructs.h" #include "core/toxid.h" -struct FriendWidget; +class FriendWidget; class ChatForm; class Friend : public QObject diff --git a/src/persistence/settings.h b/src/persistence/settings.h index 7df4d32ff..c1a103be1 100644 --- a/src/persistence/settings.h +++ b/src/persistence/settings.h @@ -368,7 +368,7 @@ private: QString alias; QString addr; QString autoAcceptDir; - int circleIndex; + int circleIndex = -1; }; struct circleProp diff --git a/src/widget/friendlistwidget.cpp b/src/widget/friendlistwidget.cpp index 076a8b776..c95fd0d2b 100644 --- a/src/widget/friendlistwidget.cpp +++ b/src/widget/friendlistwidget.cpp @@ -60,14 +60,11 @@ void FriendListWidget::addGroupWidget(GroupWidget *widget) void FriendListWidget::addFriendWidget(FriendWidget *w, Status s, int circleIndex) { - if (circleIndex == -1) + CircleWidget* circleWidget = CircleWidget::getFromID(circleIndex); + if (circleWidget == nullptr) moveWidget(w, s, true); else - { - CircleWidget::getFromID(circleIndex)->addFriendWidget(w, s); - CircleWidget::getFromID(circleIndex)->show(); - //w->setParent(CircleWidget::getFromID(circleIndex)); - } + circleWidget->addFriendWidget(w, s); } void FriendListWidget::addCircleWidget(int id) diff --git a/src/widget/friendwidget.h b/src/widget/friendwidget.h index 2272e69c2..76e71dbf4 100644 --- a/src/widget/friendwidget.h +++ b/src/widget/friendwidget.h @@ -27,7 +27,7 @@ class QPixmap; class MaskablePixmapWidget; -struct FriendWidget final : public GenericChatroomWidget +class FriendWidget : public GenericChatroomWidget { Q_OBJECT public: @@ -51,8 +51,8 @@ public slots: void setAlias(const QString& alias); protected: - virtual void mousePressEvent(QMouseEvent* ev) final override; - virtual void mouseMoveEvent(QMouseEvent* ev) final override; + virtual void mousePressEvent(QMouseEvent* ev) override; + virtual void mouseMoveEvent(QMouseEvent* ev) override; void setFriendAlias(); void showEvent(QShowEvent *) {