summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorJarek Kobus <jkobus@trolltech.com>2010-12-09 14:20:36 (GMT)
committerJarek Kobus <jkobus@trolltech.com>2010-12-09 14:20:36 (GMT)
commitfcd578e713a5a1c165ff78bab98487185a9f4d15 (patch)
tree7aaf2b35d0ee5eb74261f90ec1eba37b593a9c01 /tools
parent4ecc45086102807901a3bd2b9e02a169ca212716 (diff)
downloadQt-fcd578e713a5a1c165ff78bab98487185a9f4d15.zip
Qt-fcd578e713a5a1c165ff78bab98487185a9f4d15.tar.gz
Qt-fcd578e713a5a1c165ff78bab98487185a9f4d15.tar.bz2
Watch qrc files also when they are empty
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com> Task-number: QTCREATORBUG-825
Diffstat (limited to 'tools')
-rw-r--r--tools/designer/src/lib/shared/qtresourcemodel.cpp50
1 files changed, 27 insertions, 23 deletions
diff --git a/tools/designer/src/lib/shared/qtresourcemodel.cpp b/tools/designer/src/lib/shared/qtresourcemodel.cpp
index e3fc805..d04a5fc 100644
--- a/tools/designer/src/lib/shared/qtresourcemodel.cpp
+++ b/tools/designer/src/lib/shared/qtresourcemodel.cpp
@@ -184,15 +184,15 @@ const QByteArray *QtResourceModelPrivate::createResource(const QString &path, QS
break;
// return code cannot be fully trusted, might still be empty
const ResourceDataFileMap resMap = library.resourceDataFileMap();
- if (resMap.empty())
- break;
-
if (!library.output(buffer, errorDevice))
break;
*errorCount = library.failedResources().size();
*contents = resMap.keys();
+ if (resMap.empty())
+ break;
+
buffer.close();
rc = new QByteArray(buffer.data());
} while (false);
@@ -225,15 +225,18 @@ void QtResourceModelPrivate::registerResourceSet(QtResourceSet *resourceSet)
qDebug() << "registerResourceSet " << path;
const PathDataMap::const_iterator itRcc = m_pathToData.constFind(path);
if (itRcc != m_pathToData.constEnd()) { // otherwise data was not created yet
- if (!QResource::registerResource(reinterpret_cast<const uchar *>(itRcc.value()->constData()))) {
- qDebug() << "** WARNING: Failed to register " << path << " (QResource failure).";
- } else {
- QStringList contents = m_pathToContents.value(path);
- QStringListIterator itContents(contents);
- while (itContents.hasNext()) {
- const QString filePath = itContents.next();
- if (!m_fileToQrc.contains(filePath)) // the first loaded resource has higher priority in qt resource system
- m_fileToQrc.insert(filePath, path);
+ const QByteArray *data = itRcc.value();
+ if (data) {
+ if (!QResource::registerResource(reinterpret_cast<const uchar *>(data->constData()))) {
+ qWarning() << "** WARNING: Failed to register " << path << " (QResource failure).";
+ } else {
+ QStringList contents = m_pathToContents.value(path);
+ QStringListIterator itContents(contents);
+ while (itContents.hasNext()) {
+ const QString filePath = itContents.next();
+ if (!m_fileToQrc.contains(filePath)) // the first loaded resource has higher priority in qt resource system
+ m_fileToQrc.insert(filePath, path);
+ }
}
}
}
@@ -254,8 +257,11 @@ void QtResourceModelPrivate::unregisterResourceSet(QtResourceSet *resourceSet)
qDebug() << "unregisterResourceSet " << path;
const PathDataMap::const_iterator itRcc = m_pathToData.constFind(path);
if (itRcc != m_pathToData.constEnd()) { // otherwise data was not created yet
- if (!QResource::unregisterResource(reinterpret_cast<const uchar *>(itRcc.value()->constData())))
- qDebug() << "** WARNING: Failed to unregister " << path << " (QResource failure).";
+ const QByteArray *data = itRcc.value();
+ if (data) {
+ if (!QResource::unregisterResource(reinterpret_cast<const uchar *>(itRcc.value()->constData())))
+ qWarning() << "** WARNING: Failed to unregister " << path << " (QResource failure).";
+ }
}
}
m_fileToQrc.clear();
@@ -292,15 +298,13 @@ void QtResourceModelPrivate::activate(QtResourceSet *resourceSet, const QStringL
QStringList contents;
int qrcErrorCount;
generatedCount++;
- if (const QByteArray *data = createResource(path, &contents, &qrcErrorCount, errorStream)) {
- newPathToData.insert(path, data);
- if (qrcErrorCount) // Count single failed files as sort of 1/2 error
- errorCount++;
- addWatcher(path);
- } else {
- newPathToData.remove(path);
+ const QByteArray *data = createResource(path, &contents, &qrcErrorCount, errorStream);
+
+ newPathToData.insert(path, data);
+ if (qrcErrorCount) // Count single failed files as sort of 1/2 error
errorCount++;
- }
+ addWatcher(path);
+
m_pathToModified.insert(path, false);
m_pathToContents.insert(path, contents);
newResourceSetChanged = true;
@@ -326,7 +330,7 @@ void QtResourceModelPrivate::activate(QtResourceSet *resourceSet, const QStringL
QListIterator<const QByteArray *> itOld(oldData);
if (itOld.hasNext()) {
const QByteArray *array = itOld.next();
- if (!newData.contains(array))
+ if (array && !newData.contains(array))
toDelete.append(array);
}