hrev43907 adds 1 changeset to branch 'master' old head: 1674a53a45f12befa208e7478337d811d1fed6fd new head: 7e44de362f7aa888dc01ed867de8815f600b7fd9 ---------------------------------------------------------------------------- 7e44de3: Fix several issues in Screen preflet. - Always initialize other menu item data member. - Always use refresh_rate_to_string() to generate item labels. - When searching for the item matching the selected refresh rate, look for it by the actual refresh rate stored in the item's message rather than by string comparisons of the label. - Don't assume the Other menu item exists, since it doesn't in cases where the refresh rate constraints only allow a single rate. - Update copyright year. Fixes #8431. [ Rene Gollent <anevilyak@xxxxxxxxx> ] ---------------------------------------------------------------------------- Revision: hrev43907 Commit: 7e44de362f7aa888dc01ed867de8815f600b7fd9 URL: http://cgit.haiku-os.org/haiku/commit/?id=7e44de3 Author: Rene Gollent <anevilyak@xxxxxxxxx> Date: Fri Mar 30 22:13:19 2012 UTC Ticket: https://dev.haiku-os.org/ticket/8431 ---------------------------------------------------------------------------- 1 files changed, 20 insertions(+), 22 deletions(-) src/preferences/screen/ScreenWindow.cpp | 42 +++++++++++++-------------- ---------------------------------------------------------------------------- diff --git a/src/preferences/screen/ScreenWindow.cpp b/src/preferences/screen/ScreenWindow.cpp index 335f70d..60ff059 100644 --- a/src/preferences/screen/ScreenWindow.cpp +++ b/src/preferences/screen/ScreenWindow.cpp @@ -1,11 +1,12 @@ /* - * Copyright 2001-2011, Haiku. + * Copyright 2001-2012, Haiku. * Distributed under the terms of the MIT License. * * Authors: * Rafael Romo * Stefano Ceccherini (burton666@xxxxxxxxx) * Andrew Bachmann + * Rene Gollent, rene@xxxxxxxxxxx * Thomas Kurschel * Axel Dörfler, axeld@xxxxxxxxxxxxxxxx * Stephan Aßmus <superstippi@xxxxxx> @@ -171,6 +172,7 @@ ScreenWindow::ScreenWindow(ScreenSettings* settings) fIsVesa(false), fBootWorkspaceApplied(false), fScreenMode(this), + fOtherRefresh(NULL), fUndoScreenMode(this), fModified(false) { @@ -315,11 +317,7 @@ ScreenWindow::ScreenWindow(ScreenSettings* settings) // This is a special case for drivers that only support a single // frequency, like the VESA driver BString name; - name << min << " " << B_TRANSLATE("Hz"); - - message = new BMessage(POP_REFRESH_MSG); - message->AddFloat("refresh", min); - + refresh_rate_to_string(min, name); fRefreshMenu->AddItem(item = new BMenuItem(name.String(), message)); item->SetEnabled(false); } else { @@ -663,28 +661,28 @@ ScreenWindow::_CheckRefreshMenu() void ScreenWindow::_UpdateRefreshControl() { - BString string; - refresh_rate_to_string(fSelected.refresh, string); - - BMenuItem* item = fRefreshMenu->FindItem(string.String()); - if (item) { - if (!item->IsMarked()) + for (int32 i = 0; i < fRefreshMenu->CountItems(); i++) { + BMenuItem* item = fRefreshMenu->ItemAt(i); + if (item->Message()->FindFloat("refresh") == fSelected.refresh) { item->SetMarked(true); - - // "Other" items only contains a refresh rate when active - fOtherRefresh->SetLabel(B_TRANSLATE("Other" B_UTF8_ELLIPSIS)); - return; + // "Other" items only contains a refresh rate when active + fOtherRefresh->SetLabel(B_TRANSLATE("Other" B_UTF8_ELLIPSIS)); + return; + } } // this is a non-standard refresh rate + if (fOtherRefresh != NULL) { + fOtherRefresh->Message()->ReplaceFloat("refresh", fSelected.refresh); + fOtherRefresh->SetMarked(true); - fOtherRefresh->Message()->ReplaceFloat("refresh", fSelected.refresh); - fOtherRefresh->SetMarked(true); - - fRefreshMenu->Superitem()->SetLabel(string.String()); + BString string; + refresh_rate_to_string(fSelected.refresh, string); + fRefreshMenu->Superitem()->SetLabel(string.String()); - string.Append(B_TRANSLATE("/other" B_UTF8_ELLIPSIS)); - fOtherRefresh->SetLabel(string.String()); + string.Append(B_TRANSLATE("/other" B_UTF8_ELLIPSIS)); + fOtherRefresh->SetLabel(string.String()); + } }