TD: Fix several coverity issues:

* CID 316569: Uninitialized scalar variable
* CID 350651: Unchecked dynamic_cast
* CID 350565: Unchecked dynamic_cast
* CID 350595: Unchecked dynamic_cast
* CID 350638: Unchecked dynamic_cast
* CID 350547: Division or modulo by float zero
This commit is contained in:
wmayer
2022-03-13 15:40:49 +01:00
parent 69a5bfd6b1
commit 883012e4b0
4 changed files with 28 additions and 21 deletions

View File

@@ -108,17 +108,15 @@ void TaskCustomizeFormat::changeEvent(QEvent *e)
void TaskCustomizeFormat::setUiEdit()
{
setWindowTitle(tr("Customize Format"));
if (selectedObject->isDerivedFrom(TechDraw::DrawViewDimension::getClassTypeId()))
if (auto dim = dynamic_cast<TechDraw::DrawViewDimension*>(selectedObject))
{
auto dim = dynamic_cast<TechDraw::DrawViewDimension*>(selectedObject);
isDimension = true;
std::string dimText = dim->FormatSpec.getStrValue();
dimRawValue = dim->getDimValue();
ui->leFormat->setText(Base::Tools::fromStdString(dimText));
}
else
else if (auto balloon = dynamic_cast<TechDraw::DrawViewBalloon*>(selectedObject))
{
auto balloon = dynamic_cast<TechDraw::DrawViewBalloon*>(selectedObject);
isDimension = false;
std::string balloonText = balloon->Text.getStrValue();
ui->leFormat->setText(Base::Tools::fromStdString(balloonText));
@@ -191,9 +189,12 @@ void TaskCustomizeFormat::onSymbolClicked()
{
// Slot: a symbol PushButton has been clicked
QObject* senderObj(this->sender());
QPushButton* pressedButton = dynamic_cast<QPushButton*>(senderObj);
QString pbText = pressedButton->text();
ui->leFormat->insert(pbText);
QPushButton* pressedButton = qobject_cast<QPushButton*>(senderObj);
if (pressedButton)
{
QString pbText = pressedButton->text();
ui->leFormat->insert(pbText);
}
}
void TaskCustomizeFormat::onFormatChanged()