From 9538cf4d4c99e0b63e641b281970bb169166d42f Mon Sep 17 00:00:00 2001 From: Renaud G Date: Mon, 7 Oct 2019 21:11:30 +0200 Subject: Protect all dynamic casts. --- diceparser.cpp | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'diceparser.cpp') diff --git a/diceparser.cpp b/diceparser.cpp index 3f346e9..ad8400d 100644 --- a/diceparser.cpp +++ b/diceparser.cpp @@ -518,18 +518,21 @@ void DiceParser::getDiceResultFromAllInstruction(QList& resu if(result->hasResultOfType(Dice::RESULT_TYPE::DICE_LIST)) { DiceResult* diceResult= dynamic_cast(result); - QList list; - quint64 faces= 0; - - for(auto& die : diceResult->getResultList()) + if(diceResult) { - faces= die->getFaces(); - // qDebug() << "face" << faces; - HighLightDice hlDice(die->getListValue(), die->isHighlighted(), die->getColor(), - die->hasBeenDisplayed(), die->getFaces()); - list.append(hlDice); + QList list; + quint64 faces= 0; + + for(auto& die : diceResult->getResultList()) + { + faces= die->getFaces(); + // qDebug() << "face" << faces; + HighLightDice hlDice(die->getListValue(), die->isHighlighted(), die->getColor(), + die->hasBeenDisplayed(), die->getFaces()); + list.append(hlDice); + } + nodeResult.insert(faces, list); } - nodeResult.insert(faces, list); } result= result->getPrevious(); } -- cgit v1.2.3-70-g09d2