Media: Display alert before to quit when restarting

* Fixes 10770.
* While more complex solutions are proposed, i think
  of it as a way to get out of an eventual deadlock or
  to protect from accident close.
This commit is contained in:
Dario Casalinuovo 2015-07-27 20:16:43 +02:00
parent 40de3cd148
commit 009034bdf0
2 changed files with 19 additions and 1 deletions

View File

@ -164,7 +164,8 @@ MediaWindow::MediaWindow(BRect frame)
fAudioOutputs(5, true),
fVideoInputs(5, true),
fVideoOutputs(5, true),
fInitCheck(B_OK)
fInitCheck(B_OK),
fRestartingServices(false)
{
_InitWindow();
@ -282,6 +283,20 @@ MediaWindow::UpdateOutputListItem(MediaListItem::media_type type,
bool
MediaWindow::QuitRequested()
{
if (fRestartingServices == true) {
BString text(B_TRANSLATE("The media services are restarting,"
" interructions to this process might result"
" in media functionalities not correctly running."
" Are you really sure to quit?"));
BAlert* alert = new BAlert(B_TRANSLATE("Warning!"), text,
B_TRANSLATE("Do it"), B_TRANSLATE("No"), NULL,
B_WIDTH_AS_USUAL, B_OFFSET_SPACING, B_WARNING_ALERT);
int32 ret = alert->Go();
if (ret == 1)
return false;
}
// stop watching the MediaRoster
fCurrentNode.SetTo(NULL);
be_app->PostMessage(B_QUIT_REQUESTED);
@ -298,6 +313,7 @@ MediaWindow::MessageReceived(BMessage* message)
break;
case ML_RESTART_MEDIA_SERVER:
{
fRestartingServices = true;
thread_id thread = spawn_thread(&MediaWindow::_RestartMediaServices,
"restart_thread", B_NORMAL_PRIORITY, this);
if (thread < 0)
@ -628,6 +644,7 @@ MediaWindow::_RestartMediaServices(void* data)
launch_media_server();
window->fRestartingServices = false;
return window->PostMessage(ML_INIT_MEDIA);
}

View File

@ -112,6 +112,7 @@ private:
NodeList fVideoOutputs;
status_t fInitCheck;
bool fRestartingServices;
};