On 28 Jan 2008, at 10:53 pm, Kristian Høgsberg wrote:
On Jan 28, 2008 5:20 PM, Albert Astals Cid <[EMAIL PROTECTED]> wrote:
A Dilluns 28 Gener 2008, Jonathan Kew va escriure:
The document saving code in the Qt4 wrapper uses open_memstream(),
which is not available on all platforms. I would recommend using
vasprintf() instead, which I suspect is more widely supported, but
this is also a GNU extension and may not be available everywhere. So
a fallback approach using vsnprintf() is also needed.
Proposed changes below....
I'll let Pino comment on that, but he is travelling so it'll take
a while.
I'll weigh in though and say that using open_memstream() isn't
acceptable, it's very GNU Libc specific. Also, the suggested patch
has the same problems as the strndup() patch. I'm sure there is a
helper function in Qt to create a dynamically allocated string from a
printf-style string, that would be the way to go.
Attached is a revised (and simplified) version of the patch,
abandoning open_memstream() etc in favor of QString::vsprintf(),
which seems to be the Qt4 way to do this.
I suppose this means that the string is being (unnecessarily)
converted to and from Unicode, which may introduce a little overhead,
but I doubt this is a performance-critical point.
JK
diff --git a/qt4/src/poppler-qiodeviceoutstream.cc
b/qt4/src/poppler-qiodeviceoutstream.cc
index 11fab97..4716952 100644
--- a/qt4/src/poppler-qiodeviceoutstream.cc
+++ b/qt4/src/poppler-qiodeviceoutstream.cc
@@ -58,14 +58,11 @@ void QIODeviceOutStream::printf(const char *format, ...)
{
va_list ap;
va_start(ap, format);
- char* buf = 0;
- size_t bufsize = 0;
- FILE* stream = open_memstream(&buf, &bufsize);
- vfprintf(stream, format, ap);
+ QString s;
+ s.vsprintf(format, ap);
va_end(ap);
- fclose(stream);
- m_device->write(buf, bufsize);
- free(buf);
+ QByteArray ba = s.toAscii();
+ m_device->write(ba.constData(), ba.size());
}
}
_______________________________________________
poppler mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/poppler