Changeset 1876 for trunk/dll/treecnr.c


Ignore:
Timestamp:
Oct 11, 2015, 1:42:28 AM (10 years ago)
Author:
Gregg Young
Message:

Eliminate some unnecessary Flesh and UnFlesh calls.Update icon and display name on CD/DVD eject in all cases.
Don't use Flesh thread for floppy drive scans fix them getting mistakenly identified as directories and add nonexistent subdirectories.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/dll/treecnr.c

    r1875 r1876  
    120120                to avoid them seen as directories and having random subdirectories attached to
    121121                them.
     122  10 Oct 15 GKY Eliminate some unnecessary Flesh and UnFlesh calls
     123  10 Oct 15 GKY Update icon and display name on CD/DVD eject in all cases.
     124  10 Oct 15 GKY Don't use Flesh thread for floppy drive scans fix them getting mistakenly identified
     125                as directories and add nonexistent subdirectories.
    122126
    123127***********************************************************************/
     
    868872    {
    869873      PCNRITEM pci = (PCNRITEM) mp1;
    870       PCNRITEM pciL;
    871874
    872875      if (pci) {
    873         pciL = (PCNRITEM)WinSendMsg(dcd->hwndCnr,
    874                                     CM_QUERYRECORD,
    875                                     MPFROMP(pci),
    876                                     MPFROM2SHORT(CMA_FIRSTCHILD, CMA_ITEMORDER));
    877         if (pciL && (INT) pciL != -1) {
    878           WaitFleshWorkListEmpty(NULL, 10);     // 2015-08-13 SHL in case pci still in work list
    879           AddFleshWorkRequest(hwnd, pci, eUnFlesh);
     876        if ((INT) mp2 == 21 && pci->rc.hptrIcon == hptrCDROM) {
     877          if (fEjectCDScan)
     878            PostMsg(hwndTree, WM_COMMAND, MPFROM2SHORT(IDM_RESCAN, 0), MPVOID);
     879          else {
     880            driveflags[toupper(*pci->pszFileName) - 'A'] |= DRIVE_INVALID;
     881            PostMsg(hwndTree, WM_COMMAND, MPFROM2SHORT(IDM_UPDATE, 0), MPVOID);
     882          }
    880883        }
    881         if ((INT) mp2 == 21 && pci->rc.hptrIcon == hptrCDROM)
    882           PostMsg(hwndTree, WM_COMMAND, MPFROM2SHORT(IDM_RESCAN, 0), MPVOID);
    883884        NotifyError(pci->pszFileName, (ULONG) mp2);
    884885      }
     
    935936      if (cnri.cRecords) {
    936937        sprintf(s, GetPString(IDS_NUMDRIVESTEXT), cnri.cRecords);
    937         if (pci && (INT) pci != -1 && pci->pszFileName != NullStr) { //fixme? will try checking pci->pszFileName instead of the pointer
     938        if (pci && (INT) pci != -1) {
    938939          if (!(driveflags[toupper(*pci->pszFileName) - 'A'] &
    939940                DRIVE_REMOVABLE) ||
     
    10041005          }
    10051006          else {
    1006             PCNRITEM pciL;
    10071007            // find root record and strip it if needed
    10081008            pci = FindParentRecord(dcd->hwndCnr, pci);
    10091009            driveserial[toupper(*pci->pszFileName) - 'A'] = -1;
    1010             pciL = (PCNRITEM)WinSendMsg(dcd->hwndCnr,
    1011                                         CM_QUERYRECORD,
    1012                                         MPFROMP(pci),
    1013                                         MPFROM2SHORT(CMA_FIRSTCHILD, CMA_ITEMORDER));
    1014             if (pciL && (INT) pciL != -1) {
     1010            if (pci->fleshed) {
    10151011              WaitFleshWorkListEmpty(pci->pszFileName, 240);    // 2015-08-19 SHL in case pci still in work list
    1016               AddFleshWorkRequest(dcd->hwndCnr, pci, eUnFlesh);
     1012              if ((toupper(*pci->pszFileName) - 'A') > 1)  {
     1013                DbgMsg(pszSrcFile, __LINE__,"UM_RESCAN2 UnFlesh %s", pci->pszFileName);
     1014                AddFleshWorkRequest(hwnd, pci, eUnFlesh);
     1015              }
     1016              else
     1017                UnFlesh(hwnd, pci);
    10171018            }
    10181019          }
     
    14031404        }
    14041405      }
    1405       //DbgMsg(pszSrcFile, __LINE__, "TreeCnrWndProc UM_RESCAN PostMsg(UM_RESCAN2, %p %s)",
    1406       //       pci, pci && pci->pszFileName ? pci->pszFileName : "(null)"); // 2015-08-04 SHL FIXME debug
    14071406      PostMsg(dcd->hwndObject, UM_RESCAN2, MPFROMP(pci), MPVOID);
    14081407      if (hwndStatus2)
     
    14101409    }
    14111410    return 0;
    1412 #if 0
    1413   case UM_SETUP2:
    1414     {
    1415       PCNRITEM pci = (PCNRITEM) mp1;
    1416 
    1417       if (pci) {
    1418         WaitFleshWorkListEmpty(NULL, 10);       // 2015-08-13 SHL in case pci still in work list
    1419         AddFleshWorkRequest(hwnd, pci, eUnFlesh);
    1420         if ((INT) mp2 == 21)
    1421           PostMsg(hwndTree, WM_COMMAND, MPFROM2SHORT(IDM_RESCAN, 0), MPVOID);
    1422         NotifyError(pci->pszFileName, (ULONG) mp2);
    1423       }
    1424     }
    1425     return 0;
    1426 #endif
     1411
    14271412  case UM_SETUP:
    14281413#   ifdef FORTIFY
     
    20202005      HDIR hDir = HDIR_CREATE;
    20212006      ULONG nm = 1;
    2022       // APIRET status;
    20232007      BOOL IsOk = FALSE;
    20242008      ULONG ulDriveNum, ulDriveMap;
     
    21052089              driveserial[x] = volser.serial;
    21062090            }
    2107             pciL = WinSendMsg(hwnd,
    2108                               CM_QUERYRECORD,
    2109                               MPFROMP(pciP),
    2110                               MPFROM2SHORT(CMA_FIRSTCHILD, CMA_ITEMORDER));
    2111             if (!pciL) {
     2091            if (!pciP->fleshed) {
    21122092              AddFleshWorkRequest(hwnd, pciP, eFlesh);  // forceFlesh
    21132093            }
     
    24532433  case UM_DRIVECMD:
    24542434    if (mp1) {
    2455       //DbgMsg(pszSrcFile, __LINE__, "TreeCnrWndProc UM_DRIVECMD ShowTreeRec(\"%s\")", mp1);
     2435      DbgMsg(pszSrcFile, __LINE__, "TreeCnrWndProc UM_DRIVECMD ShowTreeRec(\"%s\")", mp1);
    24562436      ShowTreeRec(hwnd, (CHAR *)mp1, FALSE, TRUE);
    2457       //DbgMsg(pszSrcFile, __LINE__, "TreeCnrWndProc PostMsg(IDM_UPDATE)");
     2437      DbgMsg(pszSrcFile, __LINE__, "TreeCnrWndProc PostMsg(IDM_UPDATE)");
    24582438      PostMsg(hwndTree, WM_COMMAND, MPFROM2SHORT(IDM_UPDATE, 0), MPVOID);
    24592439    }
     
    29202900              if (pci->flags & RECFLAGS_UNDERENV)
    29212901                break;
    2922 
    2923               AddFleshWorkRequest(hwnd, pci, eUnFlesh);
     2902              if (pci->fleshed) {
     2903                if (x > 1) {
     2904                  DbgMsg(pszSrcFile, __LINE__,"UM_UPDATE UnFlesh %s", pci->pszFileName);
     2905                  AddFleshWorkRequest(hwnd, pci, eUnFlesh);
     2906                }
     2907                else
     2908                  UnFlesh(hwnd, pci);
     2909              }
    29242910
    29252911              // Check if drive type might need update
    29262912              if ((driveflag & (DRIVE_INVALID | DRIVE_NOPRESCAN)) ||
    2927                   (~driveflag & DRIVE_NOPRESCAN && pci->rc.hptrIcon == hptrDunno) || x < 2) {
     2913                  (~driveflag & DRIVE_NOPRESCAN && pci->rc.hptrIcon == hptrDunno)) {
    29282914                DriveFlagsOne(x, FileSystem, &volser);
    29292915                driveflag = driveflags[x];
    2930                 if (driveflag & DRIVE_INVALID)
    2931                   pci->rc.hptrIcon = hptrDunno;
     2916                if (driveflag & DRIVE_INVALID)
     2917                  if (driveflag & DRIVE_REMOVABLE) {
     2918                    pci->rc.hptrIcon = hptrRemovable;
     2919                    if (fShowFSTypeInTree || fShowDriveLabelInTree) {
     2920                      strcpy(szBuf, pci->pszFileName);
     2921                      strcat(szBuf, " [");
     2922                      strcat(szBuf, "]");
     2923                      pci->pszDisplayName = xstrdup(szBuf, pszSrcFile, __LINE__);
     2924                      pci->rc.pszIcon = pci->pszDisplayName;
     2925                    }
     2926                  }
     2927                  else
     2928                    pci->rc.hptrIcon = hptrDunno;
    29322929                else if (strlen(pci->pszFileName) < 4) {
    29332930                  SelectDriveIcon(pci);
     
    29472944                if (hwndMain)
    29482945                  PostMsg(hwndMain, UM_BUILDDRIVEBAR, MPVOID, MPVOID);
    2949               }
    2950               DbgMsg(pszSrcFile, __LINE__, " TreeCnrWndProc IDM_UPDATE %s", pci->pszFileName); // 2015-08-03 SHL FIXME debug
    2951               if (~driveflag & DRIVE_INVALID || x < 2)
    2952                 AddFleshWorkRequest(hwnd, pci, eFlesh);
     2946              }
     2947              if (~driveflag & DRIVE_INVALID) {
     2948                if (x > 1)  {
     2949                  // Note the UnFlesh above may not have completed when this is called
     2950                  // We need to keep it behind the UnFlesh in line
     2951                  AddFleshWorkRequest(hwnd, pci, eFlesh);
     2952                }
     2953                else
     2954                  Flesh(hwnd, pci);
     2955              }
    29532956            }
    29542957          }
     
    34843487                    volser.serial)
    34853488                {
    3486                   WaitFleshWorkListEmpty(pci->pszFileName, 10); // 2015-08-19 SHL in case pci still in work list
    3487                   AddFleshWorkRequest(dcd->hwndCnr, pci, eUnFlesh);
     3489                  if (pci->fleshed) {
     3490                    WaitFleshWorkListEmpty(pci->pszFileName, 10);       // 2015-08-19 SHL in case pci still in work list
     3491                    AddFleshWorkRequest(dcd->hwndCnr, pci, eUnFlesh);
     3492                  }
    34883493                }
    34893494                if (qmsg.msg != UM_COLLAPSETREE ||
     
    35013506              else {
    35023507                driveserial[toupper(*pci->pszFileName) - 'A'] = -1;
    3503                 WaitFleshWorkListEmpty(pci->pszFileName, 10);   // 2015-08-19 SHL in case pci still in work list
    3504                 AddFleshWorkRequest(dcd->hwndCnr, pci, eUnFlesh);
     3508                if (pci->fleshed) {
     3509                  WaitFleshWorkListEmpty(pci->pszFileName, 10); // 2015-08-19 SHL in case pci still in work list
     3510                  AddFleshWorkRequest(dcd->hwndCnr, pci, eUnFlesh);
     3511                }
    35053512                PostMsg(dcd->hwndCnr, UM_RESCAN, MPVOID, MPVOID);
    35063513                if (!fAlertBeepOff)
Note: See TracChangeset for help on using the changeset viewer.