[Qt-interest] buggy QDomElement
Thiago Macieira
thiago.macieira at trolltech.com
Mon May 4 21:29:20 CEST 2009
Em Segunda-feira 04 Maio 2009, às 21:16:40, Pascal Patry escreveu:
> This piece of code fails in Qt 4.5.x:
>
> ====
> QDomElement elem;
> QString tag = "test";
> elem.setTagName(tag);
> assert(elem.tagName() == tag);
> assert(elem.nodeName() == tag);
> ====
>
> This used to work prior to Qt 4.5.
No, it didn't:
$ ldd ./domtest | grep QtXml
libQtXml.so.4 => /home/tmacieir/obj/troll/qt-4.4.0/lib/libQtXml.so.4
(0xb805d000)
$ ./domtest
domtest: /tmp/domtest/main.cpp:9: int main(): Assertion `elem.tagName() ==
tag' failed.
zsh: abort ./domtest
$ ldd ./domtest | grep QtXml
libQtXml.so.4 => /home/tmacieir/obj/troll/qt-4.3.5/lib/libQtXml.so.4
(0xb8037000)
$ ./domtest
domtest: /tmp/domtest/main.cpp:9: int main(): Assertion `elem.tagName() ==
tag' failed.
zsh: abort ./domtest
> The documentation states:
> "[...]
> QDomElement::QDomElement ()
>
> Constructs an empty element. Use the QDomDocument::createElement()
> function to construct elements with content.
> [...]"
It's working exactly as described by the documentation you quoted:
- If you create a QDomElement on the stack like you did, it's empty (forever)
- If you want to have elements with content, you have to use createElement().
--
Thiago Macieira - thiago.macieira (AT) nokia.com
Senior Product Manager - Nokia, Qt Software
Sandakerveien 116, NO-0402 Oslo, Norway
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part.
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090504/cbee8c58/attachment.bin
More information about the Qt-interest-old
mailing list