Bugzilla – Bug 2230
Crash when loading an XML file containing no nodes
Last modified: 2015-11-27 11:59:46 EST
Created attachment 2194 [details] 3 diffs with patch suggestions Netanim crashes if one tries to load a file with no nodes (only anim tags inside), and if I remember correctly, even if the file contains nodes only. It will crash for sure, if no node with ID == 0 is present. Please see the attachment for some possible (quick&dirty) changes. I think the most important parts are in animpropertybrowser.cpp, postParse (): a check for count == 0 will prevent the empty-file-crash. Setting m_currentNodeId = AnimNodeMgr::getInstance()->cbegin()->first; makes sure, that m_currentNodeId is a valid ID (but it looks awful). Of course, if the node IDs always start at 0 and increase monotonically everything is fine either way. However, since NodeIdAnimNodeMap_t is a typedef to std::map instead of a simple vector, I suppose you want it to be more general. I've added the functions cbegin and cend to iterate over all elements in the map. I might be completely wrong here, but as far as I understood the function AnimPropertyBroswer::setupNodeProperties (), you want to set up all nodes, not just the m_currentNodeId one. Sorry if I tried to 'improve' correct code here. For the case that I'm not wrong so far, you probably want to change the following lines to use the iterator approach, too: for (uint32_t i = 0; i < count; ++i) { m_nodeIdSelector->addItem (QString::number (i)); //use it->first here } Thank you for your quick replies and commits!
Ok, the for loop in the browser breaks things. I'm sorry.