From b7ae4f2eb796eb61e02f6063438492bd1df4d4c5 Mon Sep 17 00:00:00 2001 From: Gerald Combs Date: Wed, 7 Feb 2024 14:54:33 -0800 Subject: [PATCH] Qt: Add null checks to the protocol tree eab4734a0d removed actionAnalyzeDecodeAs and actionFileExportPacketBytes from Logray. --- ui/qt/proto_tree.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/ui/qt/proto_tree.cpp b/ui/qt/proto_tree.cpp index 77af8d2277..e1dfaeb559 100644 --- a/ui/qt/proto_tree.cpp +++ b/ui/qt/proto_tree.cpp @@ -356,7 +356,9 @@ void ProtoTree::contextMenuEvent(QContextMenuEvent *event) action = window()->findChild("actionAnalyzeShowPacketBytes"); ctx_menu->addAction(action); action = window()->findChild("actionFileExportPacketBytes"); - ctx_menu->addAction(action); + if (action) { + ctx_menu->addAction(action); + } ctx_menu->addSeparator(); } @@ -395,12 +397,14 @@ void ProtoTree::contextMenuEvent(QContextMenuEvent *event) if (! buildForDialog) { - QAction *decode_as_ = window()->findChild("actionAnalyzeDecodeAs"); - ctx_menu->addAction(decode_as_); - decode_as_->setProperty("create_new", QVariant::fromValue(true)); + QAction *decode_as = window()->findChild("actionAnalyzeDecodeAs"); + if (decode_as) { + ctx_menu->addAction(decode_as); + decode_as->setProperty("create_new", QVariant::fromValue(true)); - ctx_menu->addAction(window()->findChild("actionGoGoToLinkedPacket")); - ctx_menu->addAction(window()->findChild("actionContextShowLinkedPacketInNewWindow")); + ctx_menu->addAction(window()->findChild("actionGoGoToLinkedPacket")); + ctx_menu->addAction(window()->findChild("actionContextShowLinkedPacketInNewWindow")); + } } // The "text only" header field will not give preferences for the selected protocol.