[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [calligra] /: Don't use dynamic_cast if the result is not checked
From:       Friedrich W. H. Kossebau <kossebau () kde ! org>
Date:       2015-09-01 1:59:40
Message-ID: E1ZWarM-0006D6-3m () scm ! kde ! org
[Download RAW message or body]

Git commit 045c9ac37e075d94cd60a859d9e987aafd0d772c by Friedrich W. H. Kossebau.
Committed on 01/09/2015 at 01:31.
Pushed by kossebau into branch 'master'.

Don't use dynamic_cast if the result is not checked

M  +1    -1    plan/kptview.cpp
M  +2    -2    stage/part/KPrNotes.cpp
M  +1    -1    stage/part/KPrPresentationToolAdaptor.cpp
M  +1    -1    stage/part/KPrView.cpp
M  +1    -1    stage/part/KPrViewModeNotes.cpp
M  +1    -1    stage/part/animations/KPrAnimationLoader.cpp
M  +10   -10   stage/part/tools/animationtool/KPrAnimationTool.cpp

http://commits.kde.org/calligra/045c9ac37e075d94cd60a859d9e987aafd0d772c

diff --git a/plan/kptview.cpp b/plan/kptview.cpp
index 26be1e2..da07945 100644
--- a/plan/kptview.cpp
+++ b/plan/kptview.cpp
@@ -235,7 +235,7 @@ View::View(KoPart *part, MainDocument *doc, QWidget *parent)
         connect( m_viewlist, SIGNAL(updateViewInfo(ViewListItem*)), \
SLOT(slotUpdateViewInfo(ViewListItem*)) );  } else {
         ViewListDockerFactory vl(this);
-        docker = dynamic_cast<ViewListDocker \
*>(mainWindow()->createDockWidget(&vl)); +        docker = static_cast<ViewListDocker \
*>(mainWindow()->createDockWidget(&vl));  if (docker->view() != this) {
             docker->setView(this);
         }
diff --git a/stage/part/KPrNotes.cpp b/stage/part/KPrNotes.cpp
index 17df64a..d6407df 100644
--- a/stage/part/KPrNotes.cpp
+++ b/stage/part/KPrNotes.cpp
@@ -107,7 +107,7 @@ void KPrNotes::saveOdf(KoShapeSavingContext &context) const
     writer.addAttribute("draw:page-number", static_cast<KoPASavingContext \
&>(context).page());  writer.endElement(); // draw:page-thumbnail
 
-    KoShapeLayer* layer = dynamic_cast<KoShapeLayer*>( shapes().last() );
+    KoShapeLayer* layer = static_cast<KoShapeLayer*>( shapes().last() );
     foreach ( KoShape *shape, layer->shapes() ) {
         if ( shape != m_textShape && shape != m_thumbnailShape ) {
             shape->saveOdf( context );
@@ -120,7 +120,7 @@ void KPrNotes::saveOdf(KoShapeSavingContext &context) const
 bool KPrNotes::loadOdf(const KoXmlElement &element, KoShapeLoadingContext &context)
 {
     KoXmlElement child;
-    KoShapeLayer* layer = dynamic_cast<KoShapeLayer*>( shapes().last() );
+    KoShapeLayer* layer = static_cast<KoShapeLayer*>( shapes().last() );
 
     forEachElement( child, element ) {
         if ( child.namespaceURI() != KoXmlNS::draw )
diff --git a/stage/part/KPrPresentationToolAdaptor.cpp \
b/stage/part/KPrPresentationToolAdaptor.cpp index 5626d77..649c211 100644
--- a/stage/part/KPrPresentationToolAdaptor.cpp
+++ b/stage/part/KPrPresentationToolAdaptor.cpp
@@ -70,7 +70,7 @@ void KPrPresentationToolAdaptor::startDrawPresentation(int pointx, \
int pointy, i  if (m_viewModePresentation.isActivated()) {
         if (! dynamic_cast< KPrPresentationDrawStrategy* >(m_tool->strategy())) {
             m_tool->drawOnPresentation();
-            KPrPresentationDrawWidget *widget=dynamic_cast< \
KPrPresentationDrawWidget *>(m_tool->strategy()->widget()); +            \
KPrPresentationDrawWidget *widget = static_cast< KPrPresentationDrawWidget \
*>(m_tool->strategy()->widget());  widget->updateSize(penSize);
             widget->updateColor(color);
         }
diff --git a/stage/part/KPrView.cpp b/stage/part/KPrView.cpp
index 5985365..4db009d 100644
--- a/stage/part/KPrView.cpp
+++ b/stage/part/KPrView.cpp
@@ -370,7 +370,7 @@ void KPrView::startPresentation()
 
 void KPrView::startPresentationFromBeginning()
 {
-    KPrDocument * doc = dynamic_cast<KPrDocument *>( kopaDocument() );
+    KPrDocument * doc = static_cast<KPrDocument *>( kopaDocument() );
     QList<KoPAPageBase*> slideshow = doc->slideShow();
     if ( !slideshow.isEmpty() ) {
         setActivePage( slideshow.first() );
diff --git a/stage/part/KPrViewModeNotes.cpp b/stage/part/KPrViewModeNotes.cpp
index fdd025b..bd16e8d 100644
--- a/stage/part/KPrViewModeNotes.cpp
+++ b/stage/part/KPrViewModeNotes.cpp
@@ -171,7 +171,7 @@ void KPrViewModeNotes::updateActivePage(KoPAPageBase *page)
     }
     KPrNotes *notes = prPage->pageNotes();
     notes->updatePageThumbnail();
-    KoShapeLayer* layer = dynamic_cast<KoShapeLayer*>(notes->shapes().last());
+    KoShapeLayer* layer = static_cast<KoShapeLayer*>(notes->shapes().last());
 
     m_canvas->shapeManager()->setShapes(layer->shapes());
     m_canvas->masterShapeManager()->setShapes(QList<KoShape*>());
diff --git a/stage/part/animations/KPrAnimationLoader.cpp \
b/stage/part/animations/KPrAnimationLoader.cpp index 1221fa4..527a629 100644
--- a/stage/part/animations/KPrAnimationLoader.cpp
+++ b/stage/part/animations/KPrAnimationLoader.cpp
@@ -155,7 +155,7 @@ bool KPrAnimationLoader::loadOdfAnimation(KPrAnimationStep \
**animationStep, cons  }
         // use the current substep
         if ((*animationStep)->animationCount()) {
-            subStep = \
dynamic_cast<KPrAnimationSubStep*>((*animationStep)->animationAt((*animationStep)->animationCount() \
- 1)); +            subStep = \
static_cast<KPrAnimationSubStep*>((*animationStep)->animationAt((*animationStep)->animationCount() \
- 1));  }
         else {
             subStep = new KPrAnimationSubStep();
diff --git a/stage/part/tools/animationtool/KPrAnimationTool.cpp \
b/stage/part/tools/animationtool/KPrAnimationTool.cpp index 8062a1d..8e636de 100644
--- a/stage/part/tools/animationtool/KPrAnimationTool.cpp
+++ b/stage/part/tools/animationtool/KPrAnimationTool.cpp
@@ -112,10 +112,10 @@ void KPrAnimationTool::activate(ToolActivation toolActivation, \
const QSet<KoShap  }
     if (m_initializeTool) {
         reloadMotionPaths();
-        connect((dynamic_cast<KoPACanvas *>(canvas()))->koPAView()->proxyObject, \
SIGNAL(activePageChanged()), +        connect((static_cast<KoPACanvas \
*>(canvas()))->koPAView()->proxyObject, SIGNAL(activePageChanged()),  this, \
SLOT(reloadMotionPaths()));  if (m_shapeAnimationWidget) {
-            connect((dynamic_cast<KoPACanvas *>(canvas()))->koPAView()->proxyObject, \
SIGNAL(activePageChanged()), +            connect((static_cast<KoPACanvas \
                *>(canvas()))->koPAView()->proxyObject, SIGNAL(activePageChanged()),
                      m_shapeAnimationWidget, SLOT(slotActivePageChanged()));
         }
     }
@@ -140,9 +140,9 @@ void KPrAnimationTool::deactivate()
 {
     // Clean shape manager of motion paths
     cleanMotionPathManager();
-    disconnect((dynamic_cast<KoPACanvas *>(canvas()))->koPAView()->proxyObject, \
SIGNAL(activePageChanged()), +    disconnect((static_cast<KoPACanvas \
*>(canvas()))->koPAView()->proxyObject, SIGNAL(activePageChanged()),  this, \
                SLOT(reloadMotionPaths()));
-    disconnect((dynamic_cast<KoPACanvas *>(canvas()))->koPAView()->proxyObject, \
SIGNAL(activePageChanged()), +    disconnect((static_cast<KoPACanvas \
*>(canvas()))->koPAView()->proxyObject, SIGNAL(activePageChanged()),  \
m_shapeAnimationWidget, SLOT(slotActivePageChanged()));  m_initializeTool = true;
     delete m_pathShapeManager;
@@ -202,16 +202,16 @@ QRectF KPrAnimationTool::handlesSize()
 QList<QPointer<QWidget> > KPrAnimationTool::createOptionWidgets()
 {
     KPrPageEffectDocker *effectWidget = new KPrPageEffectDocker( );
-    effectWidget->setView((dynamic_cast<KoPACanvas *>(canvas()))->koPAView());
+    effectWidget->setView((static_cast<KoPACanvas *>(canvas()))->koPAView());
 
     KPrClickActionDocker *clickActionWidget = new KPrClickActionDocker();
-    clickActionWidget->setView((dynamic_cast<KoPACanvas *>(canvas()))->koPAView());
+    clickActionWidget->setView((static_cast<KoPACanvas *>(canvas()))->koPAView());
 
     m_shapeAnimationWidget = new KPrShapeAnimationDocker();
-    m_shapeAnimationWidget->setView((dynamic_cast<KoPACanvas \
*>(canvas()))->koPAView()); +    \
                m_shapeAnimationWidget->setView((static_cast<KoPACanvas \
                *>(canvas()))->koPAView());
     connect(m_shapeAnimationWidget, SIGNAL(shapeAnimationsChanged(KoShape*)), this, \
                SLOT(verifyMotionPathChanged(KoShape*)));
     connect(m_shapeAnimationWidget, SIGNAL(motionPathAddedRemoved()), this, \
                SLOT(reloadMotionPaths()));
-    connect((dynamic_cast<KoPACanvas *>(canvas()))->koPAView()->proxyObject, \
SIGNAL(activePageChanged()), +    connect((static_cast<KoPACanvas \
*>(canvas()))->koPAView()->proxyObject, SIGNAL(activePageChanged()),  \
m_shapeAnimationWidget, SLOT(slotActivePageChanged()));  
     QList<QPointer<QWidget> > widgets;
@@ -228,7 +228,7 @@ void KPrAnimationTool::initMotionPathShapes()
 {
     cleanMotionPathManager();
     //Load motion paths Data
-    KPrPageData *pageData = dynamic_cast<KPrPageData *>((dynamic_cast<KoPACanvas \
*>(canvas()))->koPAView()->activePage()); +    KPrPageData *pageData = \
dynamic_cast<KPrPageData *>((static_cast<KoPACanvas \
*>(canvas()))->koPAView()->activePage());  Q_ASSERT(pageData);
     KPrShapeAnimations *animations =  &(pageData->animations());
     for (int j = 0; j < animations->rowCount(); j++) {
@@ -268,7 +268,7 @@ void KPrAnimationTool::addPathShape(KoPathShape *pathShape)
 
 QSizeF KPrAnimationTool::getPageSize()
 {
-    QSizeF pageSize = dynamic_cast<KoPACanvas \
*>(canvas())->koPAView()->zoomController()->pageSize(); +    QSizeF pageSize = \
static_cast<KoPACanvas *>(canvas())->koPAView()->zoomController()->pageSize();  \
return pageSize;  }
 


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic