diff --git a/limereport/lrreportengine.cpp b/limereport/lrreportengine.cpp index e83aadf..b07c607 100644 --- a/limereport/lrreportengine.cpp +++ b/limereport/lrreportengine.cpp @@ -155,12 +155,13 @@ QObject *ReportEnginePrivate::elementAt(const QString &, int index) return pageAt(index); } -PageDesignIntf *ReportEnginePrivate::createPage(const QString &pageName) +PageDesignIntf *ReportEnginePrivate::createPage(const QString &pageName, bool preview) { PageDesignIntf* page =new PageDesignIntf(); page->setObjectName(pageName); page->pageItem()->setObjectName("Report"+pageName); - page->setReportEditor(this); + if (!preview) + page->setReportEditor(this); page->setReportSettings(&m_reportSettings); return page; } @@ -185,7 +186,7 @@ bool ReportEnginePrivate::deletePage(PageDesignIntf *page){ PageDesignIntf *ReportEnginePrivate::createPreviewPage() { - return createPage(); + return createPage("preview",true); } int ReportEnginePrivate::elementsCount(const QString &) diff --git a/limereport/lrreportengine_p.h b/limereport/lrreportengine_p.h index 69831b7..3210e64 100644 --- a/limereport/lrreportengine_p.h +++ b/limereport/lrreportengine_p.h @@ -240,7 +240,7 @@ public slots: bool slotLoadFromFile(const QString& fileName); void cancelRender(); protected: - PageDesignIntf* createPage(const QString& pageName=""); + PageDesignIntf* createPage(const QString& pageName="", bool preview = false); protected slots: void slotDataSourceCollectionLoaded(const QString& collectionName); private slots: diff --git a/limereport/lrscriptenginemanager.cpp b/limereport/lrscriptenginemanager.cpp index f6197e9..0f3aa1a 100644 --- a/limereport/lrscriptenginemanager.cpp +++ b/limereport/lrscriptenginemanager.cpp @@ -336,7 +336,7 @@ QStringList ScriptEngineManager::functionsNames() } void ScriptEngineManager::setDataManager(DataSourceManager *dataManager){ - if (m_dataManager != dataManager){ + if (dataManager && m_dataManager != dataManager){ m_dataManager = dataManager; if (m_dataManager){ foreach(QString func, m_dataManager->groupFunctionNames()){ diff --git a/limereport/scripteditor/lrscripteditor.cpp b/limereport/scripteditor/lrscripteditor.cpp index c1a7141..7c9656d 100644 --- a/limereport/scripteditor/lrscripteditor.cpp +++ b/limereport/scripteditor/lrscripteditor.cpp @@ -54,14 +54,16 @@ void ScriptEditor::setReportEngine(ReportEnginePrivateInterface* reportEngine) { m_reportEngine = reportEngine; DataSourceManager* dm = m_reportEngine->dataManager(); - initEditor(dm); + if (dm) initEditor(dm); + else ui->tabWidget->setVisible(false); } void ScriptEditor::setReportPage(PageDesignIntf* page) { m_page = page; DataSourceManager* dm = page->datasourceManager(); - initEditor(dm); + if (dm) initEditor(dm); + else ui->tabWidget->setVisible(false); } void ScriptEditor::setPageBand(BandDesignIntf* band)