-
Notifications
You must be signed in to change notification settings - Fork 347
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
MythContext refactoring (remove gContext) #671
Conversation
c8c801d
to
da41b45
Compare
da41b45
to
7b78dfa
Compare
7b78dfa
to
a57d74a
Compare
fb1529a
to
0b0e75b
Compare
I plan on doing more later, but this stands on its own and I want to work on other things first. |
83984ea
to
f3b3de8
Compare
I like the idea, but there appear to be multiple orthogonal sets of changes here.
This should be split into multiple pull requests. |
This was the main goal at this time.
OK, this is probably independent, but I found it while removing mythcorecontext.h from header files.
Moving the constants to configuration.h was necessary to move the DatabaseParamCache into MythDB. Moving to ssdp.h was just to put the remaining constant in a better place.
I got tired of having to recompile basically every file unnecessarily due to transitive includes from header files. Except for removing mythcontext.h, I think this can be split off.
pidfile is only used by mythbackend. I saw it was unused so I removed its unused instances. The command line parsers need additional modification to remove the unused option, however.
I must have noticed that when removing mythcorecontext.h, but it should be independent.
I'll reorder and open more pull requests. |
These details do not need to be exposed in the header since MythContextPrivate is already a QObject.
Convert it to a nested private class and rename MythContext::d to m_impl.
It was only used once by a line from commit 0d4ef8e Use MythContext::Impl's own members and methods instead of redirecting back to them through MythContext.
Whether to show the prompt was never determined at runtime and in one case was forced regardless of whether or not a temporary window already existed (which would have prevented the prompt from showing as it would return early from TempMainWindow()).
and directly access the MythDB singleton. This should help reasoning about further changes.
…calls The only functional difference is that m_dbParams::m_localEnabled is now conditionally set before the first `gCoreContext->GetDB()->SetDatabaseParams(m_dbParams);` call. This doesn't matter since it was set before the second SetDatabaseParams() call, likely via ResetDatabase(). This split is to enable refactoring out the DatabaseSettingsCache into its own class by reducing LoadDatabaseSettings() to its core functionality. This is necessary to enable loading the cache in its constructor before the MythCoreContext constructor has finished, i.e. while gCoreContext is nullptr.
…ingleton This should allow moving the DatabaseSettingsCache to MythDB since save can now be called at any time.
It was never set nor reset and would thus not work as intended.
It was only used twice and I will replace one of those uses shortly.
This is to simplify moving the cache to MythDB. DatabaseParamsCache::SaveDatabaseParams(): inline ResetDatabase(), removing the duplicate call to MythDB::SetDatabaseParams().
If the string is already empty then clearing it does nothing and the DatabaseParams are already equal.
GetMythDB() will always return a valid pointer to the global MythDB instance. Some of the functions previously did not update the DatabaseParams in MythDB; however, this shouldn't make a difference since only libmyth/mythcontext.cpp ever called MythDB::SetDatabaseParams(). gContext is now unused in the libraries and can be removed.
After much investigation, I discovered that the popup the hack is supposed to be preventing has not existed since it was replaced with a notification in 2013 in 7dcf2a5
Convert it into an instance so the destructor is called automatically. mythtv-setup: SetupMenuCallback() does not use the data pointer, so feed it with nullptr. mythfrontend: TVMenuCallback() also does not use the data pointer, so feed it with nullptr. mythbackend: httpconfig.cpp: The only HttpConfig is created in MediaServer::Init() which is only called in run_backend() after the MythContext is created in main(), so that check was always false. V2Myth::s_WebOnlyStartup: I would have prefered to avoid global state and pass it as a parameter to V2Myth() via run_backend() and run_setup_webserver() but the entire class is already static. V2Myth is a better place for WebOnlyStartup since that is the only place it is used. CleanupGuards: Move the CleanupGuard instance after the MythContext, so it is destroyed first. ~MythCoreContextPrivate() calls MThread::Cleanup() which wants all threads to already be destroyed. Move DestroyMythMainWindow() into ~MythContext() so the static MythUDP instance destroys its thread. ReferenceCounter::PrintDebug(): remove extraneous ui include and move into ~MythContext() so it is called after all objects should be destroyed.
I would have preferred to make it into an instance within MythContext, but libmythtv/tv_play.cpp uses SignalHandler::IsExiting(), which seems like a hack. From: MythTV@f9a46e0 If _WIN32 is defined, the SignalHandler will only create its initial strings. mythfrontend's extra signal handlers are triggered externally and are from: MythTV@4b67e3e MythTV@2aa4aa5
c74b8b0
to
e198c2a
Compare
I had planned to do more, but I got fed up with the use of global state and Singletons, so this is all I have done for now.
Checklist