diff --git a/mainwindow.cpp b/mainwindow.cpp index fcac91b9..86c48b67 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -1466,7 +1466,7 @@ void MainWindow::zoomProfile(bool flag){ profileFv->close(); return; } - profileFv = new QWidget(0); + profileFv = new QWidget(this, Qt::Window); profileFv->setAttribute( Qt::WA_DeleteOnClose ); connect(profileFv,&QObject::destroyed,this, &MainWindow::restoreProfile); QVBoxLayout *l = new QVBoxLayout(); @@ -1481,7 +1481,7 @@ void MainWindow::zoomContour(bool flag){ contourFv->close(); return; } - contourFv = new QWidget(0); + contourFv = new QWidget(this, Qt::Window); contourFv->setAttribute( Qt::WA_DeleteOnClose ); connect(contourFv,&QObject::destroyed,this, &MainWindow::restoreContour); QVBoxLayout *l = new QVBoxLayout(); @@ -1494,7 +1494,7 @@ void MainWindow::zoomContour(bool flag){ void MainWindow::zoomOgl() { - oglFv = new QWidget(0); + oglFv = new QWidget(this, Qt::Window); oglFv->setAttribute( Qt::WA_DeleteOnClose ); connect(oglFv,&QObject::destroyed,this, &MainWindow::restoreOgl); QVBoxLayout *l = new QVBoxLayout(); @@ -2026,7 +2026,8 @@ void MainWindow::on_actionSmooth_current_wave_front_triggered() QMessageBox::warning(this, "No Wavefronts", "You must first load a wave front"); return; } - ZernikeSmoothingDlg *dlg = new ZernikeSmoothingDlg(*sm.m_wavefronts[sm.m_currentNdx]); + ZernikeSmoothingDlg *dlg = new ZernikeSmoothingDlg(*sm.m_wavefronts[sm.m_currentNdx], this); + dlg->setAttribute(Qt::WA_DeleteOnClose); dlg->resize(1000,1000); dlg->show(); return; diff --git a/statsview.cpp b/statsview.cpp index bc19e68a..26bbacb1 100644 --- a/statsview.cpp +++ b/statsview.cpp @@ -12,7 +12,7 @@ #include "myutils.h" #include "utils.h" statsView::statsView(SurfaceManager *parent) : - QDialog(0), + QDialog(qobject_cast(parent ? parent->parent() : nullptr)), ui(new Ui::statsView),m_removeOutliers(false), m_removeRMS(false) { ui->setupUi(this); diff --git a/surfacemanager.cpp b/surfacemanager.cpp index 228f2e35..0084ea64 100644 --- a/surfacemanager.cpp +++ b/surfacemanager.cpp @@ -1564,6 +1564,7 @@ void SurfaceManager::saveAllWaveFrontStats(){ if (m_wavefronts.size() == 0) return; statsView * sv = new statsView(this); + sv->setAttribute(Qt::WA_DeleteOnClose); sv->show(); return; } @@ -2030,7 +2031,6 @@ void SurfaceManager::filter(){ } #include "wftexaminer.h" -wftExaminer *wex; double wrapAngle(double angle){ if (angle < -360){ angle += 360; @@ -2040,7 +2040,12 @@ double wrapAngle(double angle){ return angle; } void SurfaceManager::inspectWavefront(){ - wex = new wftExaminer(m_wavefronts[m_currentNdx]); + wftExaminer *wex = new wftExaminer(m_wavefronts[m_currentNdx], nullptr); + wex->setAttribute(Qt::WA_DeleteOnClose); + if (parent()) { + QObject::connect(parent(), &QObject::destroyed, wex, &QWidget::close); + } + QObject::connect(qApp, &QCoreApplication::aboutToQuit, wex, &QWidget::close); wex->show(); } diff --git a/wftexaminer.cpp b/wftexaminer.cpp index 7cb4fccf..29ef6779 100644 --- a/wftexaminer.cpp +++ b/wftexaminer.cpp @@ -48,6 +48,7 @@ wftExaminer::wftExaminer( wavefront *wf,QWidget *parent) : wftExaminer::~wftExaminer() { + delete m_Pl; delete ui; }