6569: transferring from the clipboard causes gramps40 svn 21740 to crash

svn: r21783
This commit is contained in:
Benny Malengier 2013-03-28 13:53:52 +00:00
parent 591f695bc9
commit 3783a8039b

View File

@ -209,6 +209,10 @@ class ClipWrapper(object):
return self._dbname
def pack(self):
"""
Return a byte string that can be packed in a GtkSelectionData
structure
"""
if not self.is_valid():
data = list(pickle.loads(self._pickle))
data[2] = {
@ -224,12 +228,19 @@ class ClipWrapper(object):
}
return pickle.dumps(data)
else:
if sys.version_info[0] < 3:
return str(self._obj)
else:
if isinstance(self._obj, bytes):
return self._obj
else:
## don't know if this happens in Gramps, theoretically possible
asuni = str(self._obj)
return asuni.encode('utf-8')
def is_valid(self):
return True
class ClipHandleWrapper(ClipWrapper):
def __init__(self,dbstate, obj):