hrev46459 adds 5 changesets to branch 'master' old head: 25a83d13b95b7ef244ecff48dc1b0e027dcad340 new head: 65947ae5ae53be36ecd9b9190c632e1fcb6a20f8 overview: http://cgit.haiku-os.org/haiku/log/?qt=range&q=65947ae+%5E25a83d1 ---------------------------------------------------------------------------- 2a368f9: boot loader: text menu: run_menu(): Fix empty menu crash cbfc38c: boot loader: MenuItem: Add SetLabel() ccfc7be: boot loader: blacklist menu: Add "Return to ..." item e2c5cf6: boot loader: Menu: Add SetTitle() 65947ae: boot loader: blacklist menu: Set different title when disabled When booting from CD (or when no boot volume has been selected) blacklisting isn't supported. In that case let the menu title indicated that. [ Ingo Weinhold <ingo_weinhold@xxxxxx> ] ---------------------------------------------------------------------------- 3 files changed, 53 insertions(+), 18 deletions(-) headers/private/kernel/boot/menu.h | 3 ++ src/system/boot/loader/menu.cpp | 63 ++++++++++++++++------ src/system/boot/platform/generic/text_menu.cpp | 5 +- ############################################################################ Commit: 2a368f9b0e3659940316a533d2afb4673cb9f181 URL: http://cgit.haiku-os.org/haiku/commit/?id=2a368f9 Author: Ingo Weinhold <ingo_weinhold@xxxxxx> Date: Sat Nov 30 18:25:56 2013 UTC boot loader: text menu: run_menu(): Fix empty menu crash ---------------------------------------------------------------------------- diff --git a/src/system/boot/platform/generic/text_menu.cpp b/src/system/boot/platform/generic/text_menu.cpp index 605f8da..6a5ee65 100644 --- a/src/system/boot/platform/generic/text_menu.cpp +++ b/src/system/boot/platform/generic/text_menu.cpp @@ -413,6 +413,9 @@ run_menu(Menu* menu) item = menu->ItemAt(selected); if (TEXT_CONSOLE_IS_CURSOR_KEY(key)) { + if (item == NULL) + continue; + int32 oldSelected = selected; switch (key) { @@ -460,7 +463,7 @@ run_menu(Menu* menu) } } else if (key == TEXT_CONSOLE_KEY_RETURN || key == TEXT_CONSOLE_KEY_SPACE) { - if (invoke_item(menu, item, selected, key)) + if (item != NULL && invoke_item(menu, item, selected, key)) break; } else if (key == TEXT_CONSOLE_KEY_ESCAPE && menu->Type() != MAIN_MENU) { ############################################################################ Commit: cbfc38c62d972fa79a84b8b2ed528e10f3b82eae URL: http://cgit.haiku-os.org/haiku/commit/?id=cbfc38c Author: Ingo Weinhold <ingo_weinhold@xxxxxx> Date: Sat Nov 30 18:39:57 2013 UTC boot loader: MenuItem: Add SetLabel() ---------------------------------------------------------------------------- diff --git a/headers/private/kernel/boot/menu.h b/headers/private/kernel/boot/menu.h index dc07cb3..60edf8e 100644 --- a/headers/private/kernel/boot/menu.h +++ b/headers/private/kernel/boot/menu.h @@ -57,6 +57,7 @@ public: char Shortcut() const { return fShortcut; } const char* Label() const { return fLabel; } + void SetLabel(const char* label); Menu* Submenu() const { return fSubMenu; } void SetSubmenu(Menu* subMenu); diff --git a/src/system/boot/loader/menu.cpp b/src/system/boot/loader/menu.cpp index 5b55168..b5dbcc6 100644 --- a/src/system/boot/loader/menu.cpp +++ b/src/system/boot/loader/menu.cpp @@ -181,6 +181,16 @@ MenuItem::SetShortcut(char key) void +MenuItem::SetLabel(const char* label) +{ + if (char* newLabel = strdup(label)) { + free(const_cast<char*>(fLabel)); + fLabel = newLabel; + } +} + + +void MenuItem::SetSubmenu(Menu* subMenu) { fSubMenu = subMenu; ############################################################################ Commit: ccfc7bea502f61c942a39ef40ad783960f70f2d3 URL: http://cgit.haiku-os.org/haiku/commit/?id=ccfc7be Author: Ingo Weinhold <ingo_weinhold@xxxxxx> Date: Sat Nov 30 18:40:32 2013 UTC boot loader: blacklist menu: Add "Return to ..." item ---------------------------------------------------------------------------- diff --git a/src/system/boot/loader/menu.cpp b/src/system/boot/loader/menu.cpp index b5dbcc6..96fbbec 100644 --- a/src/system/boot/loader/menu.cpp +++ b/src/system/boot/loader/menu.cpp @@ -622,26 +622,29 @@ public: { _DeleteItems(); - if (fDirectory == NULL) - return; - - void* cookie; - if (fDirectory->Open(&cookie, O_RDONLY) == B_OK) { - Node* node; - while (fDirectory->GetNextNode(cookie, &node) == B_OK) { - BlacklistMenuItem* item = _CreateItem(node); - node->Release(); - if (item == NULL) - break; - - AddItem(item); - - item->UpdateBlacklisted(); + if (fDirectory != NULL) { + void* cookie; + if (fDirectory->Open(&cookie, O_RDONLY) == B_OK) { + Node* node; + while (fDirectory->GetNextNode(cookie, &node) == B_OK) { + BlacklistMenuItem* item = _CreateItem(node); + node->Release(); + if (item == NULL) + break; + + AddItem(item); + + item->UpdateBlacklisted(); + } + fDirectory->Close(cookie); } - fDirectory->Close(cookie); + + SortItems(&BlacklistMenuItem::Less); } - SortItems(&BlacklistMenuItem::Less); + if (CountItems() > 0) + AddSeparatorItem(); + AddItem(new(nothrow) MenuItem("Return to parent directory")); } virtual void Exited() @@ -725,6 +728,10 @@ public: SetDirectory(NULL); BlacklistMenu::Entered(); + + // rename last item + if (MenuItem* item = ItemAt(CountItems() - 1)) + item->SetLabel("Return to safe mode menu"); } virtual void Exited() ############################################################################ Commit: e2c5cf691d52425a693aefd8806e7d120a37ce65 URL: http://cgit.haiku-os.org/haiku/commit/?id=e2c5cf6 Author: Ingo Weinhold <ingo_weinhold@xxxxxx> Date: Sat Nov 30 18:56:26 2013 UTC boot loader: Menu: Add SetTitle() ---------------------------------------------------------------------------- diff --git a/headers/private/kernel/boot/menu.h b/headers/private/kernel/boot/menu.h index 60edf8e..b13346d 100644 --- a/headers/private/kernel/boot/menu.h +++ b/headers/private/kernel/boot/menu.h @@ -130,6 +130,8 @@ public: ? fSuperItem->fMenu : NULL; } const char* Title() const { return fTitle; } + void SetTitle(const char* title) + { fTitle = title; } void SetChoiceText(const char* text) { fChoiceText = text; } ############################################################################ Revision: hrev46459 Commit: 65947ae5ae53be36ecd9b9190c632e1fcb6a20f8 URL: http://cgit.haiku-os.org/haiku/commit/?id=65947ae Author: Ingo Weinhold <ingo_weinhold@xxxxxx> Date: Sat Nov 30 18:58:41 2013 UTC boot loader: blacklist menu: Set different title when disabled When booting from CD (or when no boot volume has been selected) blacklisting isn't supported. In that case let the menu title indicated that. ---------------------------------------------------------------------------- diff --git a/src/system/boot/loader/menu.cpp b/src/system/boot/loader/menu.cpp index 96fbbec..400b8e4 100644 --- a/src/system/boot/loader/menu.cpp +++ b/src/system/boot/loader/menu.cpp @@ -608,7 +608,7 @@ class BlacklistMenu : public Menu { public: BlacklistMenu() : - Menu(STANDARD_MENU, "Mark the entries to blacklist"), + Menu(STANDARD_MENU, kDefaultMenuTitle), fDirectory(NULL) { } @@ -706,9 +706,16 @@ private: private: Directory* fDirectory; + +protected: + static const char* const kDefaultMenuTitle; }; +const char* const BlacklistMenu::kDefaultMenuTitle + = "Mark the entries to blacklist"; + + class BlacklistRootMenu : public BlacklistMenu { public: BlacklistRootMenu() @@ -724,8 +731,13 @@ public: if (sBootVolume != NULL && sBootVolume->IsValid() && sBootVolume->IsPackaged()) { SetDirectory(sBootVolume->SystemDirectory()); - } else + SetTitle(kDefaultMenuTitle); + } else { SetDirectory(NULL); + SetTitle(sBootVolume != NULL && sBootVolume->IsValid() + ? "The selected boot volume doesn't support blacklisting!" + : "No boot volume selected!"); + } BlacklistMenu::Entered();