diff options
author | Calum Lind <calumlind+deluge@gmail.com> | 2019-05-20 20:46:00 +0100 |
---|---|---|
committer | Calum Lind <calumlind+deluge@gmail.com> | 2019-05-20 21:14:42 +0100 |
commit | 827987fe7d8b687c4ec3b4b50920f483650d65f8 (patch) | |
tree | b3a780e22a4802e42e3b7d845ec9fd0479e10c56 | |
parent | 1357ca7582249d7ba0495957bb363f40b57a45b6 (diff) | |
download | deluge-827987fe7d8b687c4ec3b4b50920f483650d65f8.tar.gz deluge-827987fe7d8b687c4ec3b4b50920f483650d65f8.tar.bz2 deluge-827987fe7d8b687c4ec3b4b50920f483650d65f8.zip |
[GTK] Fix drag and drop files in files_tab
Encoutered an error reordering files by dragging in the files tab:
TypeError: can't pickle TreePath objects
The issue was get_selected_row now returns a list of TreePath objects which
cannot be pickled. Also the set_text method only accept unicode text to
pickled bytes cannot be used.
The fix is to convert the TreePaths to strings and use json to encode
the list of strings for set_text.
-rw-r--r-- | deluge/ui/gtk3/files_tab.py | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/deluge/ui/gtk3/files_tab.py b/deluge/ui/gtk3/files_tab.py index fad74bf03..a80418ce2 100644 --- a/deluge/ui/gtk3/files_tab.py +++ b/deluge/ui/gtk3/files_tab.py @@ -9,10 +9,10 @@ from __future__ import division, unicode_literals +import json import logging import os.path -import six.moves.cPickle as pickle # noqa: N813 from gi.repository import Gio, Gtk from gi.repository.Gdk import DragAction, ModifierType, keyval_name from gi.repository.GObject import TYPE_UINT64 @@ -813,14 +813,14 @@ class FilesTab(Tab): def _on_drag_data_get_data(self, treeview, context, selection, target_id, etime): paths = self.listview.get_selection().get_selected_rows()[1] - selection.set_text(pickle.dumps(paths, protocol=2)) + selection.set_text(json.dumps([str(path) for path in paths]), -1) def _on_drag_data_received_data( self, treeview, context, x, y, selection, info, etime ): try: - selected = pickle.loads(selection.get_data()) - except pickle.UnpicklingError: + selected = json.loads(selection.get_data()) + except TypeError: log.debug('Invalid selection data: %s', selection.get_data()) return log.debug('selection.data: %s', selected) |