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
|
# live css
|
||||||
# check that clicking on both internal and external links works
|
# check that clicking on both internal and external links works
|
||||||
|
|
||||||
import json
|
|
||||||
import textwrap
|
import textwrap
|
||||||
import time
|
import time
|
||||||
from collections import defaultdict
|
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.webengine import create_script, insert_scripts, secure_webengine
|
||||||
from calibre.gui2.widgets2 import HistoryLineEdit2
|
from calibre.gui2.widgets2 import HistoryLineEdit2
|
||||||
from calibre.utils.ipc.simple_worker import offload_worker
|
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.queue import Empty, Queue
|
||||||
from polyglot.urllib import urlparse
|
from polyglot.urllib import urlparse
|
||||||
|
|
||||||
@ -293,10 +292,11 @@ class Bridge(QObject):
|
|||||||
def __init__(self, parent=None):
|
def __init__(self, parent=None):
|
||||||
QObject.__init__(self, parent)
|
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):
|
def request_sync(self, tag_name, href, sourceline_address):
|
||||||
|
address = [sourceline_address[0].toInt(), [x.toString() for x in sourceline_address[1].toArray()]]
|
||||||
try:
|
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):
|
except (TypeError, ValueError, OverflowError, AttributeError):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -142,7 +142,7 @@ INHERITED_PROPS = { # {{{
|
|||||||
|
|
||||||
|
|
||||||
def get_sourceline_address(node):
|
def get_sourceline_address(node):
|
||||||
sourceline = parseInt(node.getAttribute('data-lnum'))
|
sourceline = parseInt(node.dataset.lnum)
|
||||||
tags = v'[]'
|
tags = v'[]'
|
||||||
for elem in document.querySelectorAll(f'[data-lnum="{sourceline}"]'):
|
for elem in document.querySelectorAll(f'[data-lnum="{sourceline}"]'):
|
||||||
tags.push(elem.tagName.toLowerCase())
|
tags.push(elem.tagName.toLowerCase())
|
||||||
@ -340,7 +340,7 @@ class PreviewIntegration:
|
|||||||
tn = e.tagName.toLowerCase() if e.tagName else ''
|
tn = e.tagName.toLowerCase() if e.tagName else ''
|
||||||
href = e.getAttribute('href')
|
href = e.getAttribute('href')
|
||||||
e = e.parentNode
|
e = e.parentNode
|
||||||
self.bridge.request_sync(tn, href, JSON.stringify(address))
|
self.bridge.request_sync(tn, href, address)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def go_to_anchor(self, anchor):
|
def go_to_anchor(self, anchor):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user