mirror of
https://github.com/fralx/LimeReport.git
synced 2024-12-24 00:33:02 +03:00
fix #3 ReportEngine крашится, если попытаться его удалить на открытом preview
This commit is contained in:
parent
44fba80068
commit
5108c3a49d
@ -55,7 +55,7 @@ QSettings* ReportEngine::m_settings = 0;
|
||||
ReportEnginePrivate::ReportEnginePrivate(QObject *parent) :
|
||||
QObject(parent), m_fileName(""), m_settings(0), m_ownedSettings(false),
|
||||
m_printer(new QPrinter(QPrinter::HighResolution)), m_printerSelected(false),
|
||||
m_showProgressDialog(true), m_reportName("")
|
||||
m_showProgressDialog(true), m_reportName(""), m_activePreview(0)
|
||||
{
|
||||
m_datasources= new DataSourceManager(this);
|
||||
m_datasources->setObjectName("datasources");
|
||||
@ -64,6 +64,9 @@ ReportEnginePrivate::ReportEnginePrivate(QObject *parent) :
|
||||
|
||||
ReportEnginePrivate::~ReportEnginePrivate()
|
||||
{
|
||||
if (m_activePreview){
|
||||
m_activePreview->close();
|
||||
}
|
||||
foreach(PageDesignIntf* page,m_pages) delete page;
|
||||
m_pages.clear();
|
||||
if (m_ownedSettings&&m_settings) delete m_settings;
|
||||
@ -81,7 +84,7 @@ QObject *ReportEnginePrivate::elementAt(const QString &, int index)
|
||||
|
||||
PageDesignIntf *ReportEnginePrivate::createPage(const QString &pageName)
|
||||
{
|
||||
PageDesignIntf* page =new PageDesignIntf(this);
|
||||
PageDesignIntf* page =new PageDesignIntf();
|
||||
page->setObjectName(pageName);
|
||||
page->setReportEditor(this);
|
||||
return page;
|
||||
@ -130,6 +133,13 @@ void ReportEnginePrivate::slotDataSourceCollectionLoaded(const QString &collecti
|
||||
emit datasourceCollectionLoadFinished(collectionName);
|
||||
}
|
||||
|
||||
void ReportEnginePrivate::slotPreviewWindowDestroed(QObject* window)
|
||||
{
|
||||
if (m_activePreview == window){
|
||||
m_activePreview = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void ReportEnginePrivate::clearReport()
|
||||
{
|
||||
foreach(PageDesignIntf* page,m_pages) delete page;
|
||||
@ -291,6 +301,8 @@ void ReportEnginePrivate::previewReport()
|
||||
if (!dataManager()->errorsList().isEmpty()){
|
||||
w->setErrorMessages(dataManager()->errorsList());
|
||||
}
|
||||
m_activePreview = w;
|
||||
connect(w,SIGNAL(destroyed(QObject*)), this, SLOT(slotPreviewWindowDestroed(QObject*)));
|
||||
qDebug()<<"render time ="<<start.msecsTo(QTime::currentTime());
|
||||
w->exec();
|
||||
}
|
||||
|
@ -32,6 +32,7 @@
|
||||
|
||||
#include <QObject>
|
||||
#include <QSharedPointer>
|
||||
#include <QMainWindow>
|
||||
#include "lrreportengine.h"
|
||||
#include "lrcollection.h"
|
||||
#include "lrglobal.h"
|
||||
@ -100,6 +101,7 @@ public:
|
||||
QString currentReportsDir(){ return m_reportsDir;}
|
||||
void setReportName(const QString& reportName){ m_reportName=reportName;}
|
||||
QString reportName(){ return m_reportName;}
|
||||
bool hasActivePreview(){return m_activePreview;}
|
||||
signals:
|
||||
void pagesLoadFinished();
|
||||
void datasourceCollectionLoadFinished(const QString& collectionName);
|
||||
@ -115,6 +117,8 @@ protected:
|
||||
PageDesignIntf* createPage(const QString& pageName="");
|
||||
protected slots:
|
||||
void slotDataSourceCollectionLoaded(const QString& collectionName);
|
||||
private slots:
|
||||
void slotPreviewWindowDestroed(QObject *window);
|
||||
private:
|
||||
//ICollectionContainer
|
||||
virtual QObject* createElement(const QString&,const QString&);
|
||||
@ -139,6 +143,7 @@ private:
|
||||
bool m_showProgressDialog;
|
||||
QString m_reportsDir;
|
||||
QString m_reportName;
|
||||
QMainWindow* m_activePreview;
|
||||
};
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user