mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
Fix crash that would occur when performing certain actions after removing all tabs (#4271)
* Ensure we can deselect notebooks * Add changelog entry * Use dynamic_cast instead of raw cast
This commit is contained in:
parent
11fdd7ed74
commit
90046f380f
|
@ -8,6 +8,7 @@
|
||||||
- Minor: Tables in settings window will now scroll to newly added rows. (#4216)
|
- Minor: Tables in settings window will now scroll to newly added rows. (#4216)
|
||||||
- Minor: Added link to streamlink docs for easier user setup. (#4217)
|
- Minor: Added link to streamlink docs for easier user setup. (#4217)
|
||||||
- Minor: Added setting to turn off rendering of reply context. (#4224)
|
- Minor: Added setting to turn off rendering of reply context. (#4224)
|
||||||
|
- Bugfix: Fixed crash that would occur when performing certain actions after removing all tabs. (#4271)
|
||||||
- Bugfix: Fixed highlight sounds not reloading on change properly. (#4194)
|
- Bugfix: Fixed highlight sounds not reloading on change properly. (#4194)
|
||||||
- Bugfix: Fixed CTRL + C not working in reply thread popups. (#4209)
|
- Bugfix: Fixed CTRL + C not working in reply thread popups. (#4209)
|
||||||
- Bugfix: Fixed message input showing as red after removing a message that was more than 500 characters. (#4204)
|
- Bugfix: Fixed message input showing as red after removing a message that was more than 500 characters. (#4204)
|
||||||
|
|
|
@ -156,16 +156,15 @@ int Notebook::indexOf(QWidget *page) const
|
||||||
|
|
||||||
void Notebook::select(QWidget *page, bool focusPage)
|
void Notebook::select(QWidget *page, bool focusPage)
|
||||||
{
|
{
|
||||||
if (!page)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (page == this->selectedPage_)
|
if (page == this->selectedPage_)
|
||||||
{
|
{
|
||||||
|
// Nothing has changed
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (page)
|
||||||
|
{
|
||||||
|
// A new page has been selected, mark it as selected & focus one of its splits
|
||||||
auto *item = this->findItem(page);
|
auto *item = this->findItem(page);
|
||||||
if (!item)
|
if (!item)
|
||||||
{
|
{
|
||||||
|
@ -196,9 +195,11 @@ void Notebook::select(QWidget *page, bool focusPage)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (this->selectedPage_ != nullptr)
|
if (this->selectedPage_)
|
||||||
{
|
{
|
||||||
|
// Hide the previously selected page
|
||||||
this->selectedPage_->hide();
|
this->selectedPage_->hide();
|
||||||
|
|
||||||
auto *item = this->findItem(selectedPage_);
|
auto *item = this->findItem(selectedPage_);
|
||||||
|
@ -1169,22 +1170,29 @@ SplitContainer *SplitNotebook::getOrAddSelectedPage()
|
||||||
{
|
{
|
||||||
auto *selectedPage = this->getSelectedPage();
|
auto *selectedPage = this->getSelectedPage();
|
||||||
|
|
||||||
return selectedPage != nullptr ? (SplitContainer *)selectedPage
|
if (selectedPage)
|
||||||
: this->addPage();
|
{
|
||||||
|
return dynamic_cast<SplitContainer *>(selectedPage);
|
||||||
|
}
|
||||||
|
|
||||||
|
return this->addPage();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SplitNotebook::select(QWidget *page, bool focusPage)
|
void SplitNotebook::select(QWidget *page, bool focusPage)
|
||||||
{
|
{
|
||||||
if (auto selectedPage = this->getSelectedPage())
|
// If there's a previously selected page, go through its splits and
|
||||||
|
// update their "last read message" indicator
|
||||||
|
if (auto *selectedPage = this->getSelectedPage())
|
||||||
{
|
{
|
||||||
if (auto splitContainer = dynamic_cast<SplitContainer *>(selectedPage))
|
if (auto *splitContainer = dynamic_cast<SplitContainer *>(selectedPage))
|
||||||
{
|
{
|
||||||
for (auto split : splitContainer->getSplits())
|
for (auto *split : splitContainer->getSplits())
|
||||||
{
|
{
|
||||||
split->updateLastReadMessage();
|
split->updateLastReadMessage();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this->Notebook::select(page, focusPage);
|
this->Notebook::select(page, focusPage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue