From bbcfef1f6c4640427a6538897082f9ab1516e5ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Duval?= Date: Fri, 7 Jul 2006 16:01:37 +0000 Subject: [PATCH] archive deep when needed, restore menu items git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18054 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/interface/Menu.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/kits/interface/Menu.cpp b/src/kits/interface/Menu.cpp index 23831cb83f..636f9fd0a7 100644 --- a/src/kits/interface/Menu.cpp +++ b/src/kits/interface/Menu.cpp @@ -282,11 +282,11 @@ BMenu::Archive(BMessage *data, bool deep) const if (err == B_OK) err = data->AddFloat("_maxwidth", fMaxContentWidth); if (err == B_OK && deep) { - int32 count = CountItems(); - for (int index=0; indexArchive(&itemData); + item->Archive(&itemData, deep); err = data->AddMessage("_items", &itemData); if (err != B_OK) break; @@ -1170,6 +1170,13 @@ BMenu::InitData(BMessage *data) data->FindBool("_dyn_label", &fDynamicName); data->FindFloat("_maxwidth", &fMaxContentWidth); + + BMessage msg; + for (int32 i = 0; data->FindMessage("_items", i, &msg) == B_OK; i++) { + BArchivable *object = instantiate_object(&msg); + if (BMenuItem *item = dynamic_cast(object)) + AddItem(item); + } } }