Fixed collapse button style (looks like service message now).

Added some asserts because of unknown crash in switch in channel.
This commit is contained in:
John Preston 2016-03-25 19:39:58 +03:00
parent 844e375fac
commit 3132e4dc17
2 changed files with 16 additions and 10 deletions

View File

@ -1148,7 +1148,7 @@ collapseButton: flatButton(btnDefFlat) {
textTop: 3px; textTop: 3px;
overTextTop: 3px; overTextTop: 3px;
downTextTop: 3px; downTextTop: 3px;
height: 24px; height: 25px;
} }
collapseHideDuration: 200; collapseHideDuration: 200;
collapseShowDuration: 200; collapseShowDuration: 200;

View File

@ -830,6 +830,7 @@ void ChannelHistory::switchMode() {
int willAddToBlock = qMin(int(MessagesPerPage), count - i); int willAddToBlock = qMin(int(MessagesPerPage), count - i);
block->items.reserve(willAddToBlock); block->items.reserve(willAddToBlock);
for (int till = i + willAddToBlock; i < till; ++i) { for (int till = i + willAddToBlock; i < till; ++i) {
t_assert(_otherList.at(i)->detached());
addItemToBlock(_otherList.at(i), block); addItemToBlock(_otherList.at(i), block);
} }
@ -2565,6 +2566,8 @@ void History::changeMsgId(MsgId oldId, MsgId newId) {
void History::removeBlock(HistoryBlock *block) { void History::removeBlock(HistoryBlock *block) {
setPendingResize(); setPendingResize();
t_assert(block->items.isEmpty());
int index = block->indexInHistory(); int index = block->indexInHistory();
blocks.removeAt(index); blocks.removeAt(index);
for (int i = index, l = blocks.size(); i < l; ++i) { for (int i = index, l = blocks.size(); i < l; ++i) {
@ -2614,7 +2617,7 @@ void HistoryBlock::clear(bool leaveItems) {
void HistoryBlock::removeItem(HistoryItem *item) { void HistoryBlock::removeItem(HistoryItem *item) {
t_assert(item->block() == this); t_assert(item->block() == this);
int32 itemIndex = item->indexInBlock(); int itemIndex = item->indexInBlock();
if (history->showFrom == item) { if (history->showFrom == item) {
history->getNextShowFrom(this, itemIndex); history->getNextShowFrom(this, itemIndex);
} }
@ -2625,13 +2628,14 @@ void HistoryBlock::removeItem(HistoryItem *item) {
history->getNextScrollTopItem(this, itemIndex); history->getNextScrollTopItem(this, itemIndex);
} }
int myIndex = indexInHistory(); int blockIndex = indexInHistory();
if (myIndex >= 0) { // fix message groups if (blockIndex >= 0) { // fix message groups
if (item->isImportant()) { // unite message groups around this important message if (item->isImportant()) { // unite message groups around this important message
HistoryGroup *nextGroup = 0, *prevGroup = 0; HistoryGroup *nextGroup = nullptr;
HistoryCollapse *nextCollapse = 0; HistoryGroup *prevGroup = nullptr;
HistoryItem *prevItem = 0; HistoryCollapse *nextCollapse = nullptr;
for (int32 nextBlock = myIndex, nextIndex = qMin(items.size(), itemIndex + 1); nextBlock < history->blocks.size(); ++nextBlock) { HistoryItem *prevItem = nullptr;
for (int nextBlock = blockIndex, nextIndex = qMin(items.size(), itemIndex + 1); nextBlock < history->blocks.size(); ++nextBlock) {
HistoryBlock *block = history->blocks.at(nextBlock); HistoryBlock *block = history->blocks.at(nextBlock);
for (; nextIndex < block->items.size(); ++nextIndex) { for (; nextIndex < block->items.size(); ++nextIndex) {
HistoryItem *item = block->items.at(nextIndex); HistoryItem *item = block->items.at(nextIndex);
@ -2651,7 +2655,7 @@ void HistoryBlock::removeItem(HistoryItem *item) {
break; break;
} }
} }
for (int32 prevBlock = myIndex + 1, prevIndex = qMax(1, itemIndex); prevBlock > 0;) { for (int prevBlock = blockIndex + 1, prevIndex = qMax(1, itemIndex); prevBlock > 0;) {
--prevBlock; --prevBlock;
HistoryBlock *block = history->blocks.at(prevBlock); HistoryBlock *block = history->blocks.at(prevBlock);
if (!prevIndex) prevIndex = block->items.size(); if (!prevIndex) prevIndex = block->items.size();
@ -2680,7 +2684,9 @@ void HistoryBlock::removeItem(HistoryItem *item) {
} }
} }
} }
// myIndex can be invalid now, because of destroying previous blocks // blockIndex can be invalid now, because of destroying previous blocks
blockIndex = indexInHistory();
itemIndex = item->indexInBlock();
items.remove(itemIndex); items.remove(itemIndex);
for (int i = itemIndex, l = items.size(); i < l; ++i) { for (int i = itemIndex, l = items.size(); i < l; ++i) {