Revert "Qt: fix memory leaks found by Visual Leak Detector"

This reverts commit c2edb44a9a.

While we should definitely avoid leaking memory, this runs up against
the Qt code's assumption that it will always have valid epan data.

Fixes #17590.
Fixes #17719.
This commit is contained in:
Gerald Combs 2021-11-10 11:48:26 -08:00
parent 7a30021aef
commit eda588d1a6
4 changed files with 17 additions and 12 deletions

View File

@ -155,8 +155,13 @@ FunnelStatistics::FunnelStatistics(QObject *parent, CaptureFile &cf) :
FunnelStatistics::~FunnelStatistics()
{
delete(funnel_ops_id_);
delete(funnel_ops_);
// At this point we're probably closing the program and will shortly
// call epan_cleanup, which calls ProgDlg__gc and TextWindow__gc.
// They in turn depend on funnel_ops_ being valid.
memset(funnel_ops_id_, 0, sizeof(struct _funnel_ops_id_t));
memset(funnel_ops_, 0, sizeof(struct _funnel_ops_t));
// delete(funnel_ops_id_);
// delete(funnel_ops_);
}
void FunnelStatistics::retapPackets()

View File

@ -680,7 +680,7 @@ int main(int argc, char *qt_argv[])
#endif
/* Create The Wireshark app */
wsApp = new WiresharkApplication(argc, qt_argv);
WiresharkApplication ws_app(argc, qt_argv);
/* initialize the funnel mini-api */
// xxx qtshark
@ -724,9 +724,9 @@ int main(int argc, char *qt_argv[])
main_w->show();
// We may not need a queued connection here but it would seem to make sense
// to force the issue.
main_w->connect(wsApp, SIGNAL(openCaptureFile(QString,QString,unsigned int)),
main_w->connect(&ws_app, SIGNAL(openCaptureFile(QString,QString,unsigned int)),
main_w, SLOT(openCaptureFile(QString,QString,unsigned int)));
main_w->connect(wsApp, SIGNAL(openCaptureOptions()),
main_w->connect(&ws_app, SIGNAL(openCaptureOptions()),
main_w, SLOT(on_actionCaptureOptions_triggered()));
/* Init the "Open file" dialog directory */
@ -819,7 +819,7 @@ int main(int argc, char *qt_argv[])
ws_log(LOG_DOMAIN_MAIN, LOG_LEVEL_INFO, "Calling module preferences, elapsed time %" G_GUINT64_FORMAT " us \n", g_get_monotonic_time() - start_time);
#endif
global_commandline_info.prefs_p = wsApp->readConfigurationFiles(false);
global_commandline_info.prefs_p = ws_app.readConfigurationFiles(false);
/* Now get our args */
commandline_other_options(argc, argv, TRUE);
@ -1049,13 +1049,11 @@ int main(int argc, char *qt_argv[])
profile_store_persconffiles(FALSE);
ret_val = wsApp->exec();
recent_cleanup();
epan_cleanup();
wsApp = NULL;
delete main_w;
delete wsApp;
wsApp = NULL;
recent_cleanup();
epan_cleanup();
extcap_cleanup();

View File

@ -523,7 +523,7 @@ void PacketDiagram::resetScene(bool reset_root)
if (scene()) {
delete scene();
}
QGraphicsScene *new_scene = new QGraphicsScene(this);
QGraphicsScene *new_scene = new QGraphicsScene();
setScene(new_scene);
connect(new_scene, &QGraphicsScene::selectionChanged, this, &PacketDiagram::sceneSelectionChanged);
setRootNode(reset_root ? nullptr : root_node_);

View File

@ -629,6 +629,7 @@ WiresharkApplication::WiresharkApplication(int &argc, char **argv) :
if_notifier_(NULL),
active_captures_(0)
{
wsApp = this;
setApplicationName("Wireshark");
MimeDatabaseInitThread *mime_db_init_thread = new(MimeDatabaseInitThread);
@ -778,6 +779,7 @@ WiresharkApplication::WiresharkApplication(int &argc, char **argv) :
WiresharkApplication::~WiresharkApplication()
{
wsApp = NULL;
clearDynamicMenuGroupItems();
free_filter_lists();
}