-
-
Notifications
You must be signed in to change notification settings - Fork 410
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
When should the NapariApplication
be instantiated and its actions registered?
#6778
Comments
Thinking about this, where else do we get the app via |
From my reading of the
If at some point we want to implement a plugin-less app, we just need to call
this is definitely a bit weird, but I don't know enough about the architecture to comment intelligently about whether it's worth rejiggering it. |
Rejigging it would be trivial, we'd just move the |
Yeah this seems reasonable. I checked and if we don't init plugins, the app would be first instantiated when building the menu bar (in qt main window) (just FYI, this doesn't change anything)
No strong opinion either but I think it makes sense to move it. We make an effort to separate non-qt and qt napari actions so we may as well do the same for plugins. It would also avoid us having to use the safe register of plugin qt actions. |
🧰 Task
When is
app
created?When we initialize a
napari.Viewer
, we must also instantiate theNapariApplication
object (which is ourapp-model
app). The application is created when theget_app
class method is first called.Currently, this first call happens during execution of the
intialize_plugins
function, which is called first thing onViewer.__init__
and registers npe2 plugin actions.Is it strange that the
NapariApplication
, which is so critical to theViewer
and its function, is created in this little function rather than explicitly before we register manifest actions etc.? It seemed to @lucyleeow and I that it was a little hidden and potentially could lead to issues? So wanted to open for discussion.When are
actions
registered?** I say actions here for brevity but these steps also include registering providers and processors.
NapariApplication.__init__
. This seems normal to me.QtMainWindow.__init__
. Also seems normal to me I guess - not sure if there's meaning to moving it up or down in the function.initialize_plugins
as above (which is up first onViewer.__init__
). This means it happens after internal non-qt actions and before internal/plugin qt actions. I think this is also ok.Viewer
provider. @lucyleeow and I thought maybe this was kinda weird, and we should potentially consider splitting this out so that qt plugin actions are only registered afterinit_qactions
?Just a final note: in practice none of this seems to have caused any issues, and it may never. Everything is registered and available by the time the
Viewer
is returned. We just wanted to explicitly consider whether this is the right order of operations and whether there might be any potentially unintended consequences of the current setup down the line.The text was updated successfully, but these errors were encountered: