Revision: 14220
          http://edk2.svn.sourceforge.net/edk2/?rev=14220&view=rev
Author:   ydong10
Date:     2013-03-27 03:09:18 +0000 (Wed, 27 Mar 2013)
Log Message:
-----------
Update the traversal path logic.

Signed-off-by: Eric Dong <[email protected]>
Reviewed-by: Liming Gao <[email protected]>

Modified Paths:
--------------
    trunk/edk2/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c
    trunk/edk2/MdeModulePkg/Universal/SetupBrowserDxe/Ui.c
    trunk/edk2/MdeModulePkg/Universal/SetupBrowserDxe/Ui.h

Modified: trunk/edk2/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c
===================================================================
--- trunk/edk2/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c   2013-03-27 
02:03:48 UTC (rev 14219)
+++ trunk/edk2/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c   2013-03-27 
03:09:18 UTC (rev 14220)
@@ -245,6 +245,11 @@
   gFooterHeight = FOOTER_HEIGHT + (Index / 3);
 
   //
+  // Clean the history menu list.
+  //
+  InitializeListHead (&gMenuList);
+
+  //
   // Save globals used by SendForm()
   //
   SaveBrowserContext ();
@@ -378,6 +383,7 @@
   }
 
   FreeBrowserStrings ();
+  UiFreeMenuList(&gMenuList);
 
   gST->ConOut->SetAttribute (gST->ConOut, EFI_TEXT_ATTR (EFI_LIGHTGRAY, 
EFI_BLACK));
   gST->ConOut->ClearScreen (gST->ConOut);

Modified: trunk/edk2/MdeModulePkg/Universal/SetupBrowserDxe/Ui.c
===================================================================
--- trunk/edk2/MdeModulePkg/Universal/SetupBrowserDxe/Ui.c      2013-03-27 
02:03:48 UTC (rev 14219)
+++ trunk/edk2/MdeModulePkg/Universal/SetupBrowserDxe/Ui.c      2013-03-27 
03:09:18 UTC (rev 14220)
@@ -15,7 +15,7 @@
 #include "Setup.h"
 
 LIST_ENTRY          gMenuOption;
-LIST_ENTRY          gMenuList = INITIALIZE_LIST_HEAD_VARIABLE (gMenuList);
+LIST_ENTRY          gMenuList;
 MENU_REFRESH_ENTRY  *gMenuRefreshHead;                // Menu list used for 
refresh timer opcode.
 MENU_REFRESH_ENTRY  *gMenuEventGuidRefreshHead;       // Menu list used for 
refresh event guid opcode.
 
@@ -219,9 +219,10 @@
 
 
 /**
-  Search Menu with given FormId and FormSetGuid in all cached menu list.
+  Search Menu with given FormId, FormSetGuid and Handle in all cached menu 
list.
 
   @param  Parent                 The parent of menu to search.
+  @param  Handle                 Hii handle related to this formset.
   @param  FormSetGuid            The Formset GUID of the menu to search.  
   @param  FormId                 The Form ID of menu to search.
 
@@ -231,6 +232,7 @@
 UI_MENU_LIST *
 UiFindChildMenuList (
   IN UI_MENU_LIST         *Parent,
+  IN EFI_HII_HANDLE       Handle,
   IN EFI_GUID             *FormSetGuid, 
   IN UINT16               FormId
   )
@@ -241,7 +243,7 @@
 
   ASSERT (Parent != NULL);
 
-  if (Parent->FormId == FormId && CompareGuid (FormSetGuid, 
&Parent->FormSetGuid)) {
+  if (Parent->FormId == FormId && CompareGuid (FormSetGuid, 
&Parent->FormSetGuid) && Parent->HiiHandle == Handle) {
     return Parent;
   }
 
@@ -249,7 +251,7 @@
   while (!IsNull (&Parent->ChildListHead, Link)) {
     Child = UI_MENU_LIST_FROM_LINK (Link);
 
-    MenuList = UiFindChildMenuList (Child, FormSetGuid, FormId);
+    MenuList = UiFindChildMenuList (Child, Handle, FormSetGuid, FormId);
     if (MenuList != NULL) {
       return MenuList;
     }
@@ -262,9 +264,10 @@
 
 
 /**
-  Search Menu with given FormSetGuid and FormId in all cached menu list.
+  Search Menu with given Handle, FormSetGuid and FormId in all cached menu 
list.
 
   @param  FormSetGuid            The Formset GUID of the menu to search.
+  @param  Handle                 Hii handle related to this formset.
   @param  FormId                 The Form ID of menu to search.
 
   @return A pointer to menu found or NULL if not found.
@@ -272,6 +275,7 @@
 **/
 UI_MENU_LIST *
 UiFindMenuList (
+  IN EFI_HII_HANDLE       Handle,
   IN EFI_GUID             *FormSetGuid,
   IN UINT16               FormId
   )
@@ -284,8 +288,14 @@
   while (!IsNull (&gMenuList, Link)) {
     MenuList = UI_MENU_LIST_FROM_LINK (Link);
 
-    Child = UiFindChildMenuList(MenuList, FormSetGuid, FormId);
+    Child = UiFindChildMenuList(MenuList, Handle, FormSetGuid, FormId);
     if (Child != NULL) {
+
+      //
+      // If this form already in the menu history list,
+      // just free the list between old this form.
+      //
+      UiFreeMenuList(&Child->ChildListHead);
       return Child;
     }
 
@@ -295,7 +305,29 @@
   return NULL;
 }
 
+/**
+  Free Menu list linked list.
 
+  @param  MenuListHead    One Menu list point in the menu list.
+
+**/
+VOID
+UiFreeMenuList (
+  LIST_ENTRY   *MenuListHead
+  )
+{
+  UI_MENU_LIST    *MenuList;
+
+  while (!IsListEmpty (MenuListHead)) {
+    MenuList = UI_MENU_LIST_FROM_LINK (MenuListHead->ForwardLink);
+    RemoveEntryList (&MenuList->Link);
+    
+    UiFreeMenuList(&MenuList->ChildListHead);
+    FreePool (MenuList);
+  }
+
+}
+
 /**
   Free Menu option linked list.
 
@@ -1997,11 +2029,8 @@
   FORM_BROWSER_FORM               *RefForm;
   EFI_INPUT_KEY                   Key;
   EFI_STATUS                      Status;
-  UI_MENU_LIST                    *MenuList;
-  BOOLEAN                         UpdateFormInfo;
-  
-  Status = EFI_SUCCESS;
-  UpdateFormInfo = TRUE;
+
+  Status    = EFI_SUCCESS;
   StringPtr = NULL;
 
   //
@@ -2122,24 +2151,12 @@
         *NewLine = TRUE;
       }
     }
-    UpdateFormInfo = FALSE;
   } else {
     if ((Statement->QuestionFlags & EFI_IFR_FLAG_CALLBACK) != 0) {
       Selection->Action = UI_ACTION_REFRESH_FORM;
     }
-    UpdateFormInfo = FALSE;
   }
 
-  if (UpdateFormInfo) {
-    //
-    // Link current form so that we can always go back when someone hits the 
ESC
-    //
-    MenuList = UiFindMenuList (&Selection->FormSetGuid, Selection->FormId);
-    if (MenuList == NULL && Selection->CurrentMenu != NULL) {
-      MenuList = UiAddMenuList (Selection->CurrentMenu, Selection->Handle, 
&Selection->FormSetGuid, Selection->FormId);
-    }
-  }
-
   return Status;
 }
 
@@ -2279,12 +2296,12 @@
   //
   // Find current Menu
   //
-  CurrentMenu = UiFindMenuList (&Selection->FormSetGuid, Selection->FormId);
+  CurrentMenu = UiFindMenuList (Selection->Handle, &Selection->FormSetGuid, 
Selection->FormId);
   if (CurrentMenu == NULL) {
     //
     // Current menu not found, add it to the menu tree
     //
-    CurrentMenu = UiAddMenuList (NULL, Selection->Handle, 
&Selection->FormSetGuid, Selection->FormId);
+    CurrentMenu = UiAddMenuList (Selection->CurrentMenu, Selection->Handle, 
&Selection->FormSetGuid, Selection->FormId);
   }
   ASSERT (CurrentMenu != NULL);
   Selection->CurrentMenu = CurrentMenu;

Modified: trunk/edk2/MdeModulePkg/Universal/SetupBrowserDxe/Ui.h
===================================================================
--- trunk/edk2/MdeModulePkg/Universal/SetupBrowserDxe/Ui.h      2013-03-27 
02:03:48 UTC (rev 14219)
+++ trunk/edk2/MdeModulePkg/Universal/SetupBrowserDxe/Ui.h      2013-03-27 
03:09:18 UTC (rev 14220)
@@ -195,6 +195,7 @@
 
 
 extern LIST_ENTRY          gMenuOption;
+extern LIST_ENTRY          gMenuList;
 extern MENU_REFRESH_ENTRY  *gMenuRefreshHead;
 extern UI_MENU_SELECTION   *gCurrentSelection;
 extern BOOLEAN             mHiiPackageListUpdated;
@@ -250,9 +251,10 @@
   );
 
 /**
-  Search Menu with given FormId in the parent menu and all its child menus.
+  Search Menu with given FormId, FormSetGuid and Handle in all cached menu 
list.
 
   @param  Parent                 The parent of menu to search.
+  @param  Handle                 Hii handle related to this formset.
   @param  FormSetGuid            The Formset GUID of the menu to search.  
   @param  FormId                 The Form ID of menu to search.
 
@@ -262,14 +264,16 @@
 UI_MENU_LIST *
 UiFindChildMenuList (
   IN UI_MENU_LIST         *Parent,
+  IN EFI_HII_HANDLE       Handle,
   IN EFI_GUID             *FormSetGuid, 
   IN UINT16               FormId
   );
 
 /**
-  Search Menu with given FormSetGuid and FormId in all cached menu list.
+  Search Menu with given Handle, FormSetGuid and FormId in all cached menu 
list.
 
   @param  FormSetGuid            The Formset GUID of the menu to search.
+  @param  Handle                 Hii handle related to this formset.
   @param  FormId                 The Form ID of menu to search.
 
   @return A pointer to menu found or NULL if not found.
@@ -277,11 +281,23 @@
 **/
 UI_MENU_LIST *
 UiFindMenuList (
+  IN EFI_HII_HANDLE       Handle,
   IN EFI_GUID             *FormSetGuid,
   IN UINT16               FormId
   );
 
 /**
+  Free Menu list linked list.
+
+  @param  MenuListHead    One Menu list point in the menu list.
+
+**/
+VOID
+UiFreeMenuList (
+  LIST_ENTRY   *MenuListHead
+  );
+
+/**
   Free Menu option linked list.
 
 **/

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
Own the Future-Intel&reg; Level Up Game Demo Contest 2013
Rise to greatness in Intel's independent game demo contest.
Compete for recognition, cash, and the chance to get your game 
on Steam. $5K grand prize plus 10 genre and skill prizes. 
Submit your demo by 6/6/13. http://p.sf.net/sfu/intel_levelupd2d
_______________________________________________
edk2-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-commits

Reply via email to