add some asserts

This commit is contained in:
unknown 2024-10-17 20:35:52 +02:00
parent 39e0e00f2d
commit 1ca5d38ad5
2 changed files with 12 additions and 14 deletions

View file

@ -344,6 +344,9 @@ void NotebookTab::copyHighlightStateAndSourcesFrom(const NotebookTab *sourceTab)
{ {
if (this->isSelected()) if (this->isSelected())
{ {
assert(this->highlightSources_.highlightedSource.empty());
assert(this->highlightSources_.newMessageSource.empty());
assert(this->highlightState_ == HighlightState::None);
return; return;
} }
@ -391,7 +394,6 @@ void NotebookTab::setSelected(bool value)
} }
this->highlightSources_.clear(); this->highlightSources_.clear();
this->highlightState_ = HighlightState::None; this->highlightState_ = HighlightState::None;
this->update(); this->update();
@ -453,9 +455,14 @@ void NotebookTab::setHighlightState(HighlightState newHighlightStyle)
{ {
if (this->isSelected()) if (this->isSelected())
{ {
assert(this->highlightSources_.highlightedSource.empty());
assert(this->highlightSources_.newMessageSource.empty());
assert(this->highlightState_ == HighlightState::None);
return; return;
} }
this->highlightSources_.clear();
if (!this->highlightEnabled_ && if (!this->highlightEnabled_ &&
newHighlightStyle == HighlightState::NewMessage) newHighlightStyle == HighlightState::NewMessage)
{ {
@ -472,18 +479,15 @@ void NotebookTab::setHighlightState(HighlightState newHighlightStyle)
this->update(); this->update();
} }
void NotebookTab::forceHighlightState(HighlightState newHighlightStyle)
{
this->highlightState_ = newHighlightStyle;
this->update();
}
void NotebookTab::updateHighlightState(HighlightState newHighlightStyle, void NotebookTab::updateHighlightState(HighlightState newHighlightStyle,
const ChannelView &channelViewSource, const ChannelView &channelViewSource,
const MessagePtr &message) const MessagePtr &message)
{ {
if (this->isSelected()) if (this->isSelected())
{ {
assert(this->highlightSources_.highlightedSource.empty());
assert(this->highlightSources_.newMessageSource.empty());
assert(this->highlightState_ == HighlightState::None);
return; return;
} }

View file

@ -61,17 +61,11 @@ public:
bool isLive() const; bool isLive() const;
/** /**
* @brief Sets the highlight state of this tab clearing out highlight sources * @brief Sets the highlight state of this tab clearing highlight sources
* *
* Obeys the HighlightsEnabled setting and highlight states hierarchy * Obeys the HighlightsEnabled setting and highlight states hierarchy
*/ */
void setHighlightState(HighlightState style); void setHighlightState(HighlightState style);
/**
* @brief Forces the highlight state of this tab
*
* Does NOT obey the HighlightsEnabled setting and the highlight states hierarchy
*/
void forceHighlightState(HighlightState style);
/** /**
* @brief Updates the highlight state and highlight sources of this tab * @brief Updates the highlight state and highlight sources of this tab
* *