summaryrefslogtreecommitdiffstats
path: root/tools/designer/src/lib/shared/qtresourcemodel.cpp
diff options
context:
space:
mode:
authorShane Kearns <shane.kearns@accenture.com>2010-12-15 14:34:35 (GMT)
committerShane Kearns <shane.kearns@accenture.com>2010-12-15 14:34:35 (GMT)
commitc50ef702872ee7adf8860bf164be6d092d8bde0f (patch)
tree0359d427ef4d67323bae485f5d3118e5b4564469 /tools/designer/src/lib/shared/qtresourcemodel.cpp
parent4d86bacafad3b12ca01c20988bf578cde7bf3dae (diff)
parent567bcd38dd7a749ac0bc3cdd2432798ab1af74fe (diff)
downloadQt-c50ef702872ee7adf8860bf164be6d092d8bde0f.zip
Qt-c50ef702872ee7adf8860bf164be6d092d8bde0f.tar.gz
Qt-c50ef702872ee7adf8860bf164be6d092d8bde0f.tar.bz2
Merge remote branch 'qt/master' into symbian-socket-engine
Diffstat (limited to 'tools/designer/src/lib/shared/qtresourcemodel.cpp')
-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);
}