Don't crash the editor if drawing a view fails
This commit is contained in:
parent
7115252b62
commit
56ce6d15b6
6
vendor/lite/data/core/init.lua
vendored
6
vendor/lite/data/core/init.lua
vendored
|
@ -237,8 +237,14 @@ function core.push_clip_rect(x, y, w, h)
|
|||
w, h = r-x, b-y
|
||||
table.insert(core.clip_rect_stack, { x, y, w, h })
|
||||
renderer.set_clip_rect(x, y, w, h)
|
||||
return (#core.clip_rect_stack) - 1
|
||||
end
|
||||
|
||||
function core.pop_clip_rect_to(length)
|
||||
while #core.clip_rect_stack > length do
|
||||
core.pop_clip_rect()
|
||||
end
|
||||
end
|
||||
|
||||
function core.pop_clip_rect()
|
||||
table.remove(core.clip_rect_stack)
|
||||
|
|
10
vendor/lite/data/core/rootview.lua
vendored
10
vendor/lite/data/core/rootview.lua
vendored
|
@ -365,9 +365,13 @@ function Node:draw()
|
|||
self:draw_tabs()
|
||||
end
|
||||
local pos, size = self.active_view.position, self.active_view.size
|
||||
core.push_clip_rect(pos.x, pos.y, size.x + pos.x % 1, size.y + pos.y % 1)
|
||||
self.active_view:draw()
|
||||
core.pop_clip_rect()
|
||||
local clipstate = core.push_clip_rect(pos.x, pos.y, size.x + pos.x % 1, size.y + pos.y % 1)
|
||||
xpcall(function() self.active_view:draw() end,
|
||||
function(msg)
|
||||
love.graphics.setCanvas(nil)
|
||||
common.draw_text(style.font, { common.color "#ff0000" }, msg .. "\n" .. debug.traceback(), "left", pos.x, pos.y, size.x, size.y)
|
||||
end)
|
||||
core.pop_clip_rect_to(clipstate)
|
||||
else
|
||||
local x, y, w, h = self:get_divider_rect()
|
||||
renderer.draw_rect(x, y, w, h, style.divider)
|
||||
|
|
Loading…
Reference in a new issue