Alloc/free Pcap import options dialog every time

The earlier code was trying to reuse the dialog but this was throwing
an unexpected error every time -

    External WM_DESTROY received for QWidgetWindow

This commit fixes this error message
This commit is contained in:
Srivats P 2021-12-11 21:13:15 +05:30
parent dbdeee2a6f
commit 16b353ae30
4 changed files with 3 additions and 10 deletions

View File

@ -609,7 +609,6 @@ bool Port::openStreams(QString fileName, bool append, QString &error)
int ret; int ret;
optDialog->setParent(mainWindow, Qt::Dialog); optDialog->setParent(mainWindow, Qt::Dialog);
ret = optDialog->exec(); ret = optDialog->exec();
optDialog->setParent(0, Qt::Dialog);
if (ret == QDialog::Rejected) if (ret == QDialog::Rejected)
goto _user_opt_cancel; goto _user_opt_cancel;
} }

View File

@ -44,6 +44,7 @@ PcapImportOptionsDialog::PcapImportOptionsDialog(QVariantMap *options)
: QDialog(NULL) : QDialog(NULL)
{ {
setupUi(this); setupUi(this);
setAttribute(Qt::WA_DeleteOnClose);
options_ = options; options_ = options;
viaPdml->setChecked(options_->value("ViaPdml").toBool()); viaPdml->setChecked(options_->value("ViaPdml").toBool());
@ -72,13 +73,10 @@ PcapFileFormat::PcapFileFormat()
importOptions_.insert("ViaPdml", true); importOptions_.insert("ViaPdml", true);
importOptions_.insert("RecalculateCksums", true); importOptions_.insert("RecalculateCksums", true);
importOptions_.insert("DoDiff", true); importOptions_.insert("DoDiff", true);
importDialog_ = NULL;
} }
PcapFileFormat::~PcapFileFormat() PcapFileFormat::~PcapFileFormat()
{ {
delete importDialog_;
} }
bool PcapFileFormat::open(const QString fileName, bool PcapFileFormat::open(const QString fileName,
@ -709,10 +707,7 @@ _exit:
QDialog* PcapFileFormat::openOptionsDialog() QDialog* PcapFileFormat::openOptionsDialog()
{ {
if (!importDialog_) return new PcapImportOptionsDialog(&importOptions_);
importDialog_ = new PcapImportOptionsDialog(&importOptions_);
return importDialog_;
} }
bool PcapFileFormat::isMyFileFormat(const QString /*fileName*/) bool PcapFileFormat::isMyFileFormat(const QString /*fileName*/)

View File

@ -81,7 +81,6 @@ private:
QDataStream fd_; QDataStream fd_;
QVariantMap importOptions_; QVariantMap importOptions_;
PcapImportOptionsDialog *importDialog_;
}; };
extern PcapFileFormat pcapFileFormat; extern PcapFileFormat pcapFileFormat;

View File

@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>326</width> <width>326</width>
<height>112</height> <height>132</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">