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:
Guldoman 2021-08-30 19:19:57 +02:00
parent 7cabc4032c
commit 07dbbc6cd8
No known key found for this signature in database
GPG Key ID: C08A498EC7F1AFDD
3 changed files with 4 additions and 12 deletions

View File

@ -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 {

View File

@ -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)

View File

@ -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.