Skip to content

Commit

Permalink
Fix infinite loop
Browse files Browse the repository at this point in the history
If we have a registration from a client which will survive MythMainWindow, the screen would have been re-created, which would have re-created the screen stack, which would have caused an infinite loop in MythMainWindow destructor.
Only create a screen stack once.
  • Loading branch information
jyavenard committed Jul 8, 2013
1 parent 63dd524 commit 4a2de2e
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 28 deletions.
56 changes: 29 additions & 27 deletions mythtv/libs/libmythui/mythuinotificationcenter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -473,9 +473,11 @@ void MythUINotificationScreen::SetSingleShotTimer(int s)
/////////////////////// NCPrivate

NCPrivate::NCPrivate()
: m_screenStack(NULL), m_currentId(0)
: m_currentId(0)
{

m_screenStack = new MythNotificationScreenStack(GetMythMainWindow(),
"mythuinotification",
this);
}

NCPrivate::~NCPrivate()
Expand Down Expand Up @@ -547,16 +549,24 @@ void NCPrivate::ScreenDeleted(void)
{
if (!duefordeletion)
{
// don't remove the id from the list, as the application is still registered
// re-create the screen
MythUINotificationScreen *newscreen =
new MythUINotificationScreen(GetScreenStack(), *screen);
connect(newscreen, SIGNAL(ScreenDeleted()), this, SLOT(ScreenDeleted()));
m_registrations[screen->m_id] = newscreen;
// Screen was deleted, add it to suspended list
m_suspended.append(screen->m_id);
LOG(VB_GUI, LOG_DEBUG, LOC +
"ScreenDeleted: Suspending registered screen");
if (!m_screenStack)
{
// we're in the middle of being deleted
m_registrations.remove(screen->m_id);
}
else
{
// don't remove the id from the list, as the application is still registered
// re-create the screen
MythUINotificationScreen *newscreen =
new MythUINotificationScreen(m_screenStack, *screen);
connect(newscreen, SIGNAL(ScreenDeleted()), this, SLOT(ScreenDeleted()));
m_registrations[screen->m_id] = newscreen;
// Screen was deleted, add it to suspended list
m_suspended.append(screen->m_id);
LOG(VB_GUI, LOG_DEBUG, LOC +
"ScreenDeleted: Suspending registered screen");
}
}
else
{
Expand Down Expand Up @@ -688,11 +698,11 @@ MythUINotificationScreen *NCPrivate::CreateScreen(MythNotification *n, int id)

if (n)
{
screen = new MythUINotificationScreen(GetScreenStack(), *n);
screen = new MythUINotificationScreen(m_screenStack, *n);
}
else
{
screen = new MythUINotificationScreen(GetScreenStack(), id);
screen = new MythUINotificationScreen(m_screenStack, id);
}

if (!screen->Create()) // Reads screen definition from xml, and constructs screen
Expand Down Expand Up @@ -761,17 +771,6 @@ void NCPrivate::UnRegister(void *from, int id, bool closeimemdiately)
GetMythMainWindow(), new MythUINotificationCenterEvent());
}

MythNotificationScreenStack *NCPrivate::GetScreenStack(void)
{
if (!m_screenStack)
{
m_screenStack = new MythNotificationScreenStack(GetMythMainWindow(),
"mythuinotification",
this);
}
return m_screenStack;
}

void NCPrivate::DeleteAllRegistrations(void)
{
QMap<int, MythUINotificationScreen*>::iterator it = m_registrations.begin();
Expand Down Expand Up @@ -884,11 +883,14 @@ void NCPrivate::GetNotificationScreens(QList<MythScreenType*> &_screens)
QList<MythScreenType*> list;
QVector<MythScreenType*> screens;

GetScreenStack()->CheckDeletes();
if (!m_screenStack)
return;

m_screenStack->CheckDeletes();

QMutexLocker lock(&m_lock);

GetScreenStack()->GetScreenList(screens);
m_screenStack->GetScreenList(screens);

QVector<MythScreenType*>::const_iterator it = screens.begin();
QVector<MythScreenType*>::const_iterator itend = screens.end();
Expand Down
1 change: 0 additions & 1 deletion mythtv/libs/libmythui/mythuinotificationcenter_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ public slots:

MythUINotificationScreen *CreateScreen(MythNotification *notification,
int id = -1);
MythNotificationScreenStack *GetScreenStack(void);
void DeleteAllRegistrations(void);
void DeleteAllScreens(void);
int InsertScreen(MythUINotificationScreen *screen);
Expand Down

0 comments on commit 4a2de2e

Please sign in to comment.