Permalink
Browse files

Fix crash when changing theme while a notification is active.

We were re-creating the screen immediately when deleted which cause re-reading the theme, but the them would later be deleted invalidating all caches... So avoid re-reading the theme just yet
  • Loading branch information...
jyavenard committed Jul 2, 2013
1 parent 24b33aa commit c11e856d00fdead6057d7a71eba8c6b1aa2c1b84
@@ -41,7 +41,7 @@ MythUINotificationScreen::MythUINotificationScreen(MythScreenStack *stack,
int id)
: MythScreenType(stack, "mythuinotification"), m_id(id),
m_duration(-1), m_progress(-1.0), m_added(false),
m_update(kForce),
m_created(false), m_update(kForce),
m_artworkImage(NULL), m_titleText(NULL), m_artistText(NULL),
m_albumText(NULL), m_formatText(NULL), m_timeText(NULL),
m_progressBar(NULL)
@@ -54,7 +54,7 @@ MythUINotificationScreen::MythUINotificationScreen(MythScreenStack *stack,
MythNotification &notification)
: MythScreenType(stack, "mythuinotification"), m_id(notification.GetId()),
m_duration(notification.GetDuration()), m_progress(-1.0),
m_added(false), m_update(kForce),
m_added(false), m_created(false), m_update(kForce),
m_artworkImage(NULL), m_titleText(NULL), m_artistText(NULL),
m_albumText(NULL), m_formatText(NULL), m_timeText(NULL),
m_progressBar(NULL)
@@ -172,6 +172,8 @@ bool MythUINotificationScreen::Create(void)
m_progressBar->SetVisible(false);
}
m_created = true;
return true;
}
@@ -557,7 +559,8 @@ void MythUINotificationCenter::ScreenDeleted(void)
{
// don't remove the id from the list, as the application is still registered
// re-create the screen
MythUINotificationScreen *newscreen = CreateScreen(NULL, screen->m_id);
MythUINotificationScreen *newscreen = CreateScreen(NULL, screen->m_id,
true);
// Copy old content
*newscreen = *screen;
m_registrations[screen->m_id] = newscreen;
@@ -666,6 +669,16 @@ void MythUINotificationCenter::ProcessQueue(void)
created = true;
}
// if the screen got allocated, but did't read theme yet, do it now
if (screen && !screen->m_created)
{
if (!screen->Create())
{
delete screen;
continue;
}
}
if (created || !m_screens.contains(screen))
{
int pos = InsertScreen(screen);
@@ -690,7 +703,7 @@ void MythUINotificationCenter::ProcessQueue(void)
* This screen will not be displayed until it is used.
*/
MythUINotificationScreen *MythUINotificationCenter::CreateScreen(MythNotification *n,
int id)
int id, bool nocreate)
{
MythUINotificationScreen *screen;
@@ -703,7 +716,7 @@ MythUINotificationScreen *MythUINotificationCenter::CreateScreen(MythNotificatio
screen = new MythUINotificationScreen(GetScreenStack(), id);
}
if (!screen->Create()) // Reads screen definition from xml, and constructs screen
if (!nocreate && !screen->Create()) // Reads screen definition from xml, and constructs screen
{
// If we can't create the screen then we can't display it, so delete
// and abort
@@ -92,7 +92,7 @@ private slots:
friend class MythNotificationScreenStack;
MythUINotificationScreen *CreateScreen(MythNotification *notification,
int id = -1);
int id = -1, bool nocreate = false);
MythNotificationScreenStack *GetScreenStack(void);
void ScreenStackDeleted(void);
void DeleteAllScreens(void);
@@ -75,6 +75,7 @@ public slots:
float m_progress;
QString m_progressText;
bool m_added;
bool m_created;
uint32_t m_update;
MythUIImage *m_artworkImage;
MythUIText *m_titleText;

0 comments on commit c11e856

Please sign in to comment.