forked from Mirrorlandia_minetest/minetest
Fix content store crash (#8244)
This commit is contained in:
parent
6e7ba366fc
commit
cc9bed9321
@ -185,16 +185,7 @@ local function get_screenshot(package)
|
|||||||
if not success then
|
if not success then
|
||||||
core.log("warning", "Screenshot download failed for some reason")
|
core.log("warning", "Screenshot download failed for some reason")
|
||||||
end
|
end
|
||||||
|
ui.update()
|
||||||
local ele = ui.childlist.store
|
|
||||||
if ele and not ele.hidden then
|
|
||||||
core.update_formspec(ele:formspec())
|
|
||||||
else
|
|
||||||
ele = ui.childlist.package_view
|
|
||||||
if ele and not ele.hidden then
|
|
||||||
core.update_formspec(ele:formspec())
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
if core.handle_async(download_screenshot,
|
if core.handle_async(download_screenshot,
|
||||||
{ dest = filepath, url = package.thumbnail }, callback) then
|
{ dest = filepath, url = package.thumbnail }, callback) then
|
||||||
@ -245,7 +236,7 @@ function package_dialog.get_formspec()
|
|||||||
return table.concat(formspec, "")
|
return table.concat(formspec, "")
|
||||||
end
|
end
|
||||||
|
|
||||||
function package_dialog.handle_submit(this, fields, tabname, tabdata)
|
function package_dialog.handle_submit(this, fields)
|
||||||
if fields.back then
|
if fields.back then
|
||||||
this:delete()
|
this:delete()
|
||||||
return true
|
return true
|
||||||
@ -395,11 +386,11 @@ function store.filter_packages(query)
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function store.get_formspec()
|
function store.get_formspec(dlgdata)
|
||||||
store.update_paths()
|
store.update_paths()
|
||||||
|
|
||||||
local pages = math.ceil(#store.packages / num_per_page)
|
dlgdata.pagemax = math.max(math.ceil(#store.packages / num_per_page), 1)
|
||||||
if cur_page > pages then
|
if cur_page > dlgdata.pagemax then
|
||||||
cur_page = 1
|
cur_page = 1
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -428,7 +419,7 @@ function store.get_formspec()
|
|||||||
"button[8.1,0;1,1;pback;<]",
|
"button[8.1,0;1,1;pback;<]",
|
||||||
"label[9.2,0.2;",
|
"label[9.2,0.2;",
|
||||||
tonumber(cur_page), " / ",
|
tonumber(cur_page), " / ",
|
||||||
tonumber(pages), "]",
|
tonumber(dlgdata.pagemax), "]",
|
||||||
"button[10.1,0;1,1;pnext;>]",
|
"button[10.1,0;1,1;pnext;>]",
|
||||||
"button[11.1,0;1,1;pend;>>]",
|
"button[11.1,0;1,1;pend;>>]",
|
||||||
"container_end[]",
|
"container_end[]",
|
||||||
@ -515,12 +506,11 @@ function store.get_formspec()
|
|||||||
return table.concat(formspec, "")
|
return table.concat(formspec, "")
|
||||||
end
|
end
|
||||||
|
|
||||||
function store.handle_submit(this, fields, tabname, tabdata)
|
function store.handle_submit(this, fields)
|
||||||
if fields.search or fields.key_enter_field == "search_string" then
|
if fields.search or fields.key_enter_field == "search_string" then
|
||||||
search_string = fields.search_string:trim()
|
search_string = fields.search_string:trim()
|
||||||
cur_page = 1
|
cur_page = 1
|
||||||
store.filter_packages(search_string)
|
store.filter_packages(search_string)
|
||||||
core.update_formspec(store.get_formspec())
|
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -531,34 +521,28 @@ function store.handle_submit(this, fields, tabname, tabdata)
|
|||||||
|
|
||||||
if fields.pstart then
|
if fields.pstart then
|
||||||
cur_page = 1
|
cur_page = 1
|
||||||
core.update_formspec(store.get_formspec())
|
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
if fields.pend then
|
if fields.pend then
|
||||||
cur_page = math.ceil(#store.packages / num_per_page)
|
cur_page = this.data.pagemax
|
||||||
core.update_formspec(store.get_formspec())
|
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
if fields.pnext then
|
if fields.pnext then
|
||||||
cur_page = cur_page + 1
|
cur_page = cur_page + 1
|
||||||
local pages = math.ceil(#store.packages / num_per_page)
|
if cur_page > this.data.pagemax then
|
||||||
if cur_page > pages then
|
|
||||||
cur_page = 1
|
cur_page = 1
|
||||||
end
|
end
|
||||||
core.update_formspec(store.get_formspec())
|
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
if fields.pback then
|
if fields.pback then
|
||||||
if cur_page == 1 then
|
if cur_page == 1 then
|
||||||
local pages = math.ceil(#store.packages / num_per_page)
|
cur_page = this.data.pagemax
|
||||||
cur_page = pages
|
|
||||||
else
|
else
|
||||||
cur_page = cur_page - 1
|
cur_page = cur_page - 1
|
||||||
end
|
end
|
||||||
core.update_formspec(store.get_formspec())
|
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user