This patch changes the behavior from exiting the program, to simply
displaying an error message to the user while continuing to function.
I found that when I upgraded to 0.18, for some reason the
status-ui.xml file was missing from my theme directory as well as the
default directory. This caused mythfrontend to simply exit whenever
the status page was accessed.
Steps to reproduce:
1. Remove status-ui.xml from default and theme directories if it's there
2. Load mythfrontend
3. navigate to the status page. Note that mythfrontend exits
Changes made:
- added isInitialized boolean member variable and getter function to
StatusBox class
- changed LoadTheme to return bool instead of void
- instead of calling exit(-1) on errors, simply return false in LoadTheme
- in the StatusBox constructor, if the theme cannot be loaded, it will
return (isInitialized remains false)
- in main.cpp, check whether the status box was initialized. if not,
display a dialog.
This is my first patch with strings, so i'm not sure what the process
is for internationalization. let me know if there's something else
that i need to do and i'll submit it. I have attached the 3 diff
files.
--Harvard
Index: main.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythtv/programs/mythfrontend/main.cpp,v
retrieving revision 1.190
diff -r1.190 main.cpp
336a337,346
> if (statusbox.IsInitialized () == false) {
> // If the status box is not initialized properly, notify the user
> // and return.
> QString title = QObject::tr("The Status Screen could not be loaded.");
> DialogBox diag(gContext->GetMainWindow(), title);
> diag.AddButton(QObject::tr("OK"));
> diag.exec ();
>
> return;
> }
Index: statusbox.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythtv/programs/mythfrontend/statusbox.cpp,v
retrieving revision 1.21
diff -r1.21 statusbox.cpp
40a41
> , isInitialized (false)
50c51,53
< LoadTheme();
---
> if (!LoadTheme()) {
> return;
> }
83a87
> isInitialized = true;
222c226
< void StatusBox::LoadTheme()
---
> bool StatusBox::LoadTheme()
232c236,240
< theme->LoadTheme(xmldata, "status", "status-");
---
> if (theme->LoadTheme(xmldata, "status", "status-") == false) {
> // Clearly we were not able to load the theme and can't display
> cerr << "Statusbox was unable to load theme." << endl;
> return false;
> }
258c266
< exit(-1);
---
> return false;
266c274
< exit(-1);
---
> return false;
272c280
< exit(-1);
---
> return false;
278c286
< exit(-1);
---
> return false;
284c292
< exit(-1);
---
> return false;
290c298
< exit(-1);
---
> return false;
296c304
< exit(-1);
---
> return false;
302c310
< exit(-1);
---
> return false;
303a312
> return true;
1125a1135,1141
>
> // Simple function that checks whether the StatusBox
> // was able to be loaded correctly.
> bool StatusBox::IsInitialized ()
> {
> return isInitialized;
> }
Index: statusbox.h
===================================================================
RCS file: /var/lib/mythcvs/mythtv/programs/mythfrontend/statusbox.h,v
retrieving revision 1.6
diff -r1.6 statusbox.h
16a17
> bool IsInitialized ();
28c29
< void LoadTheme();
---
> bool LoadTheme();
61a63
> bool isInitialized;
_______________________________________________
mythtv-dev mailing list
[email protected]
http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-dev