Permalink
Browse files

Cleanup OSD::DialogShow(), this code had the potential to segfault if…

… the theme was missing a dialogue definition.
  • Loading branch information...
stuartm committed May 31, 2012
1 parent 1d7922c commit ca9086de2ed28b036cbcc9e7245b792e1e110a5e
Showing with 20 additions and 21 deletions.
  1. +20 −21 mythtv/libs/libmythtv/osd.cpp
@@ -990,38 +990,37 @@ void OSD::DialogShow(const QString &window, const QString &text, int updatefor)
{
OverrideUIScale();
MythScreenType *dialog;
+
if (window == OSD_DLG_EDITOR)
dialog = new ChannelEditor(m_ParentObject, window.toLatin1());
else if (window == OSD_DLG_CONFIRM)
dialog = new MythConfirmationDialog(NULL, text, false);
else
dialog = new MythDialogBox(text, NULL, window.toLatin1(), false, true);
- if (dialog)
+ dialog->SetPainter(m_CurrentPainter);
+ if (dialog->Create())
{
- dialog->SetPainter(m_CurrentPainter);
- if (dialog->Create())
+ PositionWindow(dialog);
+ m_Dialog = dialog;
+ MythDialogBox *dbox = dynamic_cast<MythDialogBox*>(m_Dialog);
+ if (dbox)
+ dbox->SetReturnEvent(m_ParentObject, window);
+ MythConfirmationDialog *cbox = dynamic_cast<MythConfirmationDialog*>(m_Dialog);
+ if (cbox)
{
- PositionWindow(dialog);
- m_Dialog = dialog;
- MythDialogBox *dbox = dynamic_cast<MythDialogBox*>(m_Dialog);
- if (dbox)
- dbox->SetReturnEvent(m_ParentObject, window);
- MythConfirmationDialog *cbox = dynamic_cast<MythConfirmationDialog*>(m_Dialog);
- if (cbox)
- {
- cbox->SetReturnEvent(m_ParentObject, window);
- cbox->SetData("DIALOG_CONFIRM_X_X");
- }
- m_Children.insert(window, m_Dialog);
- }
- else
- {
- RevertUIScale();
- delete dialog;
- return;
+ cbox->SetReturnEvent(m_ParentObject, window);
+ cbox->SetData("DIALOG_CONFIRM_X_X");
}
+ m_Children.insert(window, m_Dialog);
+ }
+ else
+ {
+ RevertUIScale();
+ delete dialog;
+ return;
}
+
RevertUIScale();
}

0 comments on commit ca9086d

Please sign in to comment.