Skip to content

Commit

Permalink
Merge pull request enthought#92 from pankajp/pymimedata-coerce-no-ins…
Browse files Browse the repository at this point in the history
…tance

Avoid qt traceback on drag/drop/clipboard operations.
  • Loading branch information
Jason McCampbell committed Feb 7, 2013
2 parents 2550866 + 49939f8 commit 37c9126
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
4 changes: 4 additions & 0 deletions traitsui/qt4/clipboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ def instance(self):
if self._local_instance is not None:
return self._local_instance

if not self.hasFormat(self.MIME_TYPE):
# We have no pickled python data defined.
return None

io = StringIO(str(self.data(self.MIME_TYPE)))

try:
Expand Down
9 changes: 6 additions & 3 deletions traitsui/qt4/tree_editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -513,8 +513,9 @@ def _delete_node ( self, nid ):
pnid.removeChild(nid)

# If the deleted node had an active editor panel showing, remove it:
if (self._editor is not None) and (nid == self._editor._editor_nid):
self._clear_editor()
# Note: QTreeWidgetItem does not have an equal operator, so use id()
if (self._editor is not None) and (id(nid) == id(self._editor._editor_nid)):
self._clear_editor()

#---------------------------------------------------------------------------
# Expands the contents of a specified node (if required):
Expand Down Expand Up @@ -1785,10 +1786,12 @@ def dragMoveEvent(self, e):
# A copy action is interpreted as moving the source to a particular
# place within the target's parent. A move action is interpreted as
# moving the source to be a child of the target.
node = None
if e.proposedAction() == QtCore.Qt.CopyAction:
node, object, _ = self._editor._node_index(nid)
# `node` is None in case of top-level tree node, in which case we try move
insert = True
else:
if node is None:
_, node, object = self._editor._get_node_data(nid)
insert = False

Expand Down

0 comments on commit 37c9126

Please sign in to comment.