From 5d1e75d3cb46cffcbc9f2455c3c9eb0a8a59f325 Mon Sep 17 00:00:00 2001 From: Rene Gollent Date: Tue, 20 Jan 2009 01:42:15 +0000 Subject: [PATCH] If we're going to fail because of a missing CD drive, never show the CD player window at all instead of flickering it briefly. This fixes ticket #2333. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28963 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/apps/cdplayer/CDPlayer.cpp | 20 +++++++++++++++----- src/apps/cdplayer/CDPlayer.h | 3 ++- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/apps/cdplayer/CDPlayer.cpp b/src/apps/cdplayer/CDPlayer.cpp index 59064810b1..8ca4656c18 100644 --- a/src/apps/cdplayer/CDPlayer.cpp +++ b/src/apps/cdplayer/CDPlayer.cpp @@ -85,7 +85,6 @@ CDPlayer::CDPlayer(BRect frame, const char *name, uint32 resizeMask, " drives on your computer or there is no system software to " "support one. Sorry.", "OK"); alert->Go(); - be_app->PostMessage(B_QUIT_REQUESTED); } fWindowState = fCDDrive.GetState(); @@ -104,6 +103,13 @@ CDPlayer::~CDPlayer() } +bool +CDPlayer::InitCheck() +{ + return (fCDDrive.CountDrives() > 0); +} + + void CDPlayer::BuildGUI() { @@ -638,10 +644,14 @@ CDPlayerApplication::CDPlayerApplication() : BApplication("application/x-vnd.Haiku-CDPlayer") { BWindow *window = new CDPlayerWindow(); - BView *view = new CDPlayer(window->Bounds(), "CD"); - window->ResizeTo(view->Bounds().Width(), view->Bounds().Height()); - window->AddChild(view); - window->Show(); + CDPlayer *view = new CDPlayer(window->Bounds(), "CD"); + if (view->InitCheck()) { + window->ResizeTo(view->Bounds().Width(), view->Bounds().Height()); + window->AddChild(view); + window->Show(); + } + else + PostMessage(B_QUIT_REQUESTED); } diff --git a/src/apps/cdplayer/CDPlayer.h b/src/apps/cdplayer/CDPlayer.h index b4e1936514..b79167a670 100644 --- a/src/apps/cdplayer/CDPlayer.h +++ b/src/apps/cdplayer/CDPlayer.h @@ -33,7 +33,8 @@ class CDPlayer : public BView { virtual ~CDPlayer(); void BuildGUI(); - + bool InitCheck(); + virtual void AttachedToWindow(); virtual void Pulse(); virtual void MessageReceived(BMessage *);