From 7f7ab9a1bce3ccc6901776fc85ac8a9e43679896 Mon Sep 17 00:00:00 2001 From: TheSpiritXIII Date: Thu, 18 Jun 2015 14:55:46 -0400 Subject: [PATCH] Circles: Fix quick switch crash, remove circle crash --- src/widget/categorywidget.cpp | 11 ++++++----- src/widget/circlewidget.cpp | 12 ++++++++++-- src/widget/friendlistwidget.cpp | 7 ++----- src/widget/tool/croppinglabel.cpp | 11 +++++++++++ src/widget/widget.cpp | 6 +++++- 5 files changed, 34 insertions(+), 13 deletions(-) diff --git a/src/widget/categorywidget.cpp b/src/widget/categorywidget.cpp index 09b55f0cb..e6fb9056b 100644 --- a/src/widget/categorywidget.cpp +++ b/src/widget/categorywidget.cpp @@ -256,9 +256,10 @@ void CategoryWidget::onCompactChanged(bool _compact) topLayout->setSpacing(0); topLayout->setMargin(0); - setCompact(_compact); + (void)_compact; + setCompact(true); - if (isCompact()) + if (true) { nameLabel->minimizeMaximumWidth(); @@ -277,7 +278,7 @@ void CategoryWidget::onCompactChanged(bool _compact) topLayout->addSpacing(5); topLayout->activate(); } - else + /*else { nameLabel->setMaximumWidth(QWIDGETSIZE_MAX); @@ -285,7 +286,7 @@ void CategoryWidget::onCompactChanged(bool _compact) mainLayout->setSpacing(0); mainLayout->setContentsMargins(20, 0, 20, 0); - container->setFixedHeight(35); + container->setFixedHeight(25); container->setLayout(mainLayout); topLayout->addWidget(&statusPic); @@ -300,7 +301,7 @@ void CategoryWidget::onCompactChanged(bool _compact) mainLayout->addWidget(lineFrame); mainLayout->addStretch(); mainLayout->activate(); - } + }*/ Style::repolish(this); } diff --git a/src/widget/circlewidget.cpp b/src/widget/circlewidget.cpp index 1e2aabd3b..90225a194 100644 --- a/src/widget/circlewidget.cpp +++ b/src/widget/circlewidget.cpp @@ -60,7 +60,8 @@ CircleWidget::CircleWidget(FriendListWidget* parent, int id) CircleWidget::~CircleWidget() { - circleList.remove(id); + if (circleList[id] == this) + circleList.remove(id); } void CircleWidget::editName() @@ -96,12 +97,15 @@ void CircleWidget::contextMenuEvent(QContextMenuEvent* event) friendList->removeCircleWidget(this); - circleList.remove(id); int replacedCircle = Settings::getInstance().removeCircle(id); auto circleReplace = circleList.find(replacedCircle); if (circleReplace != circleList.end()) circleReplace.value()->updateID(id); + else + assert(true); // This should never happen. + + circleList.remove(replacedCircle); } setContainerAttribute(Qt::WA_UnderMouse, false); } @@ -168,6 +172,10 @@ void CircleWidget::updateID(int index) { // For when a circle gets destroyed, another takes its id. // This function updates all friends widgets for this new id. + + if (id == index) + return; + id = index; circleList[id] = this; diff --git a/src/widget/friendlistwidget.cpp b/src/widget/friendlistwidget.cpp index 9df68b5e2..8706ad36a 100644 --- a/src/widget/friendlistwidget.cpp +++ b/src/widget/friendlistwidget.cpp @@ -374,10 +374,12 @@ void FriendListWidget::addCircleWidget(FriendWidget* friendWidget) if (circleOriginal != nullptr) Widget::getInstance()->searchCircle(circleOriginal); + } Widget::getInstance()->searchCircle(circleWidget); } + circleWidget->editName(); } void FriendListWidget::removeCircleWidget(CircleWidget* widget) @@ -660,8 +662,6 @@ void FriendListWidget::reDraw() CircleWidget* FriendListWidget::createCircleWidget(int id) { - bool isNew = (id == -1); - if (id == -1) id = Settings::getInstance().addCircle(); @@ -677,9 +677,6 @@ CircleWidget* FriendListWidget::createCircleWidget(int id) connect(circleWidget, &CircleWidget::renameRequested, this, &FriendListWidget::renameCircleWidget); circleWidget->show(); // Avoid flickering. - if (isNew) - circleWidget->editName(); - return circleWidget; } diff --git a/src/widget/tool/croppinglabel.cpp b/src/widget/tool/croppinglabel.cpp index a020bc38e..c321579e7 100644 --- a/src/widget/tool/croppinglabel.cpp +++ b/src/widget/tool/croppinglabel.cpp @@ -21,6 +21,17 @@ #include #include +class LineEdit : public QLineEdit +{ +public: + LineEdit(QWidget* parent = 0) : QLineEdit(parent) {} +protected: + void focusOutEvent(QFocusEvent *) + { + emit editingFinished(); + } +}; + CroppingLabel::CroppingLabel(QWidget* parent) : QLabel(parent) , blockPaintEvents(false) diff --git a/src/widget/widget.cpp b/src/widget/widget.cpp index 1eaa3672d..0288f4d43 100644 --- a/src/widget/widget.cpp +++ b/src/widget/widget.cpp @@ -1499,13 +1499,17 @@ void Widget::searchContacts() void Widget::changeDisplayMode() { + filterDisplayGroup->setEnabled(false); + if (filterDisplayGroup->checkedAction() == filterDisplayActivity) contactListWidget->setMode(FriendListWidget::Activity); else if (filterDisplayGroup->checkedAction() == filterDisplayName) contactListWidget->setMode(FriendListWidget::Name); - updateFilterText(); searchContacts(); + filterDisplayGroup->setEnabled(true); + + updateFilterText(); } void Widget::updateFilterText()