From a070127d1dd4296e4c26d7129e9f0867591298ef Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 13 May 2011 10:09:45 -0600 Subject: [PATCH] Fix one source of segfaults on shutdown in the linux binaries. Minor fixes. --- setup/installer/linux/util.c | 11 ++++++----- src/calibre/ebooks/oeb/reader.py | 6 +++++- src/calibre/gui2/actions/store.py | 2 +- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/setup/installer/linux/util.c b/setup/installer/linux/util.c index dfbaaef62c..b06d6083c9 100644 --- a/setup/installer/linux/util.c +++ b/setup/installer/linux/util.c @@ -30,11 +30,12 @@ int report_libc_error(const char *msg) { } int pyobject_to_int(PyObject *res) { - int ret; PyObject *tmp; - tmp = PyNumber_Int(res); - if (tmp == NULL) ret = (PyObject_IsTrue(res)) ? 1 : 0; - else ret = (int)PyInt_AS_LONG(tmp); - + int ret = 0; PyObject *tmp; + if (res != NULL) { + tmp = PyNumber_Int(res); + if (tmp == NULL) ret = (PyObject_IsTrue(res)) ? 1 : 0; + else ret = (int)PyInt_AS_LONG(tmp); + } return ret; } diff --git a/src/calibre/ebooks/oeb/reader.py b/src/calibre/ebooks/oeb/reader.py index 6c10436038..422252f73e 100644 --- a/src/calibre/ebooks/oeb/reader.py +++ b/src/calibre/ebooks/oeb/reader.py @@ -191,7 +191,11 @@ class OEBReader(object): if not scheme and href not in known: new.add(href) elif item.media_type in OEB_STYLES: - for url in cssutils.getUrls(item.data): + try: + urls = list(cssutils.getUrls(item.data)) + except: + urls = [] + for url in urls: href, _ = urldefrag(url) href = item.abshref(urlnormalize(href)) scheme = urlparse(href).scheme diff --git a/src/calibre/gui2/actions/store.py b/src/calibre/gui2/actions/store.py index 9c30a9beb1..1f1130836c 100644 --- a/src/calibre/gui2/actions/store.py +++ b/src/calibre/gui2/actions/store.py @@ -53,7 +53,7 @@ class StoreAction(InterfaceAction): if self.gui.current_view() is self.gui.library_view: author = self.gui.library_view.model().authors(row) if author: - author = author.replace('|', ',') + author = author.replace('|', ' ') else: mi = self.gui.current_view().model().get_book_display_info(row) author = ' & '.join(mi.authors)