diff --git a/mythtv/libs/libmythbase/mythversion.h b/mythtv/libs/libmythbase/mythversion.h index 3d3bd0550c5..600f55b0748 100644 --- a/mythtv/libs/libmythbase/mythversion.h +++ b/mythtv/libs/libmythbase/mythversion.h @@ -12,7 +12,7 @@ /// Update this whenever the plug-in API changes. /// Including changes in the libmythbase, libmyth, libmythtv, libmythav* and /// libmythui class methods used by plug-ins. -#define MYTH_BINARY_VERSION "0.26.20120721-1" +#define MYTH_BINARY_VERSION "0.26.20120724-1" /** \brief Increment this whenever the MythTV network protocol changes. * diff --git a/mythtv/libs/libmythui/mythscreentype.cpp b/mythtv/libs/libmythui/mythscreentype.cpp index f5f13f55d9e..a698b14e56f 100644 --- a/mythtv/libs/libmythui/mythscreentype.cpp +++ b/mythtv/libs/libmythui/mythscreentype.cpp @@ -22,16 +22,18 @@ QEvent::Type ScreenLoadCompletionEvent::kEventType = class ScreenLoadTask : public QRunnable { public: - ScreenLoadTask(MythScreenType *parent) : m_parent(parent) {} + ScreenLoadTask(MythScreenType &parent) : m_parent(parent) {} private: - void run() + void run(void) { - if (m_parent) - m_parent->LoadInForeground(); + m_parent.Load(); + m_parent.m_IsLoaded = true; + m_parent.m_IsLoading = false; + m_parent.m_LoadLock.unlock(); } - MythScreenType *m_parent; + MythScreenType &m_parent; }; MythScreenType::MythScreenType(MythScreenStack *parent, const QString &name, @@ -80,6 +82,9 @@ MythScreenType::~MythScreenType() // gCoreContext->SendSystemEvent( // QString("SCREEN_TYPE DESTROYED %1").arg(objectName())); + // locking ensures background screen load can finish running + QMutexLocker locker(&m_LoadLock); + m_CurrentFocusWidget = NULL; emit Exiting(); } @@ -294,18 +299,26 @@ void MythScreenType::Load(void) void MythScreenType::LoadInBackground(QString message) { + m_LoadLock.lock(); + m_IsLoading = true; + m_IsLoaded = false; + m_ScreenStack->AllowReInit(); OpenBusyPopup(message); - ScreenLoadTask *loadTask = new ScreenLoadTask(this); + ScreenLoadTask *loadTask = new ScreenLoadTask(*this); MThreadPool::globalInstance()->start(loadTask, "ScreenLoad"); } void MythScreenType::LoadInForeground(void) { + QMutexLocker locker(&m_LoadLock); + m_IsLoading = true; + m_IsLoaded = false; + m_ScreenStack->AllowReInit(); Load(); m_IsLoaded = true; @@ -365,6 +378,8 @@ bool MythScreenType::IsInitialized(void) const void MythScreenType::doInit(void) { + QMutexLocker locker(&m_LoadLock); // don't run while loading.. + CloseBusyPopup(); Init(); m_IsInitialized = true; diff --git a/mythtv/libs/libmythui/mythscreentype.h b/mythtv/libs/libmythui/mythscreentype.h index b83b39b071b..e998e8128b6 100644 --- a/mythtv/libs/libmythui/mythscreentype.h +++ b/mythtv/libs/libmythui/mythscreentype.h @@ -5,8 +5,11 @@ #include "mythuitext.h" #include "mythuiutils.h" +#include +#include #include +class ScreenLoadTask; class MythScreenStack; class MythUIBusyDialog; @@ -40,6 +43,8 @@ class MUI_PUBLIC MythScreenType : public MythUIType { Q_OBJECT + friend class ScreenLoadTask; + public: MythScreenType(MythScreenStack *parent, const QString &name, bool fullscreen = true); @@ -108,8 +113,10 @@ class MUI_PUBLIC MythScreenType : public MythUIType bool m_FullScreen; bool m_IsDeleting; - bool m_IsLoading; - bool m_IsLoaded; + + QMutex m_LoadLock; + volatile bool m_IsLoading; + volatile bool m_IsLoaded; bool m_IsInitialized; MythUIType *m_CurrentFocusWidget;