Changeset 846 for trunk/src/gui/image/qxbmhandler.cpp
- Timestamp:
- May 5, 2011, 5:36:53 AM (14 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
/branches/vendor/nokia/qt/4.7.2 (added) merged: 845 /branches/vendor/nokia/qt/current merged: 844 /branches/vendor/nokia/qt/4.6.3 removed
- Property svn:mergeinfo changed
-
trunk/src/gui/image/qxbmhandler.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 201 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation ([email protected]) … … 67 67 { 68 68 const int buflen = 300; 69 69 70 char buf[buflen + 1]; 70 71 QRegExp r1(QLatin1String("^#define[ \t]+[a-zA-Z0-9._]+[ \t]+")); … … 72 73 73 74 qint64 readBytes = 0; 74 75 // "#define .._width <num>" 76 readBytes = device->readLine(buf, buflen); 77 if (readBytes <= 0) 78 return false; 79 buf[readBytes - 1] = '\0'; 75 qint64 totalReadBytes = 0; 76 77 buf[0] = '\0'; 80 78 81 79 // skip initial comment, if any 82 while (buf[0] != '#' && (readBytes = device->readLine( buf, buflen )) > 0) {} 83 84 if (readBytes <= 0) 85 return false; 80 while (buf[0] != '#') { 81 readBytes = device->readLine(buf, buflen); 82 83 // if readBytes >= buflen, it's very probably not a C file 84 if (readBytes <= 0 || readBytes >= buflen -1) 85 return false; 86 87 // limit xbm headers to the first 4k in the file to prevent 88 // excessive reads on non-xbm files 89 totalReadBytes += readBytes; 90 if (totalReadBytes >= maxlen) 91 return false; 92 } 93 86 94 buf[readBytes - 1] = '\0'; 87 95 QString sbuf; 88 96 sbuf = QString::fromLatin1(buf); 89 97 98 90 99 if (r1.indexIn(sbuf) == 0 && 91 100 r2.indexIn(sbuf, r1.matchedLength()) == r1.matchedLength()) … … 262 271 bool QXbmHandler::canRead() const 263 272 { 264 if (state == Ready) { 265 if (!canRead(device())) 266 return false; 273 if (state == Ready && !canRead(device())) 274 return false; 275 276 if (state != Error) { 267 277 setFormat("xbm"); 268 278 return true; 269 279 } 270 return state != Error; 280 281 return false; 271 282 } 272 283
Note:
See TracChangeset
for help on using the changeset viewer.