Bug 94814 - Cleanup of static_cast's called immediately after a dynamic_cast.
Summary: Cleanup of static_cast's called immediately after a dynamic_cast.
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: LibreOffice (show other bugs)
Version:
(earliest affected)
5.0.1.2 release
Hardware: Other All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard: ToBeReviewed
Keywords: difficultyBeginner, easyHack, skillCpp, topicCleanup
Depends on:
Blocks:
 
Reported: 2015-10-06 08:41 UTC by Jan Holesovsky
Modified: 2017-02-14 08:58 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jan Holesovsky 2015-10-06 08:41:04 UTC
The recent changes removing rtti.hxx have introduced a pattern like this:

    if( dynamic_cast<const VclWindowEvent*>( &rEvent ) != nullptr )
    {
        VclWindowEvent* pWinEvent = static_cast<VclWindowEvent*>(&rEvent);
        [...original code...]
    }

When we have performed the dynamic_cast anyway, it would be more readable to change it to:

    VclWindowEvent* pWinEvent = dynamic_cast<VclWindowEvent*>(&rEvent);
    if (pWinEvent)
    {
        [...original code...]
    }

To find the places where this

    if (dynamic_cast<Type*>(var) != nullptr)
    {
        Type* p = static_cast<Type*>(var);

pattern was introduced, just read through the following commits:

http://cgit.freedesktop.org/libreoffice/core/commit/?id=d3c7c9ea81ee7c617f8cee5b645621088aea215b

http://cgit.freedesktop.org/libreoffice/core/commit/?id=ac9671f94800b647f82b12e718968311a025e87e

http://cgit.freedesktop.org/libreoffice/core/commit/?id=85f93697defd9a812a0cda0bc4e9364e28c0339e

http://cgit.freedesktop.org/libreoffice/core/commit/?id=89d39bc100aabf5dccbe77c0b5c0c85736e85b39

and see where the "ISA(...)" was removed, it is very likely that such change introduced the unwanted pattern.
Comment 1 Commit Notification 2015-10-06 14:11:34 UTC
Caolán McNamara committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=31ee230b6efac9a6a60ceb5c2367ae9a5cf98929

Related: tdf#94814 some cleanup of static_cast following dynamic_cast

It will be available in 5.1.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds
Affected users are encouraged to test the fix and report feedback.
Comment 2 Commit Notification 2015-10-13 21:39:43 UTC
Caolán McNamara committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=9381ca578de26aa75bb0d4439221c3439cf99616

Related: tdf#94814 some cleanup of static_cast following dynamic_cast

It will be available in 5.1.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 3 Robinson Tryon (qubit) 2015-12-13 11:04:05 UTC Comment hidden (obsolete)
Comment 4 Robinson Tryon (qubit) 2016-02-18 14:52:34 UTC Comment hidden (obsolete)
Comment 5 jani 2016-04-27 06:14:00 UTC
Seems solved