Skip to content

Commit f8c5de6

Browse files
committed
fix: fix crashes
* 修复拖动到 show stash action 时崩溃 * 修复拖动后位置不变时崩溃
1 parent 60ef3f8 commit f8c5de6

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

panels/dock/tray/traysortordermodel.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,9 @@ bool TraySortOrderModel::move(const QString &draggedSurfaceId, const QString &dr
143143
if (sourceRow < destRow) {
144144
destRow--;
145145
}
146+
if (sourceRow == destRow) {
147+
return false;
148+
}
146149

147150
QString originSectionType = iter->sectionType;
148151
if (originSectionType != sectionType) {
@@ -186,6 +189,24 @@ std::tuple<bool, QString> TraySortOrderModel::moveAux(const QString &draggedSurf
186189
// Ensure position adjustment will be saved at last
187190
auto deferSaveSortOrder = qScopeGuard([this](){saveDataToDConfig();});
188191

192+
if (dropOnSurfaceId == ACTION_STASH_PLACEHOLDER_NAME) {
193+
// placeholder 只能是 stash 中最后一个
194+
if (!isBefore) {
195+
return {false, ""};
196+
}
197+
198+
QStringList *targetSection = &m_stashedIds;
199+
200+
// move to the end of stashed section
201+
if (targetSection == sourceSection) {
202+
m_stashedIds.move(m_stashedIds.indexOf(draggedSurfaceId), m_stashedIds.count() - 1);
203+
} else {
204+
sourceSection->removeOne(draggedSurfaceId);
205+
m_stashedIds.append(draggedSurfaceId);
206+
}
207+
return {true, SECTION_STASHED};
208+
}
209+
189210
if (dropOnSurfaceId == ACTION_SHOW_STASH_NAME) {
190211
// show stash action is always the first action, drop before it consider as drop into stashed area
191212
if (sourceSection != &m_stashedIds) {

0 commit comments

Comments
 (0)