From 0e6984196b73f293c792dab9cb4eea47b724ecd5c23d7afd70d201f22f67fc13 Mon Sep 17 00:00:00 2001 From: ADAM David Alan Martin Date: Sat, 9 Aug 2025 06:09:12 -0400 Subject: [PATCH] The last few `instanceOf` uses? --- dw/oofawarewidget.cc | 5 +++-- dw/oofposrelmgr.cc | 4 ++-- dw/table.cc | 4 ++-- dw/textblock.cc | 11 +++++------ 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/dw/oofawarewidget.cc b/dw/oofawarewidget.cc index 5e627d4..2cf4c15 100644 --- a/dw/oofawarewidget.cc +++ b/dw/oofawarewidget.cc @@ -195,8 +195,9 @@ void OOFAwareWidget::notifySetParent () widget != NULL && oofContainer[oofmIndex] == NULL; widget = widget->getParent ()) if (isOOFContainer (widget, oofmIndex)) { - assert (widget->instanceOf ()); - oofContainer[oofmIndex] = (OOFAwareWidget*)widget; + auto *oaw= dynamic_cast< OOFAwareWidget * >( widget ); + assert (oaw); + oofContainer[oofmIndex]= oaw; } DBG_OBJ_ARRSET_PTR ("oofContainer", oofmIndex, oofContainer[oofmIndex]); diff --git a/dw/oofposrelmgr.cc b/dw/oofposrelmgr.cc index f4f89ef..2c081cd 100644 --- a/dw/oofposrelmgr.cc +++ b/dw/oofposrelmgr.cc @@ -66,8 +66,8 @@ void OOFPosRelMgr::calcWidgetRefSize (Widget *widget, Requisition *size) // (Notice also that Widget::sizeRequest has to be called in all // cases.) - if (widget->instanceOf ()) - *size = *((OOFAwareWidget*)widget)->getRequisitionWithoutOOF (); + if (auto *oaw= dynamic_cast< OOFAwareWidget * >( widget )) + *size = *oaw->getRequisitionWithoutOOF (); DBG_OBJ_LEAVE_VAL ("%d * (%d + %d)", diff --git a/dw/table.cc b/dw/table.cc index 03723a5..26aa904 100644 --- a/dw/table.cc +++ b/dw/table.cc @@ -607,8 +607,8 @@ AlignedTableCell *Table::getCellRef () int n = curCol + row * numCols; if (childDefined (n)) { child = children->get(n)->cell.widget; - if (child->instanceOf ()) - return (AlignedTableCell*)child; + if (auto *atc= dynamic_cast< AlignedTableCell * >( child )) + return atc; } } diff --git a/dw/textblock.cc b/dw/textblock.cc index e8a82ec..b66b5c7 100644 --- a/dw/textblock.cc +++ b/dw/textblock.cc @@ -2763,12 +2763,11 @@ void Textblock::addParbreak (int space, core::style::Style *style) way that the space is in any case visible. */ /* Find the widget where to adjust the breakSpace. (Only consider normal flow, no floats etc.) */ + Textblock *textblock2= nullptr; for (Widget *widget = this; - widget->getParent() != NULL && - widget->getParent()->instanceOf () && + ( textblock2= dynamic_cast< Textblock * >( widget->getParent() ) ) && !isWidgetOOF (widget); widget = widget->getParent ()) { - Textblock *textblock2 = (Textblock*)widget->getParent (); int index = textblock2->hasListitemValue ? 1 : 0; bool isfirst = (textblock2->words->getRef(index)->content.type == core::Content::WIDGET_IN_FLOW @@ -3192,9 +3191,9 @@ int Textblock::getGeneratorWidth () int xRel; // We only examine instances of dw::Textblock, since they are relevant // for floats, for which this method is only called. - if(word->content.type == core::Content::WIDGET_IN_FLOW && - word->content.widget->instanceOf()) { - Textblock *tbChild = (Textblock*)word->content.widget; + if(Textblock *tbChild= nullptr; + word->content.type == core::Content::WIDGET_IN_FLOW && + ( tbChild= dynamic_cast< Textblock * >( word->content.widget ) )) { if(tbChild->findSizeRequestReference(this, &xRel, NULL)) wChild = max(wChild, xRel + tbChild->getGeneratorWidth()); }