diff --git a/limereport/lritemdesignintf.cpp b/limereport/lritemdesignintf.cpp index a2b51f2..f90a90d 100644 --- a/limereport/lritemdesignintf.cpp +++ b/limereport/lritemdesignintf.cpp @@ -66,11 +66,13 @@ void ItemDesignIntf::setItemLocation(LocationType location) } else { if (scene()){ PageItemDesignIntf* page = dynamic_cast(scene())->pageItem(); - QPointF parentPos = page->mapFromItem(parentItem(),x(),y()); - setParentItem(page); - setParent(page); - setPos(parentPos); - emit itemLocationChanged(this, page); + if (page){ + QPointF parentPos = page->mapFromItem(parentItem(),x(),y()); + setParentItem(page); + setParent(page); + setPos(parentPos); + emit itemLocationChanged(this, page); + } } } notify("locationType",oldValue,location); diff --git a/limereport/lrpagedesignintf.cpp b/limereport/lrpagedesignintf.cpp index b379c3a..85ba475 100644 --- a/limereport/lrpagedesignintf.cpp +++ b/limereport/lrpagedesignintf.cpp @@ -491,13 +491,16 @@ BaseDesignIntf *PageDesignIntf::addReportItem(const QString &itemType, QPointF p reportItem->setSize(placeSizeOnGrid(size)); return reportItem; } else { - BaseDesignIntf *reportItem = addReportItem(itemType, pageItem(), pageItem()); - reportItem->setPos(placePosOnGrid(pageItem()->mapFromScene(pos))); - reportItem->setSize(placeSizeOnGrid(size)); - ItemDesignIntf* ii = dynamic_cast(reportItem); - if (ii) - ii->setItemLocation(ItemDesignIntf::Page); - return reportItem; + PageItemDesignIntf* page = pageItem() ? pageItem() : m_currentPage; + if (page){ + BaseDesignIntf *reportItem = addReportItem(itemType, page, page); + reportItem->setPos(placePosOnGrid(page->mapFromScene(pos))); + reportItem->setSize(placeSizeOnGrid(size)); + ItemDesignIntf* ii = dynamic_cast(reportItem); + if (ii) + ii->setItemLocation(ItemDesignIntf::Page); + return reportItem; + } } return 0; @@ -1066,7 +1069,9 @@ PageItemDesignIntf* PageDesignIntf::getCurrentPage() const void PageDesignIntf::setCurrentPage(PageItemDesignIntf* currentPage) { - m_currentPage = currentPage; + if (m_currentPage != currentPage ){ + m_currentPage = currentPage; + } } ReportSettings *PageDesignIntf::getReportSettings() const