From ef4fa0b843ed04cb9c65fb81ba875134944f0371 Mon Sep 17 00:00:00 2001 From: Charles Haley <> Date: Tue, 29 Jun 2010 10:21:07 +0100 Subject: [PATCH 1/3] Fix problem caused by JSON using unbuffered writes --- src/calibre/devices/usbms/driver.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/calibre/devices/usbms/driver.py b/src/calibre/devices/usbms/driver.py index a4d9486e68..377ec36c16 100644 --- a/src/calibre/devices/usbms/driver.py +++ b/src/calibre/devices/usbms/driver.py @@ -290,7 +290,7 @@ class USBMS(CLI, Device): js = [item.to_json() for item in booklists[listid] if hasattr(item, 'to_json')] with open(self.normalize_path(os.path.join(prefix, self.METADATA_CACHE)), 'wb') as f: - json.dump(js, f, indent=2, encoding='utf-8') + f.write(json.dumps(js, indent=2, encoding='utf-8')) write_prefix(self._main_prefix, 0) write_prefix(self._card_a_prefix, 1) write_prefix(self._card_b_prefix, 2) From 7beba1d6867ad11e7b8f99175057df337bdb1d5b Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 29 Jun 2010 08:00:15 -0600 Subject: [PATCH 2/3] No longer mark connect to iTunes as experimental --- src/calibre/gui2/device.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/calibre/gui2/device.py b/src/calibre/gui2/device.py index 584796231a..c5e042d3e3 100644 --- a/src/calibre/gui2/device.py +++ b/src/calibre/gui2/device.py @@ -495,7 +495,7 @@ class DeviceMenu(QMenu): # {{{ self.connect_to_folder_action = mitem mitem = self.addAction(QIcon(I('devices/itunes.png')), - _('Connect to iTunes (EXPERIMENTAL)')) + _('Connect to iTunes')) mitem.setEnabled(True) mitem.triggered.connect(lambda x : self.connect_to_itunes.emit()) self.connect_to_itunes_action = mitem From 9b9176866562d4f63380a27ddaec63effffb96d6 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 29 Jun 2010 21:29:31 -0600 Subject: [PATCH 3/3] Upgrade podofo to 0.8.1 from 0.7.0 --- setup/installer/linux/freeze.py | 2 +- setup/installer/osx/app/main.py | 5 ++- setup/installer/windows/notes.rst | 47 ++++++++++++++++++++++-- setup/installer/windows/wix-template.xml | 10 +---- src/calibre/utils/podofo/podofo.cpp | 7 +++- 5 files changed, 55 insertions(+), 16 deletions(-) diff --git a/setup/installer/linux/freeze.py b/setup/installer/linux/freeze.py index 7353134393..08237b83fa 100644 --- a/setup/installer/linux/freeze.py +++ b/setup/installer/linux/freeze.py @@ -46,7 +46,7 @@ class LinuxFreeze(Command): '/usr/lib/libsqlite3.so.0', '/usr/lib/libsqlite3.so.0', '/usr/lib/libmng.so.1', - '/usr/lib/libpodofo.so.0.6.99', + '/usr/lib/libpodofo.so.0.8.1', '/lib/libz.so.1', '/lib/libuuid.so.1', '/usr/lib/libtiff.so.3', diff --git a/setup/installer/osx/app/main.py b/setup/installer/osx/app/main.py index 5b01c8503c..c95be6752c 100644 --- a/setup/installer/osx/app/main.py +++ b/setup/installer/osx/app/main.py @@ -265,6 +265,9 @@ class Py2App(object): @flush def get_local_dependencies(self, path_to_lib): for x in self.get_dependencies(path_to_lib): + if x.startswith('libpodofo'): + yield x, x + continue for y in (SW+'/lib/', '/usr/local/lib/', SW+'/qt/lib/', '/opt/local/lib/', '/Library/Frameworks/Python.framework/', SW+'/freetype/lib/'): @@ -397,7 +400,7 @@ class Py2App(object): @flush def add_podofo(self): info('\nAdding PoDoFo') - pdf = join(SW, 'lib', 'libpodofo.0.6.99.dylib') + pdf = join(SW, 'lib', 'libpodofo.0.8.1.dylib') self.install_dylib(pdf) @flush diff --git a/setup/installer/windows/notes.rst b/setup/installer/windows/notes.rst index 0fdecda27c..cd02c80d2e 100644 --- a/setup/installer/windows/notes.rst +++ b/setup/installer/windows/notes.rst @@ -162,9 +162,50 @@ SET(WANT_LIB64 FALSE) SET(PODOFO_BUILD_SHARED TRUE) SET(PODOFO_BUILD_STATIC FALSE) -cp build/podofo-0.7.0/build/src/Release/podofo.dll bin/ -cp build/podofo-0.7.0/build/src/Release/podofo.lib lib/ -cp build/podofo-0.7.0/build/src/Release/podofo.exp lib/ +cp build/podofo/build/src/Release/podofo.dll bin/ +cp build/podofo/build/src/Release/podofo.lib lib/ +cp build/podofo/build/src/Release/podofo.exp lib/ + +cp build/podofo/build/podofo_config.h include/podofo/ +cp -r build/podofo/src/* include/podofo/ + +The following patch was required to get it to compile: + +Index: src/PdfImage.cpp +=================================================================== +--- src/PdfImage.cpp (revision 1261) ++++ src/PdfImage.cpp (working copy) +@@ -627,7 +627,7 @@ + + long lLen = static_cast(pInfo->rowbytes * height); + char* pBuffer = static_cast(malloc(sizeof(char) * lLen)); +- png_bytep pRows[height]; ++ png_bytepp pRows = static_cast(malloc(sizeof(png_bytep)*height)); + for(int y=0; y(pBuffer + (y * pInfo->rowbytes)); +@@ -672,6 +672,7 @@ + this->SetImageData( width, height, pInfo->bit_depth, &stream ); + + free(pBuffer); ++ free(pRows); + } + #endif // PODOFO_HAVE_PNG_LIB + +Index: src/PdfFiltersPrivate.cpp +=================================================================== +--- src/PdfFiltersPrivate.cpp (revision 1261) ++++ src/PdfFiltersPrivate.cpp (working copy) +@@ -1019,7 +1019,7 @@ + /* + * Prepare for input from a memory buffer. + */ +-GLOBAL(void) ++void + jpeg_memory_src (j_decompress_ptr cinfo, const JOCTET * buffer, size_t bufsize) + { + my_src_ptr src; + ImageMagick -------------- diff --git a/setup/installer/windows/wix-template.xml b/setup/installer/windows/wix-template.xml index 17976783aa..37dd8b25a8 100644 --- a/setup/installer/windows/wix-template.xml +++ b/setup/installer/windows/wix-template.xml @@ -153,18 +153,10 @@ - - - + - - - - - - diff --git a/src/calibre/utils/podofo/podofo.cpp b/src/calibre/utils/podofo/podofo.cpp index 8766b709c9..d88e71628d 100644 --- a/src/calibre/utils/podofo/podofo.cpp +++ b/src/calibre/utils/podofo/podofo.cpp @@ -164,7 +164,7 @@ podofo_convert_pystring(PyObject *py) { Py_UNICODE* u = PyUnicode_AS_UNICODE(py); PyObject *u8 = PyUnicode_EncodeUTF8(u, PyUnicode_GET_SIZE(py), "replace"); if (u8 == NULL) { PyErr_NoMemory(); return NULL; } - pdf_utf8 *s8 = (pdf_utf8 *)PyString_AS_STRING(u8); + pdf_utf8 *s8 = reinterpret_cast(PyString_AS_STRING(u8)); PdfString *ans = new PdfString(s8); Py_DECREF(u8); if (ans == NULL) PyErr_NoMemory(); @@ -219,9 +219,10 @@ podofo_PDFDoc_setter(podofo_PDFDoc *self, PyObject *val, int field) { PyErr_SetString(PyExc_Exception, "You must first load a PDF Document"); return -1; } - PdfString *s = podofo_convert_pystring(val); if (s == NULL) return -1; + + switch (field) { case 0: info->SetTitle(*s); break; @@ -240,7 +241,9 @@ podofo_PDFDoc_setter(podofo_PDFDoc *self, PyObject *val, int field) { return -1; } + self->doc->set_info(info); + return 0; }