Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 877cb51d authored by Boudewijn Rempt's avatar Boudewijn Rempt

Remove unnecessary dynamic_cast

(cherry picked from commit 94a65412)
parent 73a4d2d1
......@@ -296,7 +296,7 @@ extern "C" int main(int argc, char **argv)
if (singleApplication && app.isRunning()) {
// only pass arguments to main instance if they are not for batch processing
// any batch processing would be done in this separate instance
const bool batchRun = (args.print() || args.exportAs() || args.exportAsPdf());
const bool batchRun = args.exportAs();
if (!batchRun) {
QByteArray ba = args.serialize();
......
......@@ -282,24 +282,21 @@ KisCanvas2::~KisCanvas2()
delete m_d;
}
void KisCanvas2::setCanvasWidget(QWidget * widget)
void KisCanvas2::setCanvasWidget(KisAbstractCanvasWidget *widget)
{
KisAbstractCanvasWidget *tmp = dynamic_cast<KisAbstractCanvasWidget*>(widget);
Q_ASSERT_X(tmp, "setCanvasWidget", "Cannot cast the widget to a KisAbstractCanvasWidget");
if (m_d->popupPalette) {
m_d->popupPalette->setParent(widget);
m_d->popupPalette->setParent(widget->widget());
}
if(m_d->canvasWidget != 0)
{
tmp->setDecorations(m_d->canvasWidget->decorations());
if (m_d->canvasWidget != 0) {
widget->setDecorations(m_d->canvasWidget->decorations());
// Redundant check for the constructor case, see below
if(viewManager() != 0)
viewManager()->inputManager()->removeTrackedCanvas(this);
}
m_d->canvasWidget = tmp;
m_d->canvasWidget = widget;
// Either tmp was null or we are being called by KisCanvas2 constructor that is called by KisView
// constructor, so the view manager still doesn't exists.
......@@ -312,15 +309,14 @@ void KisCanvas2::setCanvasWidget(QWidget * widget)
m_d->canvasWidget->addDecoration(manager);
}
widget->setAutoFillBackground(false);
widget->setAttribute(Qt::WA_OpaquePaintEvent);
widget->setMouseTracking(true);
widget->setAcceptDrops(true);
widget->widget()->setAutoFillBackground(false);
widget->widget()->setAttribute(Qt::WA_OpaquePaintEvent);
widget->widget()->setMouseTracking(true);
widget->widget()->setAcceptDrops(true);
KoCanvasControllerWidget *controller = dynamic_cast<KoCanvasControllerWidget*>(canvasController());
if (controller) {
Q_ASSERT(controller->canvas() == this);
controller->changeCanvasWidget(widget);
if (controller && controller->canvas() == this) {
controller->changeCanvasWidget(widget->widget());
}
}
......
......@@ -56,6 +56,7 @@ class KisAnimationPlayer;
class KisShapeController;
class KisCoordinatesConverter;
class KoViewConverter;
class KisAbstractCanvasWidget;
/**
* KisCanvas2 is not an actual widget class, but rather an adapter for
......@@ -319,7 +320,7 @@ private:
void createQPainterCanvas();
void createOpenGLCanvas();
void updateCanvasWidgetImpl(const QRect &rc = QRect());
void setCanvasWidget(QWidget *widget);
void setCanvasWidget(KisAbstractCanvasWidget *widget);
void resetCanvas(bool useOpenGL);
void notifyLevelOfDetailChange();
......
......@@ -123,11 +123,6 @@ void KisCanvasController::setCanvas(KoCanvasBase *canvas)
KoCanvasControllerWidget::setCanvas(canvas);
}
void KisCanvasController::changeCanvasWidget(QWidget *widget)
{
KoCanvasControllerWidget::changeCanvasWidget(widget);
}
void KisCanvasController::activate()
{
KoCanvasControllerWidget::activate();
......
......@@ -36,7 +36,6 @@ public:
~KisCanvasController() override;
void setCanvas(KoCanvasBase *canvas) override;
void changeCanvasWidget(QWidget *widget) override;
void keyPressEvent(QKeyEvent *event) override;
void wheelEvent(QWheelEvent *event) override;
bool eventFilter(QObject *watched, QEvent *event) override;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment