I don't think this is a bug. The new_dialog()
function is non-blocking, creating a non-modal dialog window. So in the question's script it's creating the dialog window but immediately returning to process more of the Lua code, as it should.
I think the right way to code this in Lua is to put the rest of the logic that is currently after new_dialog()
into the callback function assigned by new_dialog()
. In other words, this:
local function reloadAPList(basename)
filename = basename
message("Opening file: " .. filename)
local csv_file = assert(io.open(filename, "r"))
if csv_file==nil then
warn(err)
return
end
-- Read CSV line
local line = csv_file:read()
-- Flush out old table contents
for k,v in pairs(apList) do
apList[k] = nil
end
-- Build AP Object Name List table
apList = fromCSV(line)
end
local function get_filename()
– Request new filename from user
new_dialog("Enter File (without extension)",
reloadAPList,
"Filename")
end
aw:add_button("Reload", get_filename )
answered 29 Jun ‘15, 16:16
Hadriel
2.7k●2●9●39
accept rate: 18%
I guess, we would need more of your code to recreate the problem.
Essentially all you need to do is invoke a new dialog from within a button function. You can see above that aw:add_button calls reloadApList when the button is clicked. In reloadApList I call new_dialog with an inline function to assign the string to a local variable (not shown in code snippet).
The dialog box launches, but the message call after the new_dialog prints the filename from the previous button click.
I hope that helps..
can you please test the following code and post the output of message() here?
The first log entry appeared when I clicked the button. The second and third appeared after I entered a string and clicked OK.
Note that test.csv does not exist and I was expecting the assert on io.open to detect that.
The assert came when I clicked the button for a second time. It looks like the code after the new_dialog executes before the dialog is closed.
strange thing… please file a bug report at https://bugs.wireshark.org