From 27a59a2fa4c3aae44e4a6a6d97973ad53df20cbe Mon Sep 17 00:00:00 2001 From: Murai Takashi Date: Mon, 7 Jan 2019 20:27:48 +0900 Subject: [PATCH] cortex: Fix PVS 1206 * Remove cast to void* in AddItem() at line 363, so that avoid that the object which was created using 'new' operator is immediately cast to another type. * Also remove other casts in AddItem(). Change-Id: Ia20ab39ef50dce12b9d06ca5b1736a8a8e3e9cdd Reviewed-on: https://review.haiku-os.org/c/856 Reviewed-by: Barrett17 --- src/apps/cortex/InfoView/InfoView.cpp | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/src/apps/cortex/InfoView/InfoView.cpp b/src/apps/cortex/InfoView/InfoView.cpp index b1d9c77d57..bbc2a39a7e 100644 --- a/src/apps/cortex/InfoView/InfoView.cpp +++ b/src/apps/cortex/InfoView/InfoView.cpp @@ -292,7 +292,7 @@ void InfoView::FrameResized( for (int32 i = 0; i < m_fields->CountItems(); i++) { bool wrappingChanged = false; _InfoTextField *field = static_cast<_InfoTextField *>(m_fields->ItemAt(i)); - field->updateLineWrapping(&wrappingChanged, + field->updateLineWrapping(&wrappingChanged, heightChanged ? 0 : &heightChanged); float fieldHeight = field->getHeight() + M_V_MARGIN; if (heightChanged) { @@ -360,13 +360,12 @@ void InfoView::addField( BString text) { D_METHOD(("InfoView::addField()\n")); - m_fields->AddItem(reinterpret_cast - (new _InfoTextField(label, text, this))); + m_fields->AddItem(new _InfoTextField(label, text, this)); } // -------------------------------------------------------- // // *** internal class: _InfoTextField -// +// // *** ctor/dtor // -------------------------------------------------------- // @@ -404,7 +403,7 @@ _InfoTextField::~_InfoTextField() { // -------------------------------------------------------- // // *** internal class: _InfoTextField -// +// // *** operations (public) // -------------------------------------------------------- // @@ -479,7 +478,7 @@ void _InfoTextField::updateLineWrapping( currentLine->Remove(i, 1); currentLine->MoveInto(*newLine, i, currentLine->CountChars() - i); - m_textLines->AddItem(reinterpret_cast(currentLine)); + m_textLines->AddItem(currentLine); currentLine = newLine; break; } @@ -488,7 +487,7 @@ void _InfoTextField::updateLineWrapping( { if (i == currentLine->CountChars() - 1) // the last char in the text { - m_textLines->AddItem(reinterpret_cast(currentLine)); + m_textLines->AddItem(currentLine); currentLine = 0; break; } @@ -505,7 +504,7 @@ void _InfoTextField::updateLineWrapping( BString *newLine = new BString(); currentLine->MoveInto(*newLine, lastBreak, currentLine->CountChars() - lastBreak); - m_textLines->AddItem(reinterpret_cast(currentLine)); + m_textLines->AddItem(currentLine); currentLine = newLine; break; } @@ -539,7 +538,7 @@ void _InfoTextField::updateLineWrapping( // -------------------------------------------------------- // // *** internal class: _InfoTextField -// +// // *** accessors (public) // -------------------------------------------------------- // @@ -580,12 +579,12 @@ bool _InfoTextField::isWrapped() const { D_ACCESS(("_InfoTextField::isWrapped()\n")); - return (m_textLines->CountItems() > 1); + return (m_textLines->CountItems() > 1); } // -------------------------------------------------------- // // *** internal class: _InfoTextField -// +// // *** static internal methods (private) // -------------------------------------------------------- //