Skip to content
Permalink
Browse files

Fix bad encoding of mime data which could cause crashes

  • Loading branch information...
captainhammy committed Jul 7, 2019
1 parent 54f05b9 commit aae84a4ad2b59c47050d8b29683fc8ad4e9e2e0c
Showing with 8 additions and 7 deletions.
  1. +2 −2 python/ht/ui/aovs/models.py
  2. +6 −5 python/ht/ui/aovs/widgets.py
@@ -767,7 +767,7 @@ def mimeData(self, indexes):

mime_data = QtCore.QMimeData()

mime_data.setData("text/csv", pickle.dumps(items))
mime_data.setData("text/csv", QtCore.QByteArray(pickle.dumps(items)))

return mime_data

@@ -865,7 +865,7 @@ def dropMimeData(self, data, action, row, column, parent): # pylint: disable=un
if not data.hasFormat("text/csv"):
return False

self.insert_data(pickle.loads(data.data("text/csv")))
self.insert_data(pickle.loads(data.data("text/csv").data()))

return True

@@ -1025,7 +1025,7 @@ def dragEnterEvent(self, event):
"""Event occurring when something is dragged into the widget."""
# Dropping our items.
if event.mimeData().hasFormat("text/csv"):
data = pickle.loads(event.mimeData().data("text/csv"))
data = pickle.loads(event.mimeData().data("text/csv").data())

if not data:
event.ignore()
@@ -1053,14 +1053,14 @@ def dropEvent(self, event):
# Handle our own drop events.
if mime_data.hasFormat("text/csv"):
# Extract the serialized json mime data from the event.
data = pickle.loads(mime_data.data("text/csv"))
data = pickle.loads(mime_data.data("text/csv").data())

# Flatten any data when moving with Ctrl.
if event.keyboardModifiers() == QtCore.Qt.ControlModifier:
data = utils.flattenList(data)

# Repack the data with out flattened list.
mime_data.setData("text/csv", pickle.dumps(data))
# Repack the data with our flattened list.
mime_data.setData("text/csv", QtCore.QByteArray(pickle.dumps(data)))

# Try to handle dropping nodes on the tree.
elif mime_data.hasFormat("text/plain"):
@@ -1100,7 +1100,7 @@ def dropEvent(self, event):
# If we've found any nodes we'll add the AOV data and remove the
# old data.
if found_nodes:
mime_data.setData("text/csv", pickle.dumps(new_data))
mime_data.setData("text/csv", QtCore.QByteArray(pickle.dumps(new_data)))
mime_data.removeFormat("text/plain")

# Call the superclass dropEvent() with our possibly modified data to
@@ -1594,6 +1594,7 @@ def uninstallListener(self, nodes):
if index is not None:
model.remove_index(index)


# =============================================================================
# New Group Widgets
# =============================================================================

0 comments on commit aae84a4

Please sign in to comment.
You can’t perform that action at this time.