From 5d019fbd87e6c40faf41c0151b7e333cd2d00e0d Mon Sep 17 00:00:00 2001 From: Arin Alexander Date: Fri, 18 Jan 2019 20:18:45 +0300 Subject: [PATCH] Null pointer access has been fixed --- common.pri | 2 +- limereport/items/lrtextitem.cpp | 24 +++++++++++++----------- limereport/lrbasedesignintf.cpp | 28 +++++++++++++++------------- limereport/lrpageitemdesignintf.cpp | 7 +++---- 4 files changed, 32 insertions(+), 29 deletions(-) diff --git a/common.pri b/common.pri index 222482d..ab95c10 100644 --- a/common.pri +++ b/common.pri @@ -77,7 +77,7 @@ RCC_DIR = $${ARCH_DIR}/$${BUILD_TYPE}/rcc LIMEREPORT_VERSION_MAJOR = 1 LIMEREPORT_VERSION_MINOR = 4 -LIMEREPORT_VERSION_RELEASE = 116 +LIMEREPORT_VERSION_RELEASE = 117 LIMEREPORT_VERSION = '\\"$${LIMEREPORT_VERSION_MAJOR}.$${LIMEREPORT_VERSION_MINOR}.$${LIMEREPORT_VERSION_RELEASE}\\"' DEFINES += LIMEREPORT_VERSION_STR=\"$${LIMEREPORT_VERSION}\" diff --git a/limereport/items/lrtextitem.cpp b/limereport/items/lrtextitem.cpp index a4384b0..eae907f 100644 --- a/limereport/items/lrtextitem.cpp +++ b/limereport/items/lrtextitem.cpp @@ -113,17 +113,19 @@ void TextItem::processPopUpAction(QAction *action) if (action->text().compare(tr("Edit")) == 0){ this->showEditorDialog(); } - if (action->text().compare(tr("Auto height")) == 0){ - page()->setPropertyToSelectedItems("autoHeight",action->isChecked()); - } - if (action->text().compare(tr("Allow HTML")) == 0){ - page()->setPropertyToSelectedItems("allowHTML",action->isChecked()); - } - if (action->text().compare(tr("Allow HTML in fields")) == 0){ - page()->setPropertyToSelectedItems("allowHTMLInFields",action->isChecked()); - } - if (action->text().compare(tr("Stretch to max height")) == 0){ - page()->setPropertyToSelectedItems("stretchToMaxHeight",action->isChecked()); + if (page()){ + if (action->text().compare(tr("Auto height")) == 0){ + page()->setPropertyToSelectedItems("autoHeight",action->isChecked()); + } + if (action->text().compare(tr("Allow HTML")) == 0){ + page()->setPropertyToSelectedItems("allowHTML",action->isChecked()); + } + if (action->text().compare(tr("Allow HTML in fields")) == 0){ + page()->setPropertyToSelectedItems("allowHTMLInFields",action->isChecked()); + } + if (action->text().compare(tr("Stretch to max height")) == 0){ + page()->setPropertyToSelectedItems("stretchToMaxHeight",action->isChecked()); + } } } diff --git a/limereport/lrbasedesignintf.cpp b/limereport/lrbasedesignintf.cpp index 3a3a22b..39de032 100644 --- a/limereport/lrbasedesignintf.cpp +++ b/limereport/lrbasedesignintf.cpp @@ -544,10 +544,12 @@ void BaseDesignIntf::mouseMoveEvent(QGraphicsSceneMouseEvent *event) setItemPos(QPointF(div(m_startPos.x(), hStep).quot * hStep, div(m_startPos.y(), vStep).quot * vStep) - delta); - if (!isBand() && scene()->selectedItems().count()>1) - moveSelectedItems(tmpPos - pos()); - if (scene()->selectedItems().count()==1 && (page()->magneticMovement())) - page()->itemMoved(this); + if (page()){ + if (!isBand() && page()->selectedItems().count()>1) + moveSelectedItems(tmpPos - pos()); + if (page()->selectedItems().count()==1 && (page()->magneticMovement())) + page()->itemMoved(this); + } } } @@ -806,29 +808,29 @@ void BaseDesignIntf::setBorderLineSize(int value) void BaseDesignIntf::moveRight() { - if (!m_fixedPos) setItemPos(pos().x() + page()->horizontalGridStep(), pos().y()); + if (!m_fixedPos && page()) setItemPos(pos().x() + page()->horizontalGridStep(), pos().y()); } void BaseDesignIntf::moveLeft() { - if (!m_fixedPos) setItemPos(pos().x() - page()->horizontalGridStep(), pos().y()); + if (!m_fixedPos && page()) setItemPos(pos().x() - page()->horizontalGridStep(), pos().y()); } void BaseDesignIntf::moveDown() { - if (!m_fixedPos) setItemPos(pos().x(), pos().y() + page()->verticalGridStep()); + if (!m_fixedPos && page()) setItemPos(pos().x(), pos().y() + page()->verticalGridStep()); } void BaseDesignIntf::moveUp() { - if (!m_fixedPos) setItemPos(pos().x(), pos().y() - page()->verticalGridStep()); + if (!m_fixedPos && page()) setItemPos(pos().x(), pos().y() - page()->verticalGridStep()); } void BaseDesignIntf::sizeRight() { if ((m_possibleResizeDirectionFlags & ResizeLeft) || (m_possibleResizeDirectionFlags & ResizeRight)) { - setWidth(width() + page()->horizontalGridStep()); + if (page()) setWidth(width() + page()->horizontalGridStep()); } } @@ -836,7 +838,7 @@ void BaseDesignIntf::sizeLeft() { if ((m_possibleResizeDirectionFlags & ResizeLeft) || (m_possibleResizeDirectionFlags & ResizeRight)) { - setWidth(width() - page()->horizontalGridStep()); + if(page()) setWidth(width() - page()->horizontalGridStep()); } } @@ -844,7 +846,7 @@ void BaseDesignIntf::sizeUp() { if ((m_possibleResizeDirectionFlags & ResizeTop) || (m_possibleResizeDirectionFlags & ResizeBottom)) { - setHeight(height() - page()->verticalGridStep()); + if (page()) setHeight(height() - page()->verticalGridStep()); } } @@ -852,7 +854,7 @@ void BaseDesignIntf::sizeDown() { if ((m_possibleResizeDirectionFlags & ResizeTop) || (m_possibleResizeDirectionFlags & ResizeBottom)) { - setHeight(height() + page()->verticalGridStep()); + if (page()) setHeight(height() + page()->verticalGridStep()); } } @@ -1325,7 +1327,7 @@ void BaseDesignIntf::collectionLoadFinished(const QString &collectionName) foreach(QObject * obj, QObject::children()) { #endif BaseDesignIntf *item = dynamic_cast(obj); - if (item) { + if (item && page()) { page()->registerItem(item); } } diff --git a/limereport/lrpageitemdesignintf.cpp b/limereport/lrpageitemdesignintf.cpp index 364d42e..af65436 100644 --- a/limereport/lrpageitemdesignintf.cpp +++ b/limereport/lrpageitemdesignintf.cpp @@ -690,10 +690,9 @@ void PageItemDesignIntf::bandGeometryChanged(QObject* object, QRectF newGeometry } } } - if (curIndex != band->bandIndex()){ - //swapBands(band, bandToSwap); - //page()->saveCommand(BandSwapCommand::create(page(), band->objectName(), bandToSwap->objectName()), true); - page()->saveCommand(BandMoveFromToCommand::create(page(), band->bandIndex(), bandToSwap->bandIndex()), true); + if (curIndex != band->bandIndex() && itemMode() == DesignMode){ + if (page()) + page()->saveCommand(BandMoveFromToCommand::create(page(), band->bandIndex(), bandToSwap->bandIndex()), true); } relocateBands(); }