Skip to content
Extraits de code Groupes Projets
Vérifiée Valider e9e1867f rédigé par Kubat's avatar Kubat
Parcourir les fichiers

FIX: Need to trick the IrElement::setParent to not dereference a nullptr in some cases...

parent b9cbae06
Aucune branche associée trouvée
Aucune étiquette associée trouvée
1 requête de fusion!25Draft: New Vivy module spec
Pipeline #2878 réussi
......@@ -7,10 +7,21 @@ namespace Vivy::Script
{
IrElement::IrElement(IrElement *p) noexcept
{
/*
** Need to trick the setParent or we might dereference a nullptr... Can't
** think of a cleaner way for now.
*/
parentRootIsNotInitialized = false;
setParent(p);
parentRoot = parent()->irRoot();
if (parentRoot == nullptr)
parentRoot = dynamic_cast<IrRoot *>(this);
parentRootIsNotInitialized = true;
if (parent() != nullptr) {
parentRoot = parent()->irRoot();
parentRootIsNotInitialized = false;
if (parentRoot == nullptr)
parentRoot = dynamic_cast<IrRoot *>(this);
}
}
IrRoot *
......@@ -90,6 +101,8 @@ IrElement::setParent(IrElement *p) noexcept
parentElement = p;
if (parentElement != nullptr)
parentElement->addChild(this);
if (parentRootIsNotInitialized)
parentRoot = parent()->irRoot();
}
void
......
......@@ -106,9 +106,10 @@ concept IrElementParsable = std::is_base_of<IrElement, T>::value && requires(T i
/* Base class definition: IrElement */
class IrElement {
IrElement *parentElement = nullptr;
IrAttribute *elementAttributes = nullptr;
IrRoot *parentRoot = nullptr;
IrElement *parentElement = nullptr;
IrAttribute *elementAttributes = nullptr;
IrRoot *parentRoot = nullptr;
bool parentRootIsNotInitialized = true;
std::vector<IrElement *> childElements;
protected:
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter