Fixed some crashing bugs (that only appear under Haiku, because there is some

stuff missing - defensive programming rules :-)).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13005 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2005-06-08 04:11:19 +00:00
parent bd28b3c746
commit e9b005131f
+10 -4
View File
@@ -107,7 +107,8 @@ set_pixel_clock(display_mode * mode, float refresh_rate)
ScreenWindow::ScreenWindow(ScreenSettings *Settings) ScreenWindow::ScreenWindow(ScreenSettings *Settings)
: BWindow(Settings->WindowFrame(), "Screen", B_TITLED_WINDOW, B_NOT_RESIZABLE | B_NOT_ZOOMABLE, B_ALL_WORKSPACES) : BWindow(Settings->WindowFrame(), "Screen", B_TITLED_WINDOW,
B_NOT_RESIZABLE | B_NOT_ZOOMABLE, B_ALL_WORKSPACES)
{ {
BRect frame(Bounds()); BRect frame(Bounds());
BScreen screen(B_MAIN_SCREEN_ID); BScreen screen(B_MAIN_SCREEN_ID);
@@ -115,6 +116,8 @@ ScreenWindow::ScreenWindow(ScreenSettings *Settings)
if (!screen.IsValid()) if (!screen.IsValid())
;//debugger() ? ;//debugger() ?
fSupportedModes = NULL;
fTotalModes = 0;
screen.GetModeList(&fSupportedModes, &fTotalModes); screen.GetModeList(&fSupportedModes, &fTotalModes);
frame.InsetBy(-1, -1); frame.InsetBy(-1, -1);
@@ -143,6 +146,7 @@ ScreenWindow::ScreenWindow(ScreenSettings *Settings)
string << count_workspaces(); string << count_workspaces();
BMenuItem *marked = fWorkspaceCountMenu->FindItem(string.String()); BMenuItem *marked = fWorkspaceCountMenu->FindItem(string.String());
if (marked != NULL)
marked->SetMarked(true); marked->SetMarked(true);
fWorkspaceCountField->SetDivider(91.0); fWorkspaceCountField->SetDivider(91.0);
@@ -182,24 +186,26 @@ ScreenWindow::ScreenWindow(ScreenSettings *Settings)
CheckUpdateDisplayModes(); CheckUpdateDisplayModes();
const char * resolutionLabel = "Resolution: "; const char *resolutionLabel = "Resolution: ";
float resolutionWidth = controlsBox->StringWidth(resolutionLabel); float resolutionWidth = controlsBox->StringWidth(resolutionLabel);
BRect controlMenuRect(88.0-resolutionWidth, 30.0, 171.0, 48.0); BRect controlMenuRect(88.0-resolutionWidth, 30.0, 171.0, 48.0);
fResolutionField = new BMenuField(controlMenuRect, "ResolutionMenu", resolutionLabel, fResolutionMenu, true); fResolutionField = new BMenuField(controlMenuRect, "ResolutionMenu", resolutionLabel, fResolutionMenu, true);
marked = fResolutionMenu->ItemAt(0); marked = fResolutionMenu->ItemAt(0);
if (marked != NULL)
marked->SetMarked(true); marked->SetMarked(true);
fResolutionField->SetDivider(resolutionWidth); fResolutionField->SetDivider(resolutionWidth);
controlsBox->AddChild(fResolutionField); controlsBox->AddChild(fResolutionField);
const char * colorsLabel = "Colors: "; const char *colorsLabel = "Colors: ";
float colorsWidth = controlsBox->StringWidth(colorsLabel); float colorsWidth = controlsBox->StringWidth(colorsLabel);
controlMenuRect.Set(88.0-colorsWidth, 58.0, 171.0, 76.0); controlMenuRect.Set(88.0-colorsWidth, 58.0, 171.0, 76.0);
fColorsField = new BMenuField(controlMenuRect, "ColorsMenu", colorsLabel, fColorsMenu, true); fColorsField = new BMenuField(controlMenuRect, "ColorsMenu", colorsLabel, fColorsMenu, true);
marked = fColorsMenu->ItemAt(0); marked = fColorsMenu->ItemAt(0);
if (marked != NULL)
marked->SetMarked(true); marked->SetMarked(true);
fColorsField->SetDivider(colorsWidth); fColorsField->SetDivider(colorsWidth);
@@ -209,7 +215,7 @@ ScreenWindow::ScreenWindow(ScreenSettings *Settings)
fOtherRefresh = new BMenuItem("Other...", new BMessage(POP_OTHER_REFRESH_MSG)); fOtherRefresh = new BMenuItem("Other...", new BMessage(POP_OTHER_REFRESH_MSG));
fRefreshMenu->AddItem(fOtherRefresh); fRefreshMenu->AddItem(fOtherRefresh);
const char * refreshLabel = "Refresh Rate: "; const char *refreshLabel = "Refresh Rate: ";
float refreshWidth = controlsBox->StringWidth(refreshLabel); float refreshWidth = controlsBox->StringWidth(refreshLabel);
controlMenuRect.Set(88.0-refreshWidth, 86.0, 171.0, 104.0); controlMenuRect.Set(88.0-refreshWidth, 86.0, 171.0, 104.0);
fRefreshField = new BMenuField(controlMenuRect, "RefreshMenu", refreshLabel, fRefreshMenu, true); fRefreshField = new BMenuField(controlMenuRect, "RefreshMenu", refreshLabel, fRefreshMenu, true);