mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-06-23 15:30:45 -04:00
Avoind double serialization of sourceline address
This commit is contained in:
parent
37c277d684
commit
cae36d2cc1
@ -7,7 +7,6 @@ from __future__ import absolute_import, division, print_function, unicode_litera
|
||||
# live css
|
||||
# check that clicking on both internal and external links works
|
||||
|
||||
import json
|
||||
import textwrap
|
||||
import time
|
||||
from collections import defaultdict
|
||||
@ -35,7 +34,7 @@ from calibre.gui2.tweak_book import TOP, actions, current_container, editors, tp
|
||||
from calibre.gui2.webengine import create_script, insert_scripts, secure_webengine
|
||||
from calibre.gui2.widgets2 import HistoryLineEdit2
|
||||
from calibre.utils.ipc.simple_worker import offload_worker
|
||||
from polyglot.builtins import native_string_type, unicode_type
|
||||
from polyglot.builtins import unicode_type
|
||||
from polyglot.queue import Empty, Queue
|
||||
from polyglot.urllib import urlparse
|
||||
|
||||
@ -293,10 +292,11 @@ class Bridge(QObject):
|
||||
def __init__(self, parent=None):
|
||||
QObject.__init__(self, parent)
|
||||
|
||||
@pyqtSlot(native_string_type, native_string_type, native_string_type)
|
||||
@pyqtSlot('QString', 'QString', 'QJsonArray')
|
||||
def request_sync(self, tag_name, href, sourceline_address):
|
||||
address = [sourceline_address[0].toInt(), [x.toString() for x in sourceline_address[1].toArray()]]
|
||||
try:
|
||||
self.sync_requested.emit(unicode_type(tag_name), unicode_type(href), json.loads(unicode_type(sourceline_address)))
|
||||
self.sync_requested.emit(tag_name, href, address)
|
||||
except (TypeError, ValueError, OverflowError, AttributeError):
|
||||
pass
|
||||
|
||||
|
@ -142,7 +142,7 @@ INHERITED_PROPS = { # {{{
|
||||
|
||||
|
||||
def get_sourceline_address(node):
|
||||
sourceline = parseInt(node.getAttribute('data-lnum'))
|
||||
sourceline = parseInt(node.dataset.lnum)
|
||||
tags = v'[]'
|
||||
for elem in document.querySelectorAll(f'[data-lnum="{sourceline}"]'):
|
||||
tags.push(elem.tagName.toLowerCase())
|
||||
@ -340,7 +340,7 @@ class PreviewIntegration:
|
||||
tn = e.tagName.toLowerCase() if e.tagName else ''
|
||||
href = e.getAttribute('href')
|
||||
e = e.parentNode
|
||||
self.bridge.request_sync(tn, href, JSON.stringify(address))
|
||||
self.bridge.request_sync(tn, href, address)
|
||||
return False
|
||||
|
||||
def go_to_anchor(self, anchor):
|
||||
|
Loading…
x
Reference in New Issue
Block a user