Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixes #10928. Fix race in LoadInBackground() handling.

  • Loading branch information...
commit 643ad3e9f83e3840d1311b2c89d736978ad8af9c 1 parent 483e06f
@daniel-kristjansson daniel-kristjansson authored
View
2  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.
*
View
27 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;
View
11 mythtv/libs/libmythui/mythscreentype.h
@@ -5,8 +5,11 @@
#include "mythuitext.h"
#include "mythuiutils.h"
+#include <QWaitCondition>
+#include <QMutex>
#include <QHash>
+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;
Please sign in to comment.
Something went wrong with that request. Please try again.