aboutsummaryrefslogtreecommitdiffstats
path: root/ui/qt/funnel_string_dialog.cpp
diff options
context:
space:
mode:
authorStig Bjørlykke <stig@bjorlykke.org>2015-09-03 14:29:06 +0200
committerStig Bjørlykke <stig@bjorlykke.org>2015-09-04 17:33:46 +0000
commit0a68c9d2578ea3432de78c52e4c53bf660eadfb6 (patch)
tree15aa85eb45a4e8f54f9c1eb5cacfff046e6b47a3 /ui/qt/funnel_string_dialog.cpp
parenta69a515f287f1e8a43b5b9034eebdfc56a29a1c9 (diff)
Qt: Destruct FunnelStringDialog when done.
To be able to close all open dialogs (emit a close signal) from a C function this change introduces a FunnelStringDialogHelper class to handle this. Change-Id: Id50e949e5e2b56401ce9228f8fa9ba17dddbd7fb Reviewed-on: https://code.wireshark.org/review/10372 Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org>
Diffstat (limited to 'ui/qt/funnel_string_dialog.cpp')
-rw-r--r--ui/qt/funnel_string_dialog.cpp38
1 files changed, 27 insertions, 11 deletions
diff --git a/ui/qt/funnel_string_dialog.cpp b/ui/qt/funnel_string_dialog.cpp
index 73ef55ddc9..027f779367 100644
--- a/ui/qt/funnel_string_dialog.cpp
+++ b/ui/qt/funnel_string_dialog.cpp
@@ -28,6 +28,9 @@
#include "qt_ui_utils.h"
#include "wireshark_application.h"
+// Helper object used for sending close signal to open dialogs from a C function
+static FunnelStringDialogHelper dialogHelper;
+
const int min_edit_width_ = 20; // em widths
FunnelStringDialog::FunnelStringDialog(const QString title, const QStringList field_name_list, funnel_dlg_cb_t dialog_cb, void *dialog_cb_data) :
QDialog(NULL),
@@ -56,6 +59,22 @@ FunnelStringDialog::~FunnelStringDialog()
delete ui;
}
+void FunnelStringDialog::accept()
+{
+ QDialog::accept();
+
+ disconnect();
+ deleteLater();
+}
+
+void FunnelStringDialog::reject()
+{
+ QDialog::reject();
+
+ disconnect();
+ deleteLater();
+}
+
void FunnelStringDialog::on_buttonBox_accepted()
{
if (!dialog_cb_) return;
@@ -72,15 +91,17 @@ void FunnelStringDialog::on_buttonBox_accepted()
g_ptr_array_free(returns, FALSE);
}
-FunnelStringDialog *FunnelStringDialog::stringDialogNew(const QString title, const QStringList field_name_list, funnel_dlg_cb_t dialog_cb, void *dialog_cb_data)
+void FunnelStringDialog::stringDialogNew(const QString title, const QStringList field_name_list, funnel_dlg_cb_t dialog_cb, void *dialog_cb_data)
{
FunnelStringDialog *fsd = new FunnelStringDialog(title, field_name_list, dialog_cb, dialog_cb_data);
+ connect(&dialogHelper, SIGNAL(closeDialogs()), fsd, SLOT(close()));
fsd->show();
-
- return fsd;
}
-QList<FunnelStringDialog *> openDialogs;
+void FunnelStringDialogHelper::emitCloseDialogs()
+{
+ emit closeDialogs();
+}
void string_dialog_new(const gchar *title, const gchar **fieldnames, funnel_dlg_cb_t dialog_cb, void *dialog_cb_data)
{
@@ -88,17 +109,12 @@ void string_dialog_new(const gchar *title, const gchar **fieldnames, funnel_dlg_
for (int i = 0; fieldnames[i]; i++) {
field_name_list << fieldnames[i];
}
- FunnelStringDialog *fsd = FunnelStringDialog::stringDialogNew(title, field_name_list, dialog_cb, dialog_cb_data);
-
- openDialogs.append (fsd);
+ FunnelStringDialog::stringDialogNew(title, field_name_list, dialog_cb, dialog_cb_data);
}
void string_dialogs_close(void)
{
- foreach (FunnelStringDialog *fsd, openDialogs)
- delete fsd;
-
- openDialogs.clear();
+ dialogHelper.emitCloseDialogs();
}
/*