1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
$NetBSD: patch-aa,v 1.21 2010/10/29 09:28:13 wiz Exp $
Three fixes from upstream:
BPM bugfix for FLAC fils, amarok commit ce57e426.
Re-add some tests for unprintable but also invalid chars. Apparently
Qt's XML classes don't properly check for invalid chars when writing
XML, even if you tel l them to. Also switch to QXmlStreamWriter,
as apparently going forward it is the more supported class. BUG:
251762, commmit 79d86829294ac54132c01153660e70e30c15c378 (I think).
Fix for previous from
http://gitweb.kde.org/amarok.git/blobdiff_plain/0b8577293698f88f2c6e5a1661ba570d0dd264b5..182f39c15575c3c1ce2b0425f9e3ec5997f3a9fd:/utilities/collectionscanner/CollectionScanner.cpp
--- utilities/collectionscanner/CollectionScanner.cpp.orig 2010-09-24 09:21:46.000000000 +0000
+++ utilities/collectionscanner/CollectionScanner.cpp
@@ -37,13 +37,13 @@
#include <QByteArray>
#include <QDBusReply>
#include <QDir>
-#include <QDomDocument>
#include <QFile>
#include <QtDebug>
#include <QTextCodec>
#include <QTextStream>
#include <QTimer>
#include <QThread>
+#include <QXmlStreamWriter>
//Taglib:
#include <apetag.h>
@@ -814,8 +814,10 @@ CollectionScanner::readTags( const QStri
void
CollectionScanner::writeElement( const QString &name, const AttributeHash &attributes )
{
- QDomDocument doc; // A dummy. We don't really use DOM, but SAX2
- QDomElement element = doc.createElement( name );
+ QString text;
+ QXmlStreamWriter writer( &text );
+
+ writer.writeStartElement( name );
QHashIterator<QString, QString> it( attributes );
while( it.hasNext() )
@@ -829,7 +831,15 @@ CollectionScanner::writeElement( const Q
bool noCategory = false;
for( unsigned i = 0; i < len; i++ )
{
- if( data[i].category() == QChar::NoCategory )
+ if( data[i].category() == QChar::NoCategory ||
+ data[i].category() == QChar::Other_Surrogate ||
+ (
+ data[i].unicode() < 32 &&
+ data[i].unicode() != 9 &&
+ data[i].unicode() != 10 &&
+ data[i].unicode() != 13
+ )
+ )
{
noCategory = true;
break;
@@ -838,15 +848,12 @@ CollectionScanner::writeElement( const Q
if( noCategory )
continue;
-
- element.setAttribute( it.key(), it.value() );
+ writer.writeAttribute( it.key(), it.value() );
}
- QString text;
- QTextStream stream( &text, QIODevice::WriteOnly );
- element.save( stream, 0 );
+ writer.writeEndElement();
- std::cout << text.toUtf8().data() << std::endl;
+ std::cout << text.toUtf8().data() << std::endl << std::endl;
}
// taken verbatim from Qt's sources, since it's stupidly in the QtGui module
|