Skip to content

Commit

Permalink
fix(Archicad): Crash when sending a Corner Window (#3034)
Browse files Browse the repository at this point in the history
crash fix

Co-authored-by: József L. Kiss <>
  • Loading branch information
jozseflkiss authored Nov 10, 2023
1 parent 3947014 commit 0f453af
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,12 @@ GS::ObjectState GetElementTypes::Execute (const GS::ObjectState& parameters, GS:
for (const GS::UniString& id : ids) {
API_Guid guid = APIGuidFromString (id.ToCStr ());
API_ElemType elementType = Utility::GetElementType (guid);
GS::UniString elemType = elementNames.Get (elementType);
GS::ObjectState listElem{ElementBase::ApplicationId, id, ElementBase::ElementType, elemType};

GS::UniString elementTypeName;
if (NoError != GetElementTypeName (elementType, elementTypeName))
continue;

GS::ObjectState listElem{ElementBase::ApplicationId, id, ElementBase::ElementType, elementTypeName};
listAdder (listElem);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,14 @@ GS::ObjectState GetSubElementInfo::Execute (const GS::ObjectState& parameters, G

GS::UniString guid = APIGuidToString (currentGuid);
API_ElemType elementType = Utility::GetElementType (currentGuid);
GS::UniString elemType = elementNames.Get (elementType);

GS::UniString elementTypeName;
if (NoError != GetElementTypeName (elementType, elementTypeName))
continue;

GS::ObjectState subelementModel;
subelementModel.Add (ElementBase::ApplicationId, guid);
subelementModel.Add (ElementBase::ElementType, elemType);
subelementModel.Add (ElementBase::ElementType, elementTypeName);
listAdder (subelementModel);
}
}
Expand Down
21 changes: 21 additions & 0 deletions ConnectorArchicad/AddOn/Sources/AddOn/TypeNameTables.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,27 @@ const GS::HashTable<API_ElemType, GS::UniString> elementNames
};


GSErrCode GetElementTypeName (const API_ElemType& elementType, GS::UniString& elementTypeName)
{
// check typeID and variationID first
if (elementNames.ContainsKey(elementType)) {
elementTypeName = elementNames.Get (elementType);
return NoError;
}

// check only typeID
for (auto elementNameIt : elementNames)
{
if (elementNameIt.key->typeID == elementType.typeID) {
elementTypeName = *(elementNameIt.value);
return NoError;
}
}

return Error;
}


const GS::HashTable<API_ModelElemStructureType, GS::UniString> structureTypeNames
{
{ API_BasicStructure, "Basic"},
Expand Down
2 changes: 2 additions & 0 deletions ConnectorArchicad/AddOn/Sources/AddOn/TypeNameTables.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
#include "Utility.hpp"

extern const GS::HashTable<API_ElemType, GS::UniString> elementNames;
GSErrCode GetElementTypeName (const API_ElemType& elementType, GS::UniString& elementTypeName);

extern const GS::HashTable<API_ModelElemStructureType, GS::UniString> structureTypeNames;

extern const GS::HashTable<API_WallTypeID, GS::UniString> wallTypeNames;
Expand Down

0 comments on commit 0f453af

Please sign in to comment.