Use correct types in QResource.
qHash() returns uint, not int, so change all interactions with hashing to use uint to match. This blocks the introduction of a new (better) hashing algorithm because it currently breaks numerous tests: rcc would (correctly) write a uint hash value to the qrc files, but QResource would attempt to mangle it around as an int. This wasn't a problem with the old hash, because it deliberately threw away data (h &= 0x0fffffff), possibly because of someone not being able to diagnose precisly this problem. Change-Id: I46fb42acc100fdd3bedd714f6dc91aeca91d0351 Reviewed-by: hjk <qthjk@ovi.com>
This commit is contained in:
parent
ab05682564
commit
db5c28fa0e
@ -114,7 +114,7 @@ class QResourceRoot
|
|||||||
};
|
};
|
||||||
const uchar *tree, *names, *payloads;
|
const uchar *tree, *names, *payloads;
|
||||||
inline int findOffset(int node) const { return node * 14; } //sizeof each tree element
|
inline int findOffset(int node) const { return node * 14; } //sizeof each tree element
|
||||||
int hash(int node) const;
|
uint hash(int node) const;
|
||||||
QString name(int node) const;
|
QString name(int node) const;
|
||||||
short flags(int node) const;
|
short flags(int node) const;
|
||||||
public:
|
public:
|
||||||
@ -594,7 +594,7 @@ QResource::searchPaths()
|
|||||||
return *resourceSearchPaths();
|
return *resourceSearchPaths();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline int QResourceRoot::hash(int node) const
|
inline uint QResourceRoot::hash(int node) const
|
||||||
{
|
{
|
||||||
if(!node) //root
|
if(!node) //root
|
||||||
return 0;
|
return 0;
|
||||||
@ -673,13 +673,13 @@ int QResourceRoot::findNode(const QString &_path, const QLocale &locale) const
|
|||||||
qDebug() << " " << child+j << " :: " << name(child+j);
|
qDebug() << " " << child+j << " :: " << name(child+j);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
const int h = qHash(segment);
|
const uint h = qHash(segment);
|
||||||
|
|
||||||
//do the binary search for the hash
|
//do the binary search for the hash
|
||||||
int l = 0, r = child_count-1;
|
int l = 0, r = child_count-1;
|
||||||
int sub_node = (l+r+1)/2;
|
int sub_node = (l+r+1)/2;
|
||||||
while(r != l) {
|
while(r != l) {
|
||||||
const int sub_node_hash = hash(child+sub_node);
|
const uint sub_node_hash = hash(child+sub_node);
|
||||||
if(h == sub_node_hash)
|
if(h == sub_node_hash)
|
||||||
break;
|
break;
|
||||||
else if(h < sub_node_hash)
|
else if(h < sub_node_hash)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user