aboutsummaryrefslogtreecommitdiff
path: root/lib/bookmarks
diff options
context:
space:
mode:
authorAqua-sama <aqua@iserlohn-fortress.net>2018-12-22 20:34:08 +0100
committerAqua-sama <aqua@iserlohn-fortress.net>2018-12-22 20:34:08 +0100
commit07cb3631b381a8ba3fcba44e3d20a40d19b83e39 (patch)
tree907e586fb0ba30c9b2c3775022509b1122f54fad /lib/bookmarks
parentAdd adblocklist class (diff)
downloadsmolbote-07cb3631b381a8ba3fcba44e3d20a40d19b83e39.tar.xz
Dropping bookmarks onto a folder now inserts it at the first position
BUG: #8 Dragging bookmarks onto folders crash
Diffstat (limited to 'lib/bookmarks')
-rw-r--r--lib/bookmarks/model/bookmarkitem.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/bookmarks/model/bookmarkitem.cpp b/lib/bookmarks/model/bookmarkitem.cpp
index 4715b6f..21d034f 100644
--- a/lib/bookmarks/model/bookmarkitem.cpp
+++ b/lib/bookmarks/model/bookmarkitem.cpp
@@ -51,8 +51,11 @@ bool BookmarkItem::appendChild(BookmarkItem *childItem)
bool BookmarkItem::insertChild(int position, BookmarkItem *childItem)
{
+ // position is invalid (-1) when dropping an item onto the folder, which leads to crash
+ // make sure that position passed is >= 0 (insert item at first position)
+
if(m_type == Folder || m_type == Root) {
- m_children.insert(position, childItem);
+ m_children.insert(qMax(position, 0), childItem);
return true;
}