KoXmlWriter::addCompleteElement leaves device open

David Faure faure at kde.org
Fri Feb 4 22:17:57 GMT 2011


I was surprised that the following code (which I'm working on for the applix 
filter) ...

            paragraphBuffer.close();
 
            bodyWriter->startElement("text:p");
            bodyWriter->addAttribute("text:style-name", autoStyleName);
            bodyWriter->addCompleteElement(&paragraphBuffer);
            bodyWriter->endElement(); // text:p

            paragraphBuffer.setData(QByteArray());

... would fail in QBuffer::setData with "can't do that while the buffer is 
open".

Turns out that addCompleteElement opens the iodevice, but doesn't close it
afterwards -- blame me, I wrote that code long ago ;)

Can I commit the attached patch?
I had a look at the existing callers of addCompleteElement (some of them -- 
there are many many more than I thought there would be!), and it seems to be 
always a one-time buffer. And if it was reused, then a second close() won't 
hurt.

-- 
David Faure, faure at kde.org, http://www.davidfaure.fr
Sponsored by Nokia to work on KDE, incl. Konqueror (http://www.konqueror.org).
-------------- next part --------------
A non-text attachment was scrubbed...
Name: koxmlwriter.diff
Type: text/x-patch
Size: 987 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/calligra-devel/attachments/20110204/eef563f5/attachment.bin>


More information about the calligra-devel mailing list