diff options
author | Stig Bjørlykke <stig@bjorlykke.org> | 2021-09-27 13:10:43 +0200 |
---|---|---|
committer | Stig Bjørlykke <stig@bjorlykke.org> | 2021-09-30 11:07:08 +0000 |
commit | 96cfaf67a383cd3676a7dba61040e8c4b7a47b12 (patch) | |
tree | b00b42d4e92b005aeea831d7f7ca20e8f21f54d1 /ui/qt | |
parent | a3c2ad04eed2c3bc0ecfffc90a2d510684a0f2d4 (diff) |
Qt: Reload Lua FileHandler when having a capture file
Support reloading a Lua FileHandler when this is in use for a
loaded capture file. Prompt to save the file if having unsaved
changes because the file must be reloaded.
Fixes #17615
Diffstat (limited to 'ui/qt')
-rw-r--r-- | ui/qt/main_window_slots.cpp | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/ui/qt/main_window_slots.cpp b/ui/qt/main_window_slots.cpp index a6f313d94c..01009f53b9 100644 --- a/ui/qt/main_window_slots.cpp +++ b/ui/qt/main_window_slots.cpp @@ -1529,6 +1529,22 @@ void MainWindow::reloadLuaPlugins() if (wsApp->isReloadingLua()) return; + gboolean uses_lua_filehandler = FALSE; + + if (capture_file_.capFile()) { + // Check if the current capture file is opened with a Lua FileHandler + capture_file *cf = capture_file_.capFile(); + uses_lua_filehandler = wtap_uses_lua_filehandler(cf->provider.wth); + + if (uses_lua_filehandler && cf->unsaved_changes) { + // Prompt to save the file before reloading, in case the FileHandler has changed + QString before_what(tr(" before reloading Lua plugins")); + if (!testCaptureFileClose(before_what, Reload)) { + return; + } + } + } + wsApp->setReloadingLua(true); wslua_reload_plugins(NULL, NULL); @@ -1544,7 +1560,14 @@ void MainWindow::reloadLuaPlugins() prefs_apply_all(); fieldsChanged(); - redissectPackets(); + + if (uses_lua_filehandler) { + // Reload the file in case the FileHandler has changed + cf_reload(capture_file_.capFile()); + proto_free_deregistered_fields(); + } else { + redissectPackets(); + } wsApp->setReloadingLua(false); SimpleDialog::displayQueuedMessages(); |