diff --git a/traitsui/qt4/clipboard.py b/traitsui/qt4/clipboard.py index 48c181dcd..78ba7a3da 100644 --- a/traitsui/qt4/clipboard.py +++ b/traitsui/qt4/clipboard.py @@ -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: diff --git a/traitsui/qt4/tree_editor.py b/traitsui/qt4/tree_editor.py index 7b077729b..17a5e6275 100644 --- a/traitsui/qt4/tree_editor.py +++ b/traitsui/qt4/tree_editor.py @@ -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): @@ -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