Merge pull request #1762 from psychon/fix-menubar-traversal

Fix menubar traversal
This commit is contained in:
Daniel Hahler 2017-05-13 23:27:13 +02:00 committed by GitHub
commit 9d1d5d5461
1 changed files with 10 additions and 10 deletions

View File

@ -252,11 +252,10 @@ end
-- @tparam table callback.programs Paths of found .desktop files.
function utils.parse_dir(dir_path, callback)
local function parser(dir, programs)
local f = gio.File.new_for_path(dir)
local function parser(file, programs)
-- Except for "NONE" there is also NOFOLLOW_SYMLINKS
local query = gio.FILE_ATTRIBUTE_STANDARD_NAME .. "," .. gio.FILE_ATTRIBUTE_STANDARD_TYPE
local enum, err = f:async_enumerate_children(query, gio.FileQueryInfoFlags.NONE)
local enum, err = file:async_enumerate_children(query, gio.FileQueryInfoFlags.NONE)
if not enum then
gdebug.print_error(err)
return
@ -270,14 +269,15 @@ function utils.parse_dir(dir_path, callback)
end
for _, info in ipairs(list) do
local file_type = info:get_file_type()
local file_path = enum:get_child(info):get_path()
local file_child = enum:get_child(info)
if file_type == 'REGULAR' then
local program = utils.parse_desktop_file(file_path)
local path = file_child:get_path()
local program = path and utils.parse_desktop_file(path)
if program then
table.insert(programs, program)
end
elseif file_type == 'DIRECTORY' then
parser(file_path, programs)
parser(file_child, programs)
end
end
if #list == 0 then
@ -287,11 +287,11 @@ function utils.parse_dir(dir_path, callback)
enum:async_close()
end
gio.Async.start(function()
gio.Async.start(protected_call.call)(function()
local result = {}
parser(dir_path, result)
protected_call.call(callback, result)
end)()
parser(gio.File.new_for_path(dir_path), result)
callback(result)
end)
end
function utils.compute_textbox_width(textbox, s)