From a47273f7b811a18b5dcb1ffdbf78f6f1243d6a1c Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 29 Apr 2010 20:40:18 -0600 Subject: [PATCH] E-book viewer: Use the Qt API to set document padding during next page operation, instead of javascript. Fixes #5343 (Preview EPUB "crashes" when PgDwn is used) --- src/calibre/gui2/viewer/documentview.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/calibre/gui2/viewer/documentview.py b/src/calibre/gui2/viewer/documentview.py index 3e7f7536d4..a1ecf14dfd 100644 --- a/src/calibre/gui2/viewer/documentview.py +++ b/src/calibre/gui2/viewer/documentview.py @@ -394,13 +394,14 @@ class Document(QWebPage): return self.mainFrame().contentsSize().width() # offsetWidth gives inaccurate results def set_bottom_padding(self, amount): - padding = '%dpx'%amount - try: - old_padding = unicode(self.javascript('$("body").css("padding-bottom")').toString()) - except: - old_padding = '' + body = self.mainFrame().documentElement().findFirst('body') + if body.isNull(): + return + old_padding = unicode(body.styleProperty('padding-bottom', + body.ComputedStyle)).strip() + padding = u'%dpx'%amount if old_padding != padding: - self.javascript('$("body").css("padding-bottom", "%s")' % padding) + body.setStyleProperty('padding-bottom', padding + ' !important') class EntityDeclarationProcessor(object):