I'm trying to get my app in development to load a bunch of static data on startup, for which i'm using a namespaced static QMap, but every time I call on the contents of it it turns out to be empty.
This is in the main file:
void kreator::loadData() {
//QFile xmlFile;
// load natures;
ExaltedData::NatureParser parsenat = ExaltedData::NatureParser();
//filename = locate("data", "natures.xml");
filename="/home/shadow/project/kreator/src/data/natures.xml";
reader.setContentHandler( &parsenat );
if (!reader.parse(source)) {
KMessageBox
::error(this,
("Parse error in natures.xml\n"+parsenat.
errorString() + "\nElement Count=")+QString::number(parsenat.
count));
};
}
void kreator::loadData() {
QString filename;
//QFile xmlFile;
// load natures;
ExaltedData::NatureParser parsenat = ExaltedData::NatureParser();
//filename = locate("data", "natures.xml");
filename="/home/shadow/project/kreator/src/data/natures.xml";
QFile xmlFile(filename);
QXmlInputSource source(&xmlFile);
QXmlSimpleReader reader;
reader.setContentHandler( &parsenat );
if (!reader.parse(source)) {
KMessageBox::error(this,("Parse error in natures.xml\n"+parsenat.errorString() + "\nElement Count=")+QString::number(parsenat.count));
};
}
To copy to clipboard, switch view to plain text mode
and in the header of the data namespace I have
namespace ExaltedData {
static QMap<QString,NatureData> natures;
}
namespace ExaltedData {
static QMap<QString,NatureData> natures;
}
To copy to clipboard, switch view to plain text mode
I've verified that the parse works correctly and during the parse natures has 21 elements, but when I reference it again later it's got 0 elements again.
Anyone able to tell me what I'm doing wrong?
Bookmarks