Skip to content

Commit

Permalink
Media: Display alert before to quit when restarting
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
Numerio committed Jul 27, 2015
1 parent 40de3cd commit 009034b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/preferences/media/MediaWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -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);
Expand All @@ -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)
Expand Down Expand Up @@ -628,6 +644,7 @@ MediaWindow::_RestartMediaServices(void* data)

launch_media_server();

window->fRestartingServices = false;
return window->PostMessage(ML_INIT_MEDIA);
}

Expand Down
1 change: 1 addition & 0 deletions src/preferences/media/MediaWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ class MediaWindow : public BWindow {
NodeList fVideoOutputs;

status_t fInitCheck;
bool fRestartingServices;
};


Expand Down

0 comments on commit 009034b

Please sign in to comment.