Changeset 1553 for trunk/dll/treecnr.c


Ignore:
Timestamp:
Nov 20, 2010, 10:18:32 PM (15 years ago)
Author:
Gregg Young
Message:

Rework scanning code to remove redundant scans, prevent double directory entries in the tree container, fix related semaphore performance using combination of event and mutex semaphores

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/dll/treecnr.c

    r1552 r1553  
    8484  11 Apr 10 GKY Fix drive tree rescan failure and program hang caused by event sem
    8585                never being posted
     86  20 Nov 10 GKY Rework scanning code to remove redundant scans, prevent double directory
     87                entries in the tree container, fix related semaphore performance using
     88                combination of event and mutex semaphores
    8689
    8790***********************************************************************/
     
    644647      dcd = INSTDATA(hwnd);
    645648      if (dcd) {
    646         BOOL tempsusp, tempfollow, temptop;
     649        BOOL tempsusp, tempfollow, temptop;
    647650
    648651        DosWaitEventSem(hevTreeCnrScanComplete, SEM_INDEFINITE_WAIT);
     
    656659        }
    657660        ShowTreeRec(dcd->hwndCnr, (CHAR *)mp1, fCollapseFirst, TRUE);
    658         // fixme Is this PostMsg needed if recursive scan has already been done?
    659661        PostMsg(hwndTree, WM_COMMAND, MPFROM2SHORT(IDM_UPDATE, 0), MPVOID);
    660662        dcd->suspendview = (USHORT) tempsusp;
     
    771773      if (cnri.cRecords) {
    772774        sprintf(s, GetPString(IDS_NUMDRIVESTEXT), cnri.cRecords);
    773         if (pci && pci->pszFileName && *pci->pszFileName) {
     775        if (pci && (INT) pci != -1 && pci->pszFileName && *pci->pszFileName) {
    774776          if (!(driveflags[toupper(*pci->pszFileName) - 'A'] &
    775777                DRIVE_REMOVABLE) ||
     
    18271829                     driveserial[toupper(*pci->pszFileName) - 'A'] !=
    18281830                     volser.serial)) {
    1829                   if (Flesh(hwnd, pci) &&
    1830                       SHORT2FROMMP(mp1) == CN_EXPANDTREE &&
    1831                       !dcd->suspendview && fTopDir) {
     1831                  if (SHORT2FROMMP(mp1) == CN_EXPANDTREE && Flesh(hwnd, pci)
     1832                      &&!dcd->suspendview  && fTopDir) {
    18321833                    PostMsg(hwnd, UM_TOPDIR, MPFROMP(pci), MPVOID);
    18331834                    //DbgMsg(pszSrcFile, __LINE__, "UM_TOPDIR %p pci %p", hwnd, pci);
     
    19051906      INT x;
    19061907
    1907       DosWaitEventSem(hevTreeCnrScanComplete, SEM_INDEFINITE_WAIT);
     1908      DosRequestMutexSem(hmtxScanning, SEM_INDEFINITE_WAIT);
    19081909      DosResetEventSem(hevTreeCnrScanComplete, &ulScanPostCnt);
    19091910      if (fFollowTree)
     
    19841985          if (!status) {
    19851986            if (!volser.serial || driveserial[x] != volser.serial) {
    1986               UnFlesh(hwnd, pciP);
    19871987              Flesh(hwnd, pciP);
    19881988              driveserial[x] = volser.serial;
     
    19921992                              MPFROMP(pciP),
    19931993                              MPFROM2SHORT(CMA_FIRSTCHILD, CMA_ITEMORDER));
    1994             if (!pciL)
    1995               Flesh(hwnd, pciP);
     1994            if (!pciL) {
     1995              Flesh(hwnd, pciP);
     1996            }
    19961997            if ((fShowFSTypeInTree || fShowDriveLabelInTree) &&
    19971998                strlen(pciP->pszFileName) < 4) {
     
    27902791              if (pci->flags & RECFLAGS_UNDERENV)
    27912792                break;
    2792               DosWaitEventSem(hevTreeCnrScanComplete, SEM_INDEFINITE_WAIT);
     2793              DosRequestMutexSem(hmtxScanning, SEM_INDEFINITE_WAIT);
    27932794              DosResetEventSem(hevTreeCnrScanComplete, &ulScanPostCnt);
    27942795              UnFlesh(hwnd, pci);
     
    28022803                else  if (strlen(pci->pszFileName) < 4) {
    28032804                  SelectDriveIcon(pci);
    2804                 }
    2805                 if ((fShowFSTypeInTree || fShowDriveLabelInTree) &&
    2806                     strlen(pci->pszFileName) < 4) {
    2807                   strcpy(szBuf, pci->pszFileName);
    2808                   strcat(szBuf, " [");
    2809                   strcat(szBuf, fShowFSTypeInTree ? FileSystem : volser.volumelabel);
    2810                   strcat(szBuf, "]");
    2811                   pci->pszDisplayName = xstrdup(szBuf, pszSrcFile, __LINE__);
    2812                   pci->rc.pszIcon = pci->pszDisplayName;
    2813                 }
     2805                  if (fShowFSTypeInTree || fShowDriveLabelInTree) {
     2806                    strcpy(szBuf, pci->pszFileName);
     2807                    strcat(szBuf, " [");
     2808                    strcat(szBuf, fShowFSTypeInTree ? FileSystem : volser.volumelabel);
     2809                    strcat(szBuf, "]");
     2810                    pci->pszDisplayName = xstrdup(szBuf, pszSrcFile, __LINE__);
     2811                    pci->rc.pszIcon = pci->pszDisplayName;
     2812                  }
     2813                }
    28142814                WinSendMsg(hwnd,
    28152815                           CM_INVALIDATERECORD,
Note: See TracChangeset for help on using the changeset viewer.