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

MythContext refactoring (remove gContext) #671

Merged
merged 19 commits into from
Feb 26, 2025
Merged
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
dfe2e3a
MythBackend.php: fix comment
ulmus-scott Nov 20, 2022
a407809
MythContextSlotHandler: merge into MythContextPrivate
ulmus-scott Nov 19, 2022
600fbc8
MythContextPrivate: PIMPL idiom style
ulmus-scott Nov 20, 2022
6f59779
MythContext::Impl: remove member m_parent
ulmus-scott Nov 20, 2022
e103dab
MythContext::Impl: create LanguagePrompt()
ulmus-scott Nov 20, 2022
8f75012
MythContext: C++ does not require a void parameter
ulmus-scott Nov 20, 2022
0438836
MythContext::Impl::ResetDatabase(): convert to a static function
ulmus-scott Nov 22, 2022
26128da
MythContext::Impl::LoadDatabaseSettings(): split into three function …
ulmus-scott Nov 22, 2022
e97bf2b
MythContext::Impl::SaveDatabaseParams(): directly access the MythDB s…
ulmus-scott Nov 22, 2022
67a5db6
DatabaseParams: remove unused parameter m_forceSave
ulmus-scott Nov 18, 2024
92a4de3
remove DatabaseParams::LoadDefaults()
ulmus-scott Nov 18, 2024
e10ba67
libmyth/mythcontext.cpp: create class DatabaseParamsCache
ulmus-scott Nov 18, 2024
698a2a7
MythContext::Impl::SilenceDBerrors(): fix braces
ulmus-scott Nov 18, 2024
d3529f8
merge DatabaseParamsCache into MythDB
ulmus-scott Nov 18, 2024
1040637
mythfrontend/exitprompt.cpp: remove backend connection popup hack
ulmus-scott Nov 20, 2024
5eede53
libmyth/mythcontext: remove gContext
ulmus-scott Nov 22, 2024
7324dd6
SignalHandler: move calls into MythContext
ulmus-scott Nov 22, 2024
f7ca74e
merge CleanupGuard into MythContext
ulmus-scott Nov 22, 2024
e198c2a
mythlogging.h: copy StringUtil::bool_to_string() as boolToQString()
ulmus-scott Feb 2, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
merge CleanupGuard into MythContext
ulmus-scott committed Feb 25, 2025
commit f7ca74ec3b09d8db46702701b33d1754842d4e8b
5 changes: 5 additions & 0 deletions mythtv/libs/libmyth/mythcontext.cpp
Original file line number Diff line number Diff line change
@@ -1664,6 +1664,11 @@ bool MythContext::Init(const bool gui,

MythContext::~MythContext()
{
if (m_cleanup != nullptr)
{
m_cleanup();
}

if (m_impl->m_gui)
{
DestroyMythMainWindow();
8 changes: 8 additions & 0 deletions mythtv/libs/libmyth/mythcontext.h
Original file line number Diff line number Diff line change
@@ -27,6 +27,9 @@ class MPUBLIC MythContext
bool disableAutoDiscovery = false,
bool ignoreDB = false);

using CleanupFunction = void (*)();
void setCleanup(CleanupFunction cleanup) { m_cleanup = cleanup; }

bool saveSettingsCache();

void SetDisableEventPopup(bool check);
@@ -37,6 +40,11 @@ class MPUBLIC MythContext
class Impl;
Impl *m_impl {nullptr}; ///< PIMPL idiom
QString m_appBinaryVersion;
/**
This is used to destroy global state before main() returns. It is called
first before anything else is done in ~MythContext() if it is not nullptr.
*/
CleanupFunction m_cleanup {nullptr};
};

#endif
2 changes: 0 additions & 2 deletions mythtv/libs/libmythbase/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -83,7 +83,6 @@ set(LIBMYTHBASE_HEADERS

set(LIBMYTHBASE_HEADERS_NOT_INSTALLED
mythbinaryplist.h
cleanupguard.h
configuration.h
housekeeper.h
logging.h
@@ -145,7 +144,6 @@ add_library(
${LIBMYTHBASE_HEADERS}
${LIBMYTHBASE_HEADERS_NOT_INSTALLED}
${LIBMYTHBASE_HTTP_HEADERS}
cleanupguard.cpp
configuration.cpp
dbcheckcommon.cpp
dbutil.cpp
11 changes: 0 additions & 11 deletions mythtv/libs/libmythbase/cleanupguard.cpp

This file was deleted.

20 changes: 0 additions & 20 deletions mythtv/libs/libmythbase/cleanupguard.h

This file was deleted.

4 changes: 2 additions & 2 deletions mythtv/libs/libmythbase/libmythbase.pro
Original file line number Diff line number Diff line change
@@ -36,7 +36,7 @@ HEADERS += mythsystemlegacy.h mythtypes.h
HEADERS += threadedfilewriter.h mythsingledownload.h
HEADERS += ternarycompare.h
HEADERS += mythsession.h
HEADERS += cleanupguard.h portchecker.h
HEADERS += portchecker.h
HEADERS += mythsorthelper.h mythdbcheck.h
HEADERS += mythpower.h
HEADERS += configuration.h
@@ -75,7 +75,7 @@ SOURCES += mythrandom.cpp
SOURCES += stringutil.cpp
SOURCES += threadedfilewriter.cpp mythsingledownload.cpp
SOURCES += mythsession.cpp
SOURCES += cleanupguard.cpp portchecker.cpp
SOURCES += portchecker.cpp
SOURCES += mythsorthelper.cpp dbcheckcommon.cpp
SOURCES += mythpower.cpp
SOURCES += configuration.cpp
3 changes: 1 addition & 2 deletions mythtv/programs/mythbackend/mythbackend.cpp
Original file line number Diff line number Diff line change
@@ -25,7 +25,6 @@

// MythTV
#include "libmyth/mythcontext.h"
#include "libmythbase/cleanupguard.h"
#include "libmythbase/compat.h"
#include "libmythbase/configuration.h"
#include "libmythbase/exitcodes.h"
@@ -156,7 +155,7 @@ int main(int argc, char **argv)
LOG(VB_GENERAL, LOG_CRIT, "Failed to init MythContext.");
return GENERIC_EXIT_NO_MYTHCONTEXT;
}
CleanupGuard callCleanup(cleanup);
context.setCleanup(cleanup);

MythTranslation::load("mythfrontend");

3 changes: 1 addition & 2 deletions mythtv/programs/mythfrontend/mythfrontend.cpp
Original file line number Diff line number Diff line change
@@ -35,7 +35,6 @@
#include "libmythui/langsettings.h"
#include "libmyth/mythcontext.h"
#include "libmythui/standardsettings.h"
#include "libmythbase/cleanupguard.h"
#include "libmythbase/compat.h" // For SIG* on MinGW
#include "libmythbase/exitcodes.h"
#include "libmythbase/hardwareprofile.h"
@@ -2053,7 +2052,7 @@ Q_DECL_EXPORT int main(int argc, char **argv)
gCoreContext->SetExiting(true);
return GENERIC_EXIT_NO_MYTHCONTEXT;
}
CleanupGuard callCleanup(cleanup);
context.setCleanup(cleanup);

SignalHandler::SetHandler(SIGUSR1, handleSIGUSR1);
SignalHandler::SetHandler(SIGUSR2, handleSIGUSR2);