Fix #30 Destroying a report engine does not destroy all it's windows and lead to crash

This commit is contained in:
Arin Alexander 2016-04-21 17:53:31 +03:00
parent 2e4ee6ca05
commit fab352c81c
2 changed files with 21 additions and 8 deletions

View File

@ -67,6 +67,9 @@ ReportEnginePrivate::ReportEnginePrivate(QObject *parent) :
ReportEnginePrivate::~ReportEnginePrivate()
{
if (m_designerWindow) {
m_designerWindow->close();
}
if (m_activePreview){
m_activePreview->close();
}
@ -392,20 +395,28 @@ void ReportEnginePrivate::designReport()
w->setAttribute(Qt::WA_DeleteOnClose,true);
w->setWindowIcon(QIcon(":report/images/logo32"));
w->setShowProgressDialog(m_showProgressDialog);
if (!m_designerWindow) {
m_designerWindow = new LimeReport::ReportDesignWindow(this,QApplication::activeWindow(),settings());
m_designerWindow->setAttribute(Qt::WA_DeleteOnClose,true);
m_designerWindow->setWindowIcon(QIcon(":report/images/logo32"));
m_designerWindow->setShowProgressDialog(m_showProgressDialog);
}
#if defined(Q_OS_MAC)
//w->showModal();
//m_designerWindow->showModal();
#elif defined(Q_OS_UNIX)
//w->showModal();
//m_designerWindow->showModal();
#endif
#ifdef Q_OS_WIN
//w->setWindowFlags(Qt::Window|Qt::WindowMaximizeButtonHint|Qt::WindowCloseButtonHint|Qt::WindowMinimizeButtonHint);
w->setWindowModality(Qt::ApplicationModal);
//w->showModal();
//m_designerWindow->setWindowFlags(Qt::Window|Qt::WindowMaximizeButtonHint|Qt::WindowCloseButtonHint|Qt::WindowMinimizeButtonHint);
m_designerWindow->setWindowModality(Qt::ApplicationModal);
//m_designerWindow->showModal();
#endif
if (QApplication::activeWindow()==0){
w->show();
m_designerWindow->show();;
} else {
w->showModal();
m_designerWindow->showModal();
}
}

View File

@ -46,6 +46,7 @@ namespace LimeReport{
class PageDesignIntf;
class PrintRange;
class ReportDesignWindow;
//TODO: Add on render callback
@ -156,6 +157,7 @@ private:
QMainWindow* m_activePreview;
QIcon m_previewWindowIcon;
QString m_previewWindowTitle;
QPointer<ReportDesignWindow> m_designerWindow;
};
}