Handle not found when copying source from the (#1175)

Citation tree

Fixes #12170
This commit is contained in:
Serge Noiraud 2021-02-19 18:25:02 +01:00 committed by GitHub
parent 14c2d0e1b6
commit b6fa5da8ee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -471,6 +471,7 @@ class ClipCitation(ClipHandleWrapper):
def refresh(self):
if self._handle:
try:
citation = clipdb.get_citation_from_handle(self._handle)
if citation:
self._title = citation.get_gramps_id()
@ -489,9 +490,17 @@ class ClipCitation(ClipHandleWrapper):
text = str(text)
if len(text) > 60:
text = text[:60] + "..."
self._value = _("Volume/Page: %(pag)s -- %(sourcetext)s") % {
'pag' : page,
self._value = _("Volume/Page: %(pag)s -- %(sourcetext)s"
) % { 'pag' : page,
'sourcetext' : text}
except:
# We are in the Source tree view. The shortcuts only
# work for citations.
print("We cannot copy the source from this view."
" Use drag and drop.")
self._title = self._value = ''
self._pickle = self._type = self._objclass = None
self._handle = self._dbid = self._dbname = None
class ClipRepoRef(ClipObjWrapper):
@ -1281,6 +1290,14 @@ class ClipboardListView:
model.insert_before(node, data)
else:
model.insert_after(node, data)
elif isinstance(data[1], ClipCitation):
if data[3]:
# we have a real citation
model.append(data)
#else:
# We are in a Source treeview and trying
# to copy a source with a shortcut.
# Use drag and drop to do that.
else:
model.append(data)