Lei Zhang : sane.ds: Get number of options only once.

Alexandre Julliard julliard at winehq.org
Fri Nov 9 07:44:25 CST 2007


Module: wine
Branch: master
Commit: e984d7ba40e6d7e6de78a2cd4f88f0b3a2f4f087
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=e984d7ba40e6d7e6de78a2cd4f88f0b3a2f4f087

Author: Lei Zhang <thestig at google.com>
Date:   Fri Nov  9 01:38:23 2007 -0800

sane.ds: Get number of options only once.

---

 dlls/sane.ds/ui.c |   20 +++++++-------------
 1 files changed, 7 insertions(+), 13 deletions(-)

diff --git a/dlls/sane.ds/ui.c b/dlls/sane.ds/ui.c
index 18fd8de..6c877a2 100644
--- a/dlls/sane.ds/ui.c
+++ b/dlls/sane.ds/ui.c
@@ -370,10 +370,8 @@ static int create_item(HDC hdc, const SANE_Option_Descriptor *opt,
 
 
 static LPDLGTEMPLATEW create_options_page(HDC hdc, int *from_index,
-                                          BOOL split_tabs)
+                                          SANE_Int optcount, BOOL split_tabs)
 {
-    SANE_Status rc;
-    SANE_Int optcount;
     int i;
     INT y = 2;
     LPDLGTEMPLATEW tpl = NULL;
@@ -385,15 +383,6 @@ static LPDLGTEMPLATEW create_options_page(HDC hdc, int *from_index,
     int group_offset = -1;
     INT control_count = 0;
 
-    rc = psane_control_option(activeDS.deviceHandle, 0, SANE_ACTION_GET_VALUE,
-            &optcount, NULL);
-
-    if (rc != SANE_STATUS_GOOD)
-    {
-        ERR("Unable to read number of options\n");
-        return NULL;
-    }
-
     for (i = *from_index; i < optcount; i++)
     {
         LPDLGITEMTEMPLATEW item_tpl = NULL;
@@ -540,12 +529,17 @@ BOOL DoScannerUI(void)
     memset(&psp,0,sizeof(psp));
     rc = psane_control_option(activeDS.deviceHandle, 0, SANE_ACTION_GET_VALUE,
             &optcount, NULL);
+    if (rc != SANE_STATUS_GOOD)
+    {
+        ERR("Unable to read number of options\n");
+        return FALSE;
+    }
 
     while (index < optcount)
     {
         const SANE_Option_Descriptor *opt;
         psp[page_count].u.pResource = create_options_page(hdc, &index,
-                TRUE);
+                optcount, TRUE);
         opt = psane_get_option_descriptor(activeDS.deviceHandle, index);
 
         if (opt->type == SANE_TYPE_GROUP)




More information about the wine-cvs mailing list