Remove `View:extend` override
Call directly `core.register_view(name, class)` to register a `View`. The `registered_name` field will be populated automatically.
This commit is contained in:
parent
7cabc4032c
commit
07dbbc6cd8
|
@ -7,10 +7,12 @@ local translate = require "core.doc.translate"
|
|||
local View = require "core.view"
|
||||
|
||||
|
||||
local DocView = View:extend("DocView")
|
||||
local DocView = View:extend()
|
||||
|
||||
DocView.context = "session"
|
||||
|
||||
core.register_view("doc", DocView)
|
||||
|
||||
|
||||
function DocView:get_content()
|
||||
return {
|
||||
|
|
|
@ -39,6 +39,7 @@ end
|
|||
local registered_views = { }
|
||||
function core.register_view(name, class)
|
||||
registered_views[name] = class
|
||||
class.registered_name = name
|
||||
end
|
||||
|
||||
function core.get_registered_view(name)
|
||||
|
|
|
@ -8,17 +8,6 @@ local Object = require "core.object"
|
|||
local View = Object:extend()
|
||||
|
||||
|
||||
-- Override how objects are created. This allows for automatic Views registration
|
||||
function View:extend(register_name)
|
||||
local new_class = View.super.extend(self)
|
||||
if register_name then
|
||||
new_class.registered_name = register_name
|
||||
core.register_view(register_name, new_class)
|
||||
end
|
||||
return new_class
|
||||
end
|
||||
|
||||
|
||||
-- context can be "application" or "session". The instance of objects
|
||||
-- with context "session" will be closed when a project session is
|
||||
-- terminated. The context "application" is for functional UI elements.
|
||||
|
|
Loading…
Reference in New Issue