Skip to content

Commit

Permalink
Fix secondary issues due to Qt tree widget bug (#2109)
Browse files Browse the repository at this point in the history
  • Loading branch information
vkbo authored Nov 16, 2024
2 parents bec082c + c20f970 commit d944a70
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions novelwriter/gui/projtree.py
Original file line number Diff line number Diff line change
Expand Up @@ -1000,7 +1000,9 @@ def permDeleteItem(self, tHandle: str, askFirst: bool = True, flush: bool = True

self.propagateCount(tHandle, 0)

trItemP = trItemS.parent()
# If a non-root item ends up on root due to a bug, allow it
# to still be deleted from invisible root (see #2108)
trItemP = trItemS.parent() or self.invisibleRootItem()
tIndex = trItemP.indexOfChild(trItemS)
trItemP.takeChild(tIndex)

Expand Down Expand Up @@ -1315,9 +1317,11 @@ def dropEvent(self, event: QDropEvent) -> None:
action is allowed, and update relevant data.
"""
tItem = self.itemAt(event.pos())
dropOn = self.dropIndicatorPosition() == QAbstractItemView.DropIndicatorPosition.OnItem
onItem = self.dropIndicatorPosition() == QAbstractItemView.DropIndicatorPosition.OnItem
onView = self.dropIndicatorPosition() == QAbstractItemView.DropIndicatorPosition.OnViewport
# Make sure nothing can be dropped on invisible root (see #1569)
if not tItem or tItem.parent() is None and not dropOn:
# Make sure nothing can be dropped on the viewport (see #2108)
if tItem is None or (tItem.parent() is None and not onItem) or onView:
logger.error("Invalid drop location")
event.ignore()
return
Expand Down

0 comments on commit d944a70

Please sign in to comment.