Merge pull request #4217 from umlaeute/bugfix/x3d-extension-check

Fix file-extension check for X3D-files
pull/4219/head
Kim Kulling 2021-12-01 16:07:12 +01:00 committed by GitHub
commit 16149348ed
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 10 deletions

View File

@ -235,10 +235,8 @@ void X3DImporter::ParseFile(const std::string &file, IOSystem *pIOHandler) {
bool X3DImporter::CanRead(const std::string &pFile, IOSystem * /*pIOHandler*/, bool checkSig) const { bool X3DImporter::CanRead(const std::string &pFile, IOSystem * /*pIOHandler*/, bool checkSig) const {
if (checkSig) { if (checkSig) {
std::string::size_type pos = pFile.find_last_of(".x3d"); if (GetExtension(pFile) == "x3d")
if (pos != std::string::npos) {
return true; return true;
}
} }
return false; return false;

View File

@ -72,7 +72,7 @@ void X3DImporter::startReadGroup(XmlNode &node) {
// if "USE" defined then find already defined element. // if "USE" defined then find already defined element.
if (!use.empty()) { if (!use.empty()) {
X3DNodeElementBase *ne = nullptr; X3DNodeElementBase *ne(nullptr);
ne = MACRO_USE_CHECKANDAPPLY(node, def, use, ENET_Group, ne); ne = MACRO_USE_CHECKANDAPPLY(node, def, use, ENET_Group, ne);
} else { } else {
ParseHelper_Group_Begin(); // create new grouping element and go deeper if node has children. ParseHelper_Group_Begin(); // create new grouping element and go deeper if node has children.
@ -110,7 +110,7 @@ void X3DImporter::startReadStaticGroup(XmlNode &node) {
// if "USE" defined then find already defined element. // if "USE" defined then find already defined element.
if (!use.empty()) { if (!use.empty()) {
X3DNodeElementBase *ne = nullptr; X3DNodeElementBase *ne(nullptr);
ne = MACRO_USE_CHECKANDAPPLY(node, def, use, ENET_Group, ne); ne = MACRO_USE_CHECKANDAPPLY(node, def, use, ENET_Group, ne);
} else { } else {
@ -153,7 +153,7 @@ void X3DImporter::startReadSwitch(XmlNode &node) {
// if "USE" defined then find already defined element. // if "USE" defined then find already defined element.
if (!use.empty()) { if (!use.empty()) {
X3DNodeElementBase *ne=nullptr; X3DNodeElementBase *ne(nullptr);
ne = MACRO_USE_CHECKANDAPPLY(node, def, use, ENET_Group, ne); ne = MACRO_USE_CHECKANDAPPLY(node, def, use, ENET_Group, ne);
} else { } else {
@ -226,8 +226,13 @@ void X3DImporter::startReadTransform(XmlNode &node) {
// if "USE" defined then find already defined element. // if "USE" defined then find already defined element.
if (!use.empty()) { if (!use.empty()) {
X3DNodeElementBase *ne(nullptr); X3DNodeElementBase *ne(nullptr);
bool newgroup = (nullptr == mNodeElementCur);
if(newgroup)
ParseHelper_Group_Begin();
ne = MACRO_USE_CHECKANDAPPLY(node, def, use, ENET_Group, ne); ne = MACRO_USE_CHECKANDAPPLY(node, def, use, ENET_Group, ne);
if (newgroup && isNodeEmpty(node)) {
ParseHelper_Node_Exit();
}
} else { } else {
ParseHelper_Group_Begin(); // create new grouping element and go deeper if node has children. ParseHelper_Group_Begin(); // create new grouping element and go deeper if node has children.
// at this place new group mode created and made current, so we can name it. // at this place new group mode created and made current, so we can name it.

View File

@ -60,14 +60,12 @@ namespace Assimp {
/// \param [in] pType - type of element to find. /// \param [in] pType - type of element to find.
/// \param [out] pNE - pointer to found node element. /// \param [out] pNE - pointer to found node element.
inline X3DNodeElementBase *X3DImporter::MACRO_USE_CHECKANDAPPLY(XmlNode &node, std::string pDEF, std::string pUSE, X3DElemType pType, X3DNodeElementBase *pNE) { inline X3DNodeElementBase *X3DImporter::MACRO_USE_CHECKANDAPPLY(XmlNode &node, std::string pDEF, std::string pUSE, X3DElemType pType, X3DNodeElementBase *pNE) {
if (nullptr == mNodeElementCur) {
printf("here\n");
}
checkNodeMustBeEmpty(node); checkNodeMustBeEmpty(node);
if (!pDEF.empty()) if (!pDEF.empty())
Assimp::Throw_DEF_And_USE(node.name()); Assimp::Throw_DEF_And_USE(node.name());
if (!FindNodeElement(pUSE, pType, &pNE)) if (!FindNodeElement(pUSE, pType, &pNE))
Assimp::Throw_USE_NotFound(node.name(), pUSE); Assimp::Throw_USE_NotFound(node.name(), pUSE);
ai_assert(nullptr != mNodeElementCur);
mNodeElementCur->Children.push_back(pNE); /* add found object as child to current element */ mNodeElementCur->Children.push_back(pNE); /* add found object as child to current element */
return pNE; return pNE;