Qt: Make Lua dialogs children of the main window.
Pass the funnel operations ID to new_text_window and new_dialog so that we can assign parent widgets when we create new FunnelTextDialogs and FunnelStringDialog. This should ensure that they're destroyed properly. Ping #17590.
This commit is contained in:
parent
64275ff196
commit
6ee1390b86
|
@ -48,7 +48,7 @@ struct progdlg;
|
||||||
|
|
||||||
typedef struct _funnel_ops_t {
|
typedef struct _funnel_ops_t {
|
||||||
funnel_ops_id_t *ops_id;
|
funnel_ops_id_t *ops_id;
|
||||||
funnel_text_window_t* (*new_text_window)(const char* label);
|
funnel_text_window_t* (*new_text_window)(funnel_ops_id_t *ops_id, const char* label);
|
||||||
void (*set_text)(funnel_text_window_t* win, const char* text);
|
void (*set_text)(funnel_text_window_t* win, const char* text);
|
||||||
void (*append_text)(funnel_text_window_t* win, const char* text);
|
void (*append_text)(funnel_text_window_t* win, const char* text);
|
||||||
void (*prepend_text)(funnel_text_window_t* win, const char* text);
|
void (*prepend_text)(funnel_text_window_t* win, const char* text);
|
||||||
|
@ -59,7 +59,8 @@ typedef struct _funnel_ops_t {
|
||||||
void (*destroy_text_window)(funnel_text_window_t* win);
|
void (*destroy_text_window)(funnel_text_window_t* win);
|
||||||
void (*add_button)(funnel_text_window_t* win, funnel_bt_t* cb, const char* label);
|
void (*add_button)(funnel_text_window_t* win, funnel_bt_t* cb, const char* label);
|
||||||
|
|
||||||
void (*new_dialog)(const gchar* title,
|
void (*new_dialog)(funnel_ops_id_t *ops_id,
|
||||||
|
const gchar* title,
|
||||||
const gchar** field_names,
|
const gchar** field_names,
|
||||||
const gchar** field_values,
|
const gchar** field_values,
|
||||||
funnel_dlg_cb_t dlg_cb,
|
funnel_dlg_cb_t dlg_cb,
|
||||||
|
|
|
@ -341,7 +341,7 @@ Instead of a strings it is possible to provide tables with fields 'name' and 'va
|
||||||
g_ptr_array_add(field_names, NULL);
|
g_ptr_array_add(field_names, NULL);
|
||||||
g_ptr_array_add(field_values, NULL);
|
g_ptr_array_add(field_values, NULL);
|
||||||
|
|
||||||
ops->new_dialog(title, (const gchar**)(field_names->pdata), (const gchar**)(field_values->pdata), lua_dialog_cb, dcbd, g_free);
|
ops->new_dialog(ops->ops_id, title, (const gchar**)(field_names->pdata), (const gchar**)(field_values->pdata), lua_dialog_cb, dcbd, g_free);
|
||||||
|
|
||||||
g_ptr_array_free(field_names, TRUE);
|
g_ptr_array_free(field_names, TRUE);
|
||||||
g_ptr_array_free(field_values, TRUE);
|
g_ptr_array_free(field_values, TRUE);
|
||||||
|
@ -606,7 +606,7 @@ WSLUA_CONSTRUCTOR TextWindow_new(lua_State* L) { /*
|
||||||
title = luaL_optstring(L,WSLUA_OPTARG_TextWindow_new_TITLE, "Untitled Window");
|
title = luaL_optstring(L,WSLUA_OPTARG_TextWindow_new_TITLE, "Untitled Window");
|
||||||
tw = g_new(struct _wslua_tw, 1);
|
tw = g_new(struct _wslua_tw, 1);
|
||||||
tw->expired = FALSE;
|
tw->expired = FALSE;
|
||||||
tw->ws_tw = ops->new_text_window(title);
|
tw->ws_tw = ops->new_text_window(ops->ops_id, title);
|
||||||
|
|
||||||
default_cbd = g_new(struct _close_cb_data, 1);
|
default_cbd = g_new(struct _close_cb_data, 1);
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,7 @@ struct _funnel_text_window_t {
|
||||||
|
|
||||||
static GPtrArray *text_windows = NULL;
|
static GPtrArray *text_windows = NULL;
|
||||||
|
|
||||||
static funnel_text_window_t *new_text_window(const gchar *title) {
|
static funnel_text_window_t *new_text_window(funnel_ops_id_t *ops_id _U_, const gchar *title) {
|
||||||
funnel_text_window_t *tw = g_new(funnel_text_window_t, 1);
|
funnel_text_window_t *tw = g_new(funnel_text_window_t, 1);
|
||||||
tw->title = g_strdup(title);
|
tw->title = g_strdup(title);
|
||||||
tw->text = g_string_new("");
|
tw->text = g_string_new("");
|
||||||
|
|
|
@ -39,6 +39,9 @@
|
||||||
// - Add a FunnelGraphDialog class?
|
// - Add a FunnelGraphDialog class?
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
static struct _funnel_text_window_t* text_window_new(funnel_ops_id_t *ops_id, const char* title);
|
||||||
|
static void string_dialog_new(funnel_ops_id_t *ops_id, const gchar* title, const gchar** field_names, const gchar** field_values, funnel_dlg_cb_t dialog_cb, void* dialog_cb_data, funnel_dlg_cb_data_free_t dialog_cb_data_free);
|
||||||
|
|
||||||
static void funnel_statistics_logger(const gchar *, enum ws_log_level, const gchar *message, gpointer);
|
static void funnel_statistics_logger(const gchar *, enum ws_log_level, const gchar *message, gpointer);
|
||||||
static void funnel_statistics_retap_packets(funnel_ops_id_t *ops_id);
|
static void funnel_statistics_retap_packets(funnel_ops_id_t *ops_id);
|
||||||
static void funnel_statistics_copy_to_clipboard(GString *text);
|
static void funnel_statistics_copy_to_clipboard(GString *text);
|
||||||
|
@ -224,6 +227,26 @@ void FunnelStatistics::displayFilterTextChanged(const QString &filter)
|
||||||
display_filter_ = filter.toUtf8();
|
display_filter_ = filter.toUtf8();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct _funnel_text_window_t* text_window_new(funnel_ops_id_t *ops_id, const char* title)
|
||||||
|
{
|
||||||
|
return FunnelTextDialog::textWindowNew(qobject_cast<QWidget *>(ops_id->funnel_statistics->parent()), title);
|
||||||
|
}
|
||||||
|
|
||||||
|
void string_dialog_new(funnel_ops_id_t *ops_id, const gchar* title, const gchar** field_names, const gchar** field_values, funnel_dlg_cb_t dialog_cb, void* dialog_cb_data, funnel_dlg_cb_data_free_t dialog_cb_data_free)
|
||||||
|
{
|
||||||
|
QList<QPair<QString, QString>> field_list;
|
||||||
|
for (int i = 0; field_names[i]; i++) {
|
||||||
|
QPair<QString, QString> field = QPair<QString, QString>(QString(field_names[i]), QString(""));
|
||||||
|
if (field_values != NULL && field_values[i])
|
||||||
|
{
|
||||||
|
field.second = QString(field_values[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
field_list << field;
|
||||||
|
}
|
||||||
|
FunnelStringDialog::stringDialogNew(qobject_cast<QWidget *>(ops_id->funnel_statistics->parent()), title, field_list, dialog_cb, dialog_cb_data, dialog_cb_data_free);
|
||||||
|
}
|
||||||
|
|
||||||
void funnel_statistics_logger(const gchar *log_domain,
|
void funnel_statistics_logger(const gchar *log_domain,
|
||||||
enum ws_log_level log_level,
|
enum ws_log_level log_level,
|
||||||
const gchar *message,
|
const gchar *message,
|
||||||
|
|
|
@ -13,7 +13,6 @@
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
#include "capture_file.h"
|
#include "capture_file.h"
|
||||||
#include "funnel_text_dialog.h"
|
|
||||||
#include <ui/qt/filter_action.h>
|
#include <ui/qt/filter_action.h>
|
||||||
|
|
||||||
struct _funnel_ops_t;
|
struct _funnel_ops_t;
|
||||||
|
|
|
@ -20,8 +20,8 @@
|
||||||
static FunnelStringDialogHelper dialog_helper_;
|
static FunnelStringDialogHelper dialog_helper_;
|
||||||
|
|
||||||
const int min_edit_width_ = 20; // em widths
|
const int min_edit_width_ = 20; // em widths
|
||||||
FunnelStringDialog::FunnelStringDialog(const QString title, const QList<QPair<QString, QString>> field_list, funnel_dlg_cb_t dialog_cb, void* dialog_cb_data, funnel_dlg_cb_data_free_t dialog_data_free_cb) :
|
FunnelStringDialog::FunnelStringDialog(QWidget *parent, const QString title, const QList<QPair<QString, QString>> field_list, funnel_dlg_cb_t dialog_cb, void* dialog_cb_data, funnel_dlg_cb_data_free_t dialog_data_free_cb) :
|
||||||
QDialog(NULL),
|
QDialog(parent),
|
||||||
ui(new Ui::FunnelStringDialog),
|
ui(new Ui::FunnelStringDialog),
|
||||||
dialog_cb_(dialog_cb),
|
dialog_cb_(dialog_cb),
|
||||||
dialog_cb_data_(dialog_cb_data),
|
dialog_cb_data_(dialog_cb_data),
|
||||||
|
@ -85,9 +85,9 @@ void FunnelStringDialog::on_buttonBox_accepted()
|
||||||
dialog_cb_(user_input, dialog_cb_data_);
|
dialog_cb_(user_input, dialog_cb_data_);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FunnelStringDialog::stringDialogNew(const QString title, QList<QPair<QString, QString>> field_list, funnel_dlg_cb_t dialog_cb, void* dialog_cb_data, funnel_dlg_cb_data_free_t dialog_cb_data_free)
|
void FunnelStringDialog::stringDialogNew(QWidget *parent, const QString title, QList<QPair<QString, QString>> field_list, funnel_dlg_cb_t dialog_cb, void* dialog_cb_data, funnel_dlg_cb_data_free_t dialog_cb_data_free)
|
||||||
{
|
{
|
||||||
FunnelStringDialog* fsd = new FunnelStringDialog(title, field_list, dialog_cb, dialog_cb_data, dialog_cb_data_free);
|
FunnelStringDialog* fsd = new FunnelStringDialog(parent, title, field_list, dialog_cb, dialog_cb_data, dialog_cb_data_free);
|
||||||
connect(&dialog_helper_, &FunnelStringDialogHelper::closeDialogs, fsd, &FunnelStringDialog::close);
|
connect(&dialog_helper_, &FunnelStringDialogHelper::closeDialogs, fsd, &FunnelStringDialog::close);
|
||||||
fsd->show();
|
fsd->show();
|
||||||
}
|
}
|
||||||
|
@ -97,21 +97,6 @@ void FunnelStringDialogHelper::emitCloseDialogs()
|
||||||
emit closeDialogs();
|
emit closeDialogs();
|
||||||
}
|
}
|
||||||
|
|
||||||
void string_dialog_new(const gchar* title, const gchar** field_names, const gchar** field_values, funnel_dlg_cb_t dialog_cb, void* dialog_cb_data, funnel_dlg_cb_data_free_t dialog_cb_data_free)
|
|
||||||
{
|
|
||||||
QList<QPair<QString, QString>> field_list;
|
|
||||||
for (int i = 0; field_names[i]; i++) {
|
|
||||||
QPair<QString, QString> field = QPair<QString, QString>(QString(field_names[i]), QString(""));
|
|
||||||
if (field_values != NULL && field_values[i])
|
|
||||||
{
|
|
||||||
field.second = QString(field_values[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
field_list << field;
|
|
||||||
}
|
|
||||||
FunnelStringDialog::stringDialogNew(title, field_list, dialog_cb, dialog_cb_data, dialog_cb_data_free);
|
|
||||||
}
|
|
||||||
|
|
||||||
void string_dialogs_close(void)
|
void string_dialogs_close(void)
|
||||||
{
|
{
|
||||||
dialog_helper_.emitCloseDialogs();
|
dialog_helper_.emitCloseDialogs();
|
||||||
|
|
|
@ -28,11 +28,11 @@ class FunnelStringDialog : public QDialog
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit FunnelStringDialog(const QString title, const QList<QPair<QString, QString>> field_list, funnel_dlg_cb_t dialog_cb, void* dialog_cb_data, funnel_dlg_cb_data_free_t dialog_data_free_cb);
|
explicit FunnelStringDialog(QWidget *parent, const QString title, const QList<QPair<QString, QString>> field_list, funnel_dlg_cb_t dialog_cb, void* dialog_cb_data, funnel_dlg_cb_data_free_t dialog_data_free_cb);
|
||||||
~FunnelStringDialog();
|
~FunnelStringDialog();
|
||||||
|
|
||||||
// Funnel ops
|
// Funnel ops
|
||||||
static void stringDialogNew(const QString title, const QList<QPair<QString, QString>> field_list, funnel_dlg_cb_t dialog_cb, void* dialog_cb_data, funnel_dlg_cb_data_free_t dialog_cb_data_free);
|
static void stringDialogNew(QWidget *parent, const QString title, const QList<QPair<QString, QString>> field_list, funnel_dlg_cb_t dialog_cb, void* dialog_cb_data, funnel_dlg_cb_data_free_t dialog_cb_data_free);
|
||||||
|
|
||||||
void accept();
|
void accept();
|
||||||
void reject();
|
void reject();
|
||||||
|
@ -60,7 +60,6 @@ signals:
|
||||||
};
|
};
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
void string_dialog_new(const gchar* title, const gchar** field_names, const gchar** field_values, funnel_dlg_cb_t dialog_cb, void* dialog_cb_data, funnel_dlg_cb_data_free_t dialog_cb_data_free);
|
|
||||||
void string_dialogs_close(void);
|
void string_dialogs_close(void);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,8 +25,8 @@
|
||||||
|
|
||||||
static QHash<QObject *, funnel_bt_t*> text_button_to_funnel_button_;
|
static QHash<QObject *, funnel_bt_t*> text_button_to_funnel_button_;
|
||||||
|
|
||||||
FunnelTextDialog::FunnelTextDialog(const QString &title) :
|
FunnelTextDialog::FunnelTextDialog(QWidget *parent, const QString &title) :
|
||||||
GeometryStateDialog(NULL),
|
GeometryStateDialog(parent),
|
||||||
ui(new Ui::FunnelTextDialog),
|
ui(new Ui::FunnelTextDialog),
|
||||||
close_cb_(NULL),
|
close_cb_(NULL),
|
||||||
close_cb_data_(NULL)
|
close_cb_data_(NULL)
|
||||||
|
@ -73,9 +73,9 @@ void FunnelTextDialog::reject()
|
||||||
deleteLater();
|
deleteLater();
|
||||||
}
|
}
|
||||||
|
|
||||||
struct _funnel_text_window_t *FunnelTextDialog::textWindowNew(const QString title)
|
struct _funnel_text_window_t *FunnelTextDialog::textWindowNew(QWidget *parent, const QString title)
|
||||||
{
|
{
|
||||||
FunnelTextDialog *ftd = new FunnelTextDialog(title);
|
FunnelTextDialog *ftd = new FunnelTextDialog(parent, title);
|
||||||
ftd->show();
|
ftd->show();
|
||||||
return &ftd->funnel_text_window_;
|
return &ftd->funnel_text_window_;
|
||||||
}
|
}
|
||||||
|
@ -170,11 +170,6 @@ void FunnelTextDialog::on_findLineEdit_textChanged(const QString &pattern)
|
||||||
setUpdatesEnabled(true);
|
setUpdatesEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct _funnel_text_window_t* text_window_new(const char* title)
|
|
||||||
{
|
|
||||||
return FunnelTextDialog::textWindowNew(title);
|
|
||||||
}
|
|
||||||
|
|
||||||
void text_window_set_text(funnel_text_window_t *ftw, const char* text)
|
void text_window_set_text(funnel_text_window_t *ftw, const char* text)
|
||||||
{
|
{
|
||||||
if (ftw) {
|
if (ftw) {
|
||||||
|
|
|
@ -31,13 +31,13 @@ class FunnelTextDialog : public GeometryStateDialog
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit FunnelTextDialog(const QString &title = QString());
|
explicit FunnelTextDialog(QWidget *parent, const QString &title = QString());
|
||||||
~FunnelTextDialog();
|
~FunnelTextDialog();
|
||||||
|
|
||||||
void reject();
|
void reject();
|
||||||
|
|
||||||
// Funnel ops
|
// Funnel ops
|
||||||
static struct _funnel_text_window_t *textWindowNew(const QString title);
|
static struct _funnel_text_window_t *textWindowNew(QWidget *parent, const QString title);
|
||||||
void setText(const QString text);
|
void setText(const QString text);
|
||||||
void appendText(const QString text);
|
void appendText(const QString text);
|
||||||
void prependText(const QString text);
|
void prependText(const QString text);
|
||||||
|
@ -60,7 +60,6 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
struct _funnel_text_window_t* text_window_new(const char* title);
|
|
||||||
void text_window_set_text(funnel_text_window_t* ftw, const char* text);
|
void text_window_set_text(funnel_text_window_t* ftw, const char* text);
|
||||||
void text_window_append(funnel_text_window_t *ftw, const char* text);
|
void text_window_append(funnel_text_window_t *ftw, const char* text);
|
||||||
void text_window_prepend(funnel_text_window_t* ftw, const char* text);
|
void text_window_prepend(funnel_text_window_t* ftw, const char* text);
|
||||||
|
|
|
@ -666,7 +666,7 @@ void InterfaceToolbar::onLogButtonClicked()
|
||||||
|
|
||||||
if (!interface_[ifname].log_dialog.contains(num))
|
if (!interface_[ifname].log_dialog.contains(num))
|
||||||
{
|
{
|
||||||
interface_[ifname].log_dialog[num] = new FunnelTextDialog(ifname + " " + button->text());
|
interface_[ifname].log_dialog[num] = new FunnelTextDialog(window(), ifname + " " + button->text());
|
||||||
connect(interface_[ifname].log_dialog[num], SIGNAL(accepted()), this, SLOT(closeLog()));
|
connect(interface_[ifname].log_dialog[num], SIGNAL(accepted()), this, SLOT(closeLog()));
|
||||||
connect(interface_[ifname].log_dialog[num], SIGNAL(rejected()), this, SLOT(closeLog()));
|
connect(interface_[ifname].log_dialog[num], SIGNAL(rejected()), this, SLOT(closeLog()));
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue