зеркало из https://github.com/mozilla/pjs.git
fix for bug #382221: Dragging bookmark on toolbar doesn't give permanent result
we need to adjust the indices before we make the change to the item we are moving, otherwise, our we'll impact the index of the item we are moving. r=dietrich
This commit is contained in:
Родитель
4888314444
Коммит
193c7e6686
|
@ -1455,25 +1455,9 @@ nsNavBookmarks::MoveItem(PRInt64 aItemId, PRInt64 aNewParent, PRInt32 aIndex)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
// update parent/index fields
|
||||
nsCAutoString buffer;
|
||||
buffer.AssignLiteral("UPDATE moz_bookmarks SET ");
|
||||
if (aNewParent != oldParent) {
|
||||
buffer.AppendLiteral(" parent = ");
|
||||
buffer.AppendInt(aNewParent);
|
||||
}
|
||||
if (newIndex != oldIndex) {
|
||||
if (aNewParent != oldParent)
|
||||
buffer.AppendLiteral(", ");
|
||||
buffer.AppendLiteral(" position = ");
|
||||
buffer.AppendInt(newIndex);
|
||||
}
|
||||
buffer.AppendLiteral(" WHERE id = ");
|
||||
buffer.AppendInt(aItemId);
|
||||
rv = dbConn->ExecuteSimpleSQL(buffer);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// adjust indices to account for the move
|
||||
// do this before we update the parent/index fields
|
||||
// or we'll re-adjust the index for the item we are moving
|
||||
if (oldParent == aNewParent) {
|
||||
// We can optimize the updates if moving within the same container.
|
||||
// We only shift the items between the old and new positions, since the
|
||||
|
@ -1493,6 +1477,24 @@ nsNavBookmarks::MoveItem(PRInt64 aItemId, PRInt64 aNewParent, PRInt32 aIndex)
|
|||
}
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// update parent/index fields
|
||||
nsCAutoString buffer;
|
||||
buffer.AssignLiteral("UPDATE moz_bookmarks SET ");
|
||||
if (aNewParent != oldParent) {
|
||||
buffer.AppendLiteral(" parent = ");
|
||||
buffer.AppendInt(aNewParent);
|
||||
}
|
||||
if (newIndex != oldIndex) {
|
||||
if (aNewParent != oldParent)
|
||||
buffer.AppendLiteral(", ");
|
||||
buffer.AppendLiteral(" position = ");
|
||||
buffer.AppendInt(newIndex);
|
||||
}
|
||||
buffer.AppendLiteral(" WHERE id = ");
|
||||
buffer.AppendInt(aItemId);
|
||||
rv = dbConn->ExecuteSimpleSQL(buffer);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = transaction.Commit();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче