mirror of
https://github.com/vale981/tdesktop
synced 2025-03-06 02:01:40 -05:00
Add some assertions and info for crash debug.
An assertion violation happens some time so add some debug info.
This commit is contained in:
parent
8202a1633b
commit
8b96f7214e
2 changed files with 41 additions and 0 deletions
|
@ -91,6 +91,19 @@ void IndexedList::movePinned(Row *row, int deltaSign) {
|
|||
}
|
||||
auto history1 = row->history();
|
||||
auto history2 = (*swapPinnedIndexWith)->history();
|
||||
|
||||
// Debug an assertion violation.
|
||||
if (!history2->isPinnedDialog()) {
|
||||
auto myPinnedCount = 0;
|
||||
for_const (auto row, *this) {
|
||||
if (!row->history()->isPinnedDialog()) {
|
||||
break;
|
||||
}
|
||||
++myPinnedCount;
|
||||
}
|
||||
SignalHandlers::setCrashAnnotation("DebugInfo", QString("row index: %1, deltaSign: %2, pinnedCount: %3, myPinnedCount: %4").arg(row->pos()).arg(deltaSign).arg(App::histories().pinnedCount()).arg(myPinnedCount));
|
||||
}
|
||||
|
||||
t_assert(history1->isPinnedDialog());
|
||||
t_assert(history2->isPinnedDialog());
|
||||
auto index1 = history1->getPinnedIndex();
|
||||
|
|
|
@ -721,6 +721,20 @@ bool DialogsInner::updateReorderPinned(QPoint localPosition) {
|
|||
auto rowHeight = st::dialogsRowHeight;
|
||||
if (_dragStart.y() > localPosition.y() && _draggingIndex > 0) {
|
||||
shift = -floorclamp(_dragStart.y() - localPosition.y() + (rowHeight / 2), rowHeight, 0, _draggingIndex);
|
||||
|
||||
// Debug an assertion violation.
|
||||
if (shift < 0) {
|
||||
auto index = 0;
|
||||
for_const (auto row, *shownDialogs()) {
|
||||
if (++index >= _draggingIndex + shift) {
|
||||
t_assert(row->history()->isPinnedDialog());
|
||||
if (index >= _draggingIndex) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (auto from = _draggingIndex, to = _draggingIndex + shift; from > to; --from) {
|
||||
shownDialogs()->movePinned(_dragging, -1);
|
||||
std::swap(_pinnedRows[from], _pinnedRows[from - 1]);
|
||||
|
@ -729,6 +743,20 @@ bool DialogsInner::updateReorderPinned(QPoint localPosition) {
|
|||
}
|
||||
} else if (_dragStart.y() < localPosition.y() && _draggingIndex + 1 < pinnedCount) {
|
||||
shift = floorclamp(localPosition.y() - _dragStart.y() + (rowHeight / 2), rowHeight, 0, pinnedCount - _draggingIndex - 1);
|
||||
|
||||
// Debug an assertion violation.
|
||||
if (shift > 0) {
|
||||
auto index = 0;
|
||||
for_const (auto row, *shownDialogs()) {
|
||||
if (++index >= _draggingIndex) {
|
||||
t_assert(row->history()->isPinnedDialog());
|
||||
if (index >= _draggingIndex + shift) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (auto from = _draggingIndex, to = _draggingIndex + shift; from < to; ++from) {
|
||||
shownDialogs()->movePinned(_dragging, 1);
|
||||
std::swap(_pinnedRows[from], _pinnedRows[from + 1]);
|
||||
|
|
Loading…
Add table
Reference in a new issue