]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/DisplayEngineDxe/FormDisplay.c
DisplayEngineDxe: Fixed calculate help string page count error.
[mirror_edk2.git] / MdeModulePkg / Universal / DisplayEngineDxe / FormDisplay.c
index 9f50f832aae2a3c0be61f586a392fc20cb5cbcc4..a391442d169ac02e3d175b7046aeb38574cb2efc 100644 (file)
@@ -1782,14 +1782,15 @@ FindTopMenu (
 \r
   TopRow    = gStatementDimensions.TopRow    + SCROLL_ARROW_HEIGHT;\r
   BottomRow = gStatementDimensions.BottomRow - SCROLL_ARROW_HEIGHT;\r
-\r
-  if (gMisMatch) {\r
+  //\r
+  // When option mismatch happens,there exist two cases,one is reenter the form, just like the if case below,\r
+  // and the other is exit current form and enter last form, it can be covered by the else case.\r
+  //\r
+  if (gMisMatch && gFormData->HiiHandle == gHighligthMenuInfo.HiiHandle && gFormData->FormId == gHighligthMenuInfo.FormId) {\r
     //\r
     // Reenter caused by option mismatch or auto exit caused by refresh form(refresh interval/guid), \r
     // base on the record highlight info to find the highlight menu.\r
     //\r
-    ASSERT (gFormData->HiiHandle == gHighligthMenuInfo.HiiHandle &&\r
-            gFormData->FormId == gHighligthMenuInfo.FormId);\r
 \r
     *HighlightMenu = FindHighLightMenuOption(NULL);\r
     if (*HighlightMenu != NULL) {\r
@@ -1840,7 +1841,6 @@ FindTopMenu (
       *SkipValue = 0;\r
     }\r
 \r
-    gMisMatch = FALSE;\r
   } else if (FormData->HighLightedStatement != NULL) {\r
     if (IsSavedHighlightStatement (FormData->HighLightedStatement)) {\r
       //\r
@@ -1914,6 +1914,8 @@ FindTopMenu (
     *SkipValue     = 0;\r
   }\r
 \r
+  gMisMatch = FALSE;\r
+\r
   //\r
   // First enter to show the menu, update highlight info.\r
   //\r
@@ -2149,6 +2151,7 @@ FxConfirmPopup (
   UINT32                          CheckFlags;\r
   BOOLEAN                         RetVal;\r
   UINTN                           CatLen;\r
+  UINTN                           MaxLen;\r
 \r
   CfmStrLen = 0;\r
   CatLen    = StrLen (gConfirmMsgConnect);\r
@@ -2209,55 +2212,57 @@ FxConfirmPopup (
   // Allocate buffer to save the string.\r
   // String + "?" + "\0"\r
   //\r
-  CfmStr = AllocateZeroPool ((CfmStrLen + 1 + 1) * sizeof (CHAR16));\r
+  MaxLen = CfmStrLen + 1 + 1;\r
+  CfmStr = AllocateZeroPool (MaxLen * sizeof (CHAR16));\r
   ASSERT (CfmStr != NULL);\r
 \r
   if ((Action & BROWSER_ACTION_DISCARD) == BROWSER_ACTION_DISCARD) {\r
-    StrCpy (CfmStr, gConfirmDiscardMsg);\r
+    StrCpyS (CfmStr, MaxLen, gConfirmDiscardMsg);\r
   }\r
 \r
   if ((Action & BROWSER_ACTION_DEFAULT) == BROWSER_ACTION_DEFAULT) {\r
     if (CfmStr[0] != 0) {\r
-      StrCat (CfmStr, gConfirmMsgConnect);\r
-      StrCat (CfmStr, gConfirmDefaultMsg2nd);\r
+      StrCatS (CfmStr, MaxLen, gConfirmMsgConnect);\r
+      StrCatS (CfmStr, MaxLen, gConfirmDefaultMsg2nd);\r
     } else {\r
-      StrCpy (CfmStr, gConfirmDefaultMsg);\r
+      StrCpyS (CfmStr, MaxLen, gConfirmDefaultMsg);\r
     }\r
   }\r
 \r
   if ((Action & BROWSER_ACTION_SUBMIT)  == BROWSER_ACTION_SUBMIT) {\r
     if (CfmStr[0] != 0) {\r
-      StrCat (CfmStr, gConfirmMsgConnect);\r
-      StrCat (CfmStr, gConfirmSubmitMsg2nd);\r
+      StrCatS (CfmStr, MaxLen, gConfirmMsgConnect);\r
+      StrCatS (CfmStr, MaxLen, gConfirmSubmitMsg2nd);\r
     } else {\r
-      StrCpy (CfmStr, gConfirmSubmitMsg);\r
+      StrCpyS (CfmStr, MaxLen, gConfirmSubmitMsg);\r
     }\r
   }\r
 \r
   if ((Action & BROWSER_ACTION_RESET)  == BROWSER_ACTION_RESET) {\r
     if (CfmStr[0] != 0) {\r
-      StrCat (CfmStr, gConfirmMsgConnect);\r
-      StrCat (CfmStr, gConfirmResetMsg2nd);\r
+      StrCatS (CfmStr, MaxLen, gConfirmMsgConnect);\r
+      StrCatS (CfmStr, MaxLen, gConfirmResetMsg2nd);\r
     } else {\r
-      StrCpy (CfmStr, gConfirmResetMsg);\r
+      StrCpyS (CfmStr, MaxLen, gConfirmResetMsg);\r
     }\r
   }\r
 \r
   if ((Action & BROWSER_ACTION_EXIT)  == BROWSER_ACTION_EXIT) {\r
     if (CfmStr[0] != 0) {\r
-      StrCat (CfmStr, gConfirmMsgConnect);\r
-      StrCat (CfmStr, gConfirmExitMsg2nd);\r
+      StrCatS (CfmStr, MaxLen, gConfirmMsgConnect);\r
+      StrCatS (CfmStr, MaxLen, gConfirmExitMsg2nd);\r
     } else {\r
-      StrCpy (CfmStr, gConfirmExitMsg);\r
+      StrCpyS (CfmStr, MaxLen, gConfirmExitMsg);\r
     }\r
   }\r
 \r
-  StrCat (CfmStr, gConfirmMsgEnd);\r
+  StrCatS (CfmStr, MaxLen, gConfirmMsgEnd);\r
 \r
   do {\r
     CreateDialog (&Key, gEmptyString, CfmStr, gConfirmOpt, gEmptyString, NULL);\r
   } while (((Key.UnicodeChar | UPPER_LOWER_CASE_OFFSET) != (gConfirmOptYes[0] | UPPER_LOWER_CASE_OFFSET)) &&\r
-           ((Key.UnicodeChar | UPPER_LOWER_CASE_OFFSET) != (gConfirmOptNo[0] | UPPER_LOWER_CASE_OFFSET)));\r
+           ((Key.UnicodeChar | UPPER_LOWER_CASE_OFFSET) != (gConfirmOptNo[0] | UPPER_LOWER_CASE_OFFSET)) &&\r
+           (Key.ScanCode != SCAN_ESC));\r
 \r
   if ((Key.UnicodeChar | UPPER_LOWER_CASE_OFFSET) == (gConfirmOptYes[0] | UPPER_LOWER_CASE_OFFSET)) {\r
     RetVal = TRUE;\r
@@ -2944,7 +2949,7 @@ UiDisplayMenu (
           //\r
           if (HelpLine > 2 * RowCount - 2) {\r
             HelpPageCount = (HelpLine - RowCount + 1) / (RowCount - 2) + 1;\r
-            if ((HelpLine - RowCount + 1) % (RowCount - 2) > 1) {\r
+            if ((HelpLine - RowCount + 1) % (RowCount - 2) != 0) {\r
               HelpPageCount += 1;\r
             }\r
           } else {\r