commit: 2fdb70bfff9392d8634fcbd1ae44ae10fb3f0e75 Author: Holger Hoffstätte <holger <AT> applied-asynchrony <DOT> com> AuthorDate: Sat Apr 26 16:52:58 2025 +0000 Commit: Sam James <sam <AT> gentoo <DOT> org> CommitDate: Sat Apr 26 17:23:39 2025 +0000 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=2fdb70bf
net-analyzer/wireshark: properly return from main() Closes: https://bugs.gentoo.org/954756 Signed-off-by: Holger Hoffstätte <holger <AT> applied-asynchrony.com> Part-of: https://github.com/gentoo/gentoo/pull/41773 Closes: https://github.com/gentoo/gentoo/pull/41773 Signed-off-by: Sam James <sam <AT> gentoo.org> .../wireshark/files/4.4.6-return-from-main.patch | 59 ++++++++++++++++++++++ ...k-4.4.6-r1.ebuild => wireshark-4.4.6-r2.ebuild} | 1 + 2 files changed, 60 insertions(+) diff --git a/net-analyzer/wireshark/files/4.4.6-return-from-main.patch b/net-analyzer/wireshark/files/4.4.6-return-from-main.patch new file mode 100644 index 000000000000..8e523a98c12b --- /dev/null +++ b/net-analyzer/wireshark/files/4.4.6-return-from-main.patch @@ -0,0 +1,59 @@ +Patch from: https://gitlab.com/wireshark/wireshark/-/commit/b4d6d76c6eba2da7f8df55c328607fe651037c03 +Removed hunk #2 which was for Stratoshark. + +From b4d6d76c6eba2da7f8df55c328607fe651037c03 Mon Sep 17 00:00:00 2001 +From: John Thacker <[email protected]> +Date: Sat, 22 Feb 2025 10:19:36 -0500 +Subject: [PATCH] Qt: Return from main instead of calling exit_application + +If the main event loop isn't running (and it can't be if we reach the +clean_exit label in main()), then exit_application just calls stdlib +exit. Returning from main does the same thing, execept the QApplication +(function scoped) will be destroyed first. That's better for dealing +with KDE Breeze mixing thread_local and QThreadStorage and having +deleteLater. It ensures that objects get deleted before all the +thread_local storage is destroyed. + +I can't replicate #14395 after this change, including by putting in +the extra goto clean_exit mentioned in that issue's comments, on +Qt 5.15, Qt 6, and different OSes. + +Fix #20370 +--- + ui/qt/main.cpp | 14 +++++++++++++- + ui/stratoshark/stratoshark_main.cpp | 2 +- + 2 files changed, 14 insertions(+), 2 deletions(-) + +diff --git a/ui/qt/main.cpp b/ui/qt/main.cpp +index e73496d4017..6d22ca43cc9 100644 +--- a/ui/qt/main.cpp ++++ b/ui/qt/main.cpp +@@ -117,9 +117,21 @@ void main_window_update(void) + } + + void exit_application(int status) { ++ // It's generally better to return from main. If the event loop is ++ // running (or has already stopped), wsApp->quit will cause the app ++ // to do so. (So we wouldn't need to call stdlib exit.) If it's not ++ // yet running, e.g., failure parsing options in ui/commandline.c, ++ // it's would be cleaner to return back to main and exit from there, ++ // especially if wsApp has been created. + if (wsApp) { ++ // wsApp->quit() is a no-op if the event loop isn't running ++ // (That was not true in some earlier versions of Qt.) ++ // wsApp->exit(status) is not thread safe, though it may be possible to call ++ //QMetaObject::invokeMethod(wsApp, "exit", Qt::QueuedConnection, status); ++ // or similar, e.g. with a QTimer + wsApp->quit(); + } ++ // Calling stdlib exit here does not call the wsApp destructor. + exit(status); + } + +@@ -1128,5 +1140,5 @@ clean_exit: + wtap_cleanup(); + free_progdirs(); + commandline_options_free(); +- exit_application(ret_val); ++ return ret_val; + } diff --git a/net-analyzer/wireshark/wireshark-4.4.6-r1.ebuild b/net-analyzer/wireshark/wireshark-4.4.6-r2.ebuild similarity index 99% rename from net-analyzer/wireshark/wireshark-4.4.6-r1.ebuild rename to net-analyzer/wireshark/wireshark-4.4.6-r2.ebuild index 3193a70c6df1..122684587be3 100644 --- a/net-analyzer/wireshark/wireshark-4.4.6-r1.ebuild +++ b/net-analyzer/wireshark/wireshark-4.4.6-r2.ebuild @@ -120,6 +120,7 @@ fi PATCHES=( "${FILESDIR}/4.4.4-fix-skipping-rawshark-tests-on-big-endian.patch" "${FILESDIR}/4.4.6-lto.patch" + "${FILESDIR}/4.4.6-return-from-main.patch" ) python_check_deps() {
