mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
Fix crash happening when QuickSwitcher is used with popout window (#4187)
Co-authored-by: Felanbird <41973452+Felanbird@users.noreply.github.com> Co-authored-by: pajlada <rasmus.karlsson@pajlada.com>
This commit is contained in:
parent
b3e400a049
commit
330e0a99fa
3 changed files with 39 additions and 31 deletions
|
@ -2,6 +2,7 @@
|
|||
|
||||
## Unversioned
|
||||
|
||||
- Bugfix: Fixed crash happening when QuickSwitcher is used with a popout window. (#4187)
|
||||
- Bugfix: Fixed low contrast of text in settings tooltips. (#4188)
|
||||
- Bugfix: Fixed being unable to see the usercard of VIPs who have Asian language display names. (#4174)
|
||||
- Bugfix: Fixed the wrong right-click menu showing in the chat input box. (#4177)
|
||||
|
|
|
@ -156,32 +156,38 @@ int Notebook::indexOf(QWidget *page) const
|
|||
|
||||
void Notebook::select(QWidget *page, bool focusPage)
|
||||
{
|
||||
if (!page)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (page == this->selectedPage_)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (page != nullptr)
|
||||
auto *item = this->findItem(page);
|
||||
if (!item)
|
||||
{
|
||||
page->setHidden(false);
|
||||
return;
|
||||
}
|
||||
|
||||
assert(this->containsPage(page));
|
||||
Item &item = this->findItem(page);
|
||||
page->show();
|
||||
|
||||
item.tab->setSelected(true);
|
||||
item.tab->raise();
|
||||
item->tab->setSelected(true);
|
||||
item->tab->raise();
|
||||
|
||||
if (focusPage)
|
||||
{
|
||||
if (item.selectedWidget == nullptr)
|
||||
if (item->selectedWidget == nullptr)
|
||||
{
|
||||
item.page->setFocus();
|
||||
item->page->setFocus();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (containsChild(page, item.selectedWidget))
|
||||
if (containsChild(page, item->selectedWidget))
|
||||
{
|
||||
item.selectedWidget->setFocus(Qt::MouseFocusReason);
|
||||
item->selectedWidget->setFocus(Qt::MouseFocusReason);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -190,20 +196,18 @@ void Notebook::select(QWidget *page, bool focusPage)
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (this->selectedPage_ != nullptr)
|
||||
{
|
||||
this->selectedPage_->setHidden(true);
|
||||
this->selectedPage_->hide();
|
||||
|
||||
Item &item = this->findItem(selectedPage_);
|
||||
item.tab->setSelected(false);
|
||||
|
||||
// for (auto split : this->selectedPage->getSplits()) {
|
||||
// split->updateLastReadMessage();
|
||||
// }
|
||||
|
||||
item.selectedWidget = this->selectedPage_->focusWidget();
|
||||
auto *item = this->findItem(selectedPage_);
|
||||
if (!item)
|
||||
{
|
||||
return;
|
||||
}
|
||||
item->tab->setSelected(false);
|
||||
item->selectedWidget = this->selectedPage_->focusWidget();
|
||||
}
|
||||
|
||||
this->selectedPage_ = page;
|
||||
|
@ -219,14 +223,17 @@ bool Notebook::containsPage(QWidget *page)
|
|||
});
|
||||
}
|
||||
|
||||
Notebook::Item &Notebook::findItem(QWidget *page)
|
||||
Notebook::Item *Notebook::findItem(QWidget *page)
|
||||
{
|
||||
auto it = std::find_if(this->items_.begin(), this->items_.end(),
|
||||
[page](const auto &item) {
|
||||
return page == item.page;
|
||||
});
|
||||
assert(it != this->items_.end());
|
||||
return *it;
|
||||
if (it != this->items_.end())
|
||||
{
|
||||
return &(*it);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool Notebook::containsChild(const QObject *obj, const QObject *child)
|
||||
|
|
|
@ -90,7 +90,7 @@ private:
|
|||
void resizeAddButton();
|
||||
|
||||
bool containsPage(QWidget *page);
|
||||
Item &findItem(QWidget *page);
|
||||
Item *findItem(QWidget *page);
|
||||
|
||||
static bool containsChild(const QObject *obj, const QObject *child);
|
||||
NotebookTab *getTabFromPage(QWidget *page);
|
||||
|
|
Loading…
Reference in a new issue