Skip to content
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

Configuration caches #435

Closed
wants to merge 16 commits into from
Closed

Conversation

ulmus-scott
Copy link
Contributor

Checklist

@stuarta I had hoped to do more work on this, regarding the XmlConfigurations use, but this should be an improvement over what you did.

The configuration caches are currently in libmyth/mythcontext (private).

See the commit messages for details. None of the UPnP stuff was ever saved.

@ulmus-scott
Copy link
Contributor Author

ulmus-scott commented Dec 23, 2021

Compiles, but not working. I'm investigating.
Overload resolution failure, renamed function to correct. Added the missing overload.

mythtv/libs/libmythupnp/httprequest.cpp Outdated Show resolved Hide resolved
mythtv/libs/libmythupnp/mmulticastsocketdevice.cpp Outdated Show resolved Hide resolved
mythtv/libs/libmythupnp/ssdp.cpp Outdated Show resolved Hide resolved
mythtv/libs/libmythupnp/ssdp.cpp Outdated Show resolved Hide resolved
mythtv/libs/libmythupnp/upnpcds.cpp Outdated Show resolved Hide resolved
mythtv/libs/libmythupnp/upnptasknotify.cpp Outdated Show resolved Hide resolved
mythtv/libs/libmythupnp/upnptasksearch.cpp Outdated Show resolved Hide resolved
mythtv/libs/libmythupnp/upnputil.cpp Outdated Show resolved Hide resolved
mythtv/programs/mythfrontend/mediarenderer.cpp Outdated Show resolved Hide resolved
mythtv/programs/mythfrontend/mythfexml.cpp Outdated Show resolved Hide resolved
@stuarta stuarta added this to In progress in UPnP Rework via automation Dec 28, 2021
@ulmus-scott ulmus-scott force-pushed the config-caches1 branch 2 times, most recently from c895b72 to e17a11e Compare December 30, 2021 05:35
@ulmus-scott
Copy link
Contributor Author

ulmus-scott commented Dec 30, 2021

Rebased and force pushed. (I meant to merge some of the commits together before pushing, but I forgot. It is probably clearer while in progress to not do that kind of rebasing, anyway.)

See 381a3c9 for my solution for the non-DB settings. It works fine when I tested it.

Re: "UPnP/DescXmlPath" in mythfexml.cpp
stuarta:

The settings that are of relevance should be migrated to DB configuration items, unless they are required to gain access to get the config items out of the DB. This involves a read config.xml, and save to DB cycle rather than just changing the code to request everything out of the DB.

I think that is beyond the scope of this pull request.

@ulmus-scott
Copy link
Contributor Author

Rebased onto master and added more logging.

@ulmus-scott
Copy link
Contributor Author

WriteDelayedSettings.patch.txt LOG_ALERT to make searching the log easier.
@stuarta
I could not verify that WriteDelayedSettings() works because I could not trigger appending a delayed setting. This is probably because I was testing on a combined backend/frontend.

GetSettings() does return the default given.

WriteDelayedSettings() is called a number of times. However,

if (!gCoreContext->IsUIThread())
should probably be renamed to IsCoreContextThread.

@ulmus-scott
Copy link
Contributor Author

Compilation failure from

const DatabaseParams params = gCoreContext->GetDatabaseParams();

Now converted to GetMythDB().

@stuarta The changes are otherwise identical.

Several commits will need to be squashed before merging this PR.

@ulmus-scott
Copy link
Contributor Author

Rebased onto master with the commits re-ordered and squashed.

The only difference is an extra newline in configuration.h and the removal of the void parameters in XmlConfiguration::(Save|Load).

@ulmus-scott
Copy link
Contributor Author

@stuarta I have split out #598 because it was unrelated and I am currently rebasing this onto master.

@ulmus-scott
Copy link
Contributor Author

@stuarta I have now rebased this onto master and made a number of changes versus the previous version, including no longer using reversion commits. The overall changes are similar.

@ulmus-scott
Copy link
Contributor Author

configuration.h was a public header when it was part of libmythupnp, and unless you see a reason it needs to be public, I'm fine keeping it a private header as it is currently in libmythbase.

The Configuration DBConfiguration has always been a shim to the
database see commit 85bb976
so I have replaced those few uses in mediaserver.cpp with direct
GetMythDB() database accesses.

However, setting a DBConfiguration to the global Configuration
was incorrect since the UPnP code looks for values that are
not present in the database, only optionally present in config.xml.

Note: I now have UDNs for MediaRenderer, MediaServer, and MasterMediaServer
in config.xml.  However, I also had UPnP/UDN/* in the settings table of my
database.
This is intended to prevent the loss of changes made to the configuration file
between it being read into the XmlConfiguration instance and saving that instance.
Also, this removes the unnecessary global state.

mythcontext.cpp: use XmlConfiguration::k_default_filename and the default constructor.
add const char* overloads to fix overload resolution
reordered lines for enhanced clarity
prevented an unwanted, inaccurate log line on Android
improve short circuit comparison

make the return value actually have meaning, which it never did;
see original commit 3fb9d6e from 2012

It now returns if the settings were saved successfully, instead of always returning true,
which frankly I'm surprised was never caught
(I would have thought this would throw a warning on the compiler or other analysis tools).
by moving the only code using it into the same function and making it local to
that function.

The only times saveSettingsCache() is called are right there in MythContext::Init()
and in mythfrontend::main() immediately before exiting.  Thus this change should
have no noticeable functional change.

For reference, these lines are originally from:
deeed3c and 0b9d21a
references https://code.mythtv.org/trac/ticket/13239

It is not clear to me from either commit or the referenced issue why the main window
is being destroyed in the first place.
It's not much of a class, but this makes its function clearer and prepares
MythContext for refactoring into MythGUIContext.
I don't like the pointer use of BackendSelection::Prompt(), but I am not
investigating replacing it at this time.  It should probably return a DatabaseParams
and take by reference as an output a BackendSelection::Decision (enum).
@ulmus-scott
Copy link
Contributor Author

@stuarta Ping. Rebased onto master to resolve minor conflict from minimum Qt version bump.

@bennettpeter bennettpeter self-assigned this Nov 14, 2022
@bennettpeter
Copy link
Member

From the comments this pull seems to follow on to some discussion you had with stuart, which I know nothing about, so I need some context.

Please can you give an overall description of what the purpose is of the pull request, what features of MythTV are affected, and what changes will be visible to the user.

@ulmus-scott
Copy link
Contributor Author

From the comments this pull seems to follow on to some discussion you had with stuart, which I know nothing about, so I need some context.

#435 (comment) is about MythDB::WriteDelayedSettings(), which if I remember correctly, we discussed (privately?) on IRC. Since 2010 with c93be1c and 75cf4e4, you are supposed to be able to write settings to the database before it is connected. Looking over the current changes, I don't think this is relevant to this pull request.

Please can you give an overall description of what the purpose is of the pull request,

I had started work on this before Stuart committed 6ba7c84 and the basic goal was the same: break dependencies on libmythupnp.

However, I went further than he did and also started some code cleanup.

My intention was to prepare to break the dependency of MythContext on libmythupnp, but I'm not sure that is completely possible.

what features of MythTV are affected,

Loading the configuration caches in config.xml for database settings and the frontend settings from cache/contextcache.xml.

and what changes will be visible to the user.

Aside from the extra log messages I added, there should be no visible behavior changes. UDNs for MediaRenderer, MediaServer, and MasterMediaServer will all end up saved in config.xml. Only one of those is currently saved, I think. I have those in my database's settings table because of an earlier version where I (incorrectly) made everything directly access the database.

Copy link
Member

@bennettpeter bennettpeter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The destroying of the main window was to address the case where the xml cache had been deleted and you were starting up before the database was active, and got the wrong GUI setup in your window.

That destroying of the main window is no longer necessary, so this commit is good.

@bennettpeter
Copy link
Member

Merged into master.

UPnP Rework automation moved this from In progress to Done Nov 18, 2022
@ulmus-scott ulmus-scott deleted the config-caches1 branch November 19, 2022 16:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging this pull request may close these issues.

None yet

3 participants