Changeset 1856


Ignore:
Timestamp:
Aug 18, 2015, 7:12:52 PM (10 years ago)
Author:
Steven Levine
Message:

Rework Flesh/Stubby etc. to avoid running on thread 1
Should be ready for release after spurious traps resolved
DbgMsg calls retained - delete/disable before release

Location:
trunk
Files:
2 added
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/HISTORY

    r1807 r1856  
    11New stuff at the top.  This list is not necessarily complete.
     2
     33.24
     4 o Rework Flesh/Stubby logic to avoid doing work on thread 1
     5 o Add generic linked list support routines
    26
    373.23
  • trunk/dll/dircnrs.c

    r1838 r1856  
    77
    88  Copyright (c) 1993-98 M. Kimes
    9   Copyright (c) 2001, 2010 Steven H. Levine
     9  Copyright (c) 2001, 2015 Steven H. Levine
    1010
    1111  16 Oct 02 SHL Handle large partitions
     
    8585  22 Feb 14 GKY Fix warn readonly yes don't ask to work when recursing directories.
    8686  02 Mar 14 GKY Speed up intial drive scans Ticket 528
    87   26 Jun 14 SHL Rework DirObjWndProc UM_RESCAN to avoid hanging FM/2 Lite when tree hidden
     87  26 Jun 14 SHL Rework DirObjWndProc UM_RESCAN to avoid hanging FM/2 Lite when tree hidden
    8888  30 Aug 14 GKY Add semaphore hmtxFiltering to prevent freeing dcd while filtering. Prevents
    8989                a trap when FM2 is shutdown while directory containers are still populating
     
    9292  02 Aug 15 GKY Remove unneed SubbyScan code and improve suppression of blank lines and
    9393                duplicate subdirectory name caused by running Stubby in worker threads.
     94  07 Aug 15 SHL Rework to use AddFleshWorkRequest rather than direct calls to Stubby/Flesh/Unflesh
    9495
    9596***********************************************************************/
     
    139140                                        // SpecialSelect2
    140141#include "dirsize.h"                    // DirSizeProc
    141 #include "flesh.h"                      // Flesh, Stubby, UnFlesh
     142#include "flesh.h"                      // AddFleshWorkRequest
    142143#include "valid.h"                      // IsValidDir
    143144#include "objwin.h"                     // MakeObjWin
     
    766767#     ifdef FORTIFY
    767768      Fortify_BecomeOwner(dcd);         // We free dcd
    768       if (GetTidForThread() != 1)
    769       Fortify_ChangeScope(dcd, -1);
     769      if (GetTidForThread())
     770        Fortify_ChangeScope(dcd, -1);
    770771#     endif
    771772      // set unique id
     
    779780#   ifdef FORTIFY
    780781    // TID 1 will free data
    781     if (GetTidForThread() != 1)
     782    if (GetTidForThread())
    782783      Fortify_LeaveScope();
    783784#   endif
     
    844845                            MPFROM2SHORT(CMA_FIRSTCHILD, CMA_ITEMORDER));
    845846          if (!pciC) {
    846             Stubby(dcd->hwndCnr, pci);
     847            AddFleshWorkRequest(dcd->hwndCnr, pci, eStubby);
    847848          }
    848849        }
     
    899900      // 2014-06-26 SHL FM/2 Lite may not have drive tree yet
    900901      if (hwndTree) {
     902        // 2015-08-12 SHL Optimze to update drive tree for only last saved state
     903
     904        // 2015-08-13 SHL
     905        if (fSwitchTreeOnDirChg)
     906          DbgMsg(pszSrcFile, __LINE__, "DirObjWndProc UM_RESCAN cDirectoriesRestored %u", cDirectoriesRestored); // 2015-08-04 SHL FIXME debug
     907
    901908        if (fSwitchTreeOnDirChg) {
    902909          // Keep drive tree in sync with directory container
    903910          PSZ pszTempDir;
     911#if 0 // 2015-08-12 SHL FIXME to be gone fInitialDriveScan
    904912          while (fInitialDriveScan)
    905             DosSleep(10);                       // Allow to complete
    906           DosSleep(50);
     913            DosSleep(500);                      // Allow to complete
     914          DosSleep(200);                        // Allow to complete
     915#endif
    907916          pszTempDir = xstrdup(dcd->directory, pszSrcFile, __LINE__);
    908917          if (pszTempDir) {
    909918            if (hwndMain) {
    910               if (TopWindow(hwndMain, (HWND) 0) == dcd->hwndFrame)
     919              if (TopWindow(hwndMain, (HWND)0) == dcd->hwndFrame) {
     920                DbgMsg(pszSrcFile, __LINE__, "DirObjWndProc UM_RESCAN PostMsg(UM_SHOWME)"); // 2015-08-04 SHL FIXME debug
    911921                if (!PostMsg(hwndTree, UM_SHOWME, MPFROMP(pszTempDir), MPVOID))
    912922                  free(pszTempDir);
     923              }
    913924            }
    914925            else {
     926              DbgMsg(pszSrcFile, __LINE__, "DirObjWndProc UM_RESCAN PostMsg(UM_SHOWME)"); // 2015-08-04 SHL FIXME debug
    915927              if (!PostMsg(hwndTree, UM_SHOWME, MPFROMP(pszTempDir), MPVOID))
    916928                free(pszTempDir);
     
    12291241                        0,
    12301242                        0,
    1231                         SWP_RESTORE | SWP_SHOW | SWP_ACTIVATE | SWP_ZORDER);
     1243                        SWP_RESTORE | SWP_SHOW | SWP_ACTIVATE | SWP_ZORDER);
    12321244      FreeList(dcd->lastselection);
    12331245      WinSetWindowPtr(dcd->hwndCnr, QWL_USER, NULL);    // 13 Apr 10 SHL Set NULL before freeing dcd
     
    14211433      LastDir = hwnd;
    14221434      PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
     1435      // 2015-08-13 SHL
    14231436      if (fSwitchTreeOnFocus && hwndTree && dcd && *dcd->directory) {
    14241437        PSZ pszTempDir = xstrdup(dcd->directory, pszSrcFile, __LINE__);
     1438        DbgMsg(pszSrcFile, __LINE__, "DirCnrWndProc WM_SETFOCUS cDirectoriesRestored %u", cDirectoriesRestored); // 2015-08-04 SHL FIXME debug
    14251439        if (pszTempDir) {
     1440          DbgMsg(pszSrcFile, __LINE__, "DirCnrWndProc WM_SETFOCUS PostMsg(UM_SHOWME, %s)", pszTempDir); // 2015-08-04 SHL FIXME debug
    14261441          if (!PostMsg(hwndTree, UM_SHOWME, MPFROMP(pszTempDir), MPVOID))
    14271442            free(pszTempDir);           // Failed
     
    14901505      cnri.pszCnrTitle = dcd->directory;
    14911506      WinSendMsg(hwnd,
    1492                  CM_SETCNRINFO, MPFROMP(&cnri), MPFROMLONG(CMA_CNRTITLE));
     1507                 CM_SETCNRINFO, MPFROMP(&cnri), MPFROMLONG(CMA_CNRTITLE));
    14931508      DosRequestMutexSem(hmtxFiltering, SEM_INDEFINITE_WAIT);
    14941509      dcd->totalfiles = cnri.cRecords;
     
    15691584      WinSendMsg(hwnd,
    15701585                 CM_QUERYCNRINFO,
    1571                  MPFROMP(&cnri), MPFROMLONG(sizeof(CNRINFO)));
     1586                 MPFROMP(&cnri), MPFROMLONG(sizeof(CNRINFO)));
    15721587      cnri.pSortRecord = (PVOID) SortDirCnr;
    15731588      WinSendMsg(hwnd,
     
    15961611        cnri.flWindowAttr &= (~(CV_TREE | CV_ICON | CV_DETAIL | CV_TEXT));
    15971612        cnri.flWindowAttr |= (CV_NAME | CA_DETAILSVIEWTITLES | CV_MINI |
    1598                               CV_FLOW);
     1613                              CV_FLOW);
    15991614        cnri.pSortRecord = (PVOID) SortDirCnr;
    16001615
     
    16531668        WinEnableMenuItem(DirCnrMenu, IDM_FINDINTREE, (hwndTree != (HWND) 0));
    16541669      }
    1655       // 2014-06-11 SHL fm/2 lite can get here before drive scan completes
    1656       //if (!fInitialDriveScan) // 2014-08-30 GKY This doesn't seem to be needed
    1657         PostMsg(hwnd, UM_SETUP2, MPVOID, MPVOID);
     1670        // 2014-06-11 SHL fm/2 lite can get here before drive scan completes - may not be true anymore
     1671        PostMsg(hwnd, UM_SETUP2, MPVOID, MPVOID);
    16581672    }
    16591673    else {
     
    19631977
    19641978          if (pszTempDir) {
     1979            DbgMsg(pszSrcFile, __LINE__, "DirCnrWndProc IDM_FINDINTREE PostMsg(UM_SHOWME)"); // 2015-08-04 SHL FIXME debug
    19651980            if (!PostMsg(hwndTree, UM_SHOWME, MPFROMP(pszTempDir),
    19661981                            MPFROMLONG(1L)))
     
    21282143            dcd->sortFlags |= SORT_REVERSE;
    21292144          break;
    2130         }
     2145        }
    21312146        WinSendMsg(hwnd, CM_SORTRECORD, MPFROMP(SortDirCnr),
    21322147                   MPFROMLONG(dcd->sortFlags));
     
    27282743              case IDM_PRINT:
    27292744              case IDM_SHADOW:
    2730               case IDM_SHADOW2:
    2731               case IDM_JAVAEXE:
     2745              case IDM_SHADOW2:
     2746              case IDM_JAVAEXE:
    27322747              case IDM_OBJECT:
    27332748              case IDM_VIEW:
     
    28472862                  DosBeep(250,100);
    28482863                driveserial[toupper(*pci->pszFileName) - 'A'] = -1;
    2849                 UnFlesh(hwnd, pci);
     2864                AddFleshWorkRequest(hwnd, pci, eUnFlesh);
    28502865                PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
    28512866              }
     
    28552870                    driveserial[toupper(*pci->pszFileName) - 'A'] !=
    28562871                    volser.serial)
    2857                   UnFlesh(hwnd, pci);
     2872                  AddFleshWorkRequest(hwnd, pci, eUnFlesh);
    28582873                if (SHORT2FROMMP(mp1) != CN_COLLAPSETREE ||
    28592874                    (!volser.serial ||
    28602875                     driveserial[toupper(*pci->pszFileName) - 'A'] !=
    28612876                     volser.serial)) {
    2862                   if (SHORT2FROMMP(mp1) == CN_EXPANDTREE && Flesh(hwnd, pci) &&
     2877                  // 2015-08-07 SHL FIXME to wait for Flesh to finish before PostMsg
     2878                  if (SHORT2FROMMP(mp1) == CN_EXPANDTREE && AddFleshWorkRequest(hwnd, pci, eFlesh) &&
    28632879                      !dcd->suspendview && fTopDir ) {
    28642880                    PostMsg(hwnd, UM_TOPDIR, MPFROMP(pci), MPVOID);
     
    28702886            }
    28712887            else if (SHORT2FROMMP(mp1) == CN_EXPANDTREE) {
    2872               if (Flesh(hwnd, pci) && !dcd->suspendview && fTopDir) {
     2888              if (AddFleshWorkRequest(hwnd, pci, eFlesh) && !dcd->suspendview && fTopDir) {
     2889                // 2015-08-07 SHL FIXME to wait for Flesh to finish before PostMsg
    28732890                PostMsg(hwnd, UM_TOPDIR, MPFROMP(pci), MPVOID);
    28742891                //DbgMsg(pszSrcFile, __LINE__, "UM_TOPDIR %p pci %p", hwnd, pci);
     
    32753292          else {
    32763293
    3277             MRESULT mre;
    3278 
    3279             mre = CnrDirectEdit(hwnd, msg, mp1, mp2);
     3294            MRESULT mre;
     3295
     3296            mre = CnrDirectEdit(hwnd, msg, mp1, mp2);
    32803297            if (mre != (MRESULT) - 1)
    32813298              return mre;
     
    35303547    WinSendMsg(hwnd, WM_SAVEAPPLICATION, MPVOID, MPVOID);
    35313548    if (LastDir == hwnd)
    3532         LastDir = (HWND) 0;
     3549        LastDir = (HWND) 0;
    35333550    DosRequestMutexSem(hmtxFiltering, SEM_INDEFINITE_WAIT);
    35343551    if (dcd) {
     
    35493566                        0,
    35503567                        0,
    3551                         SWP_RESTORE | SWP_SHOW | SWP_ACTIVATE | SWP_ZORDER);
     3568                        SWP_RESTORE | SWP_SHOW | SWP_ACTIVATE | SWP_ZORDER);
    35523569      FreeList(dcd->lastselection);
    35533570      WinSetWindowPtr(hwnd, QWL_USER, NULL);
     
    38213838          Win_Error(hwndClient, hwndClient, pszSrcFile, __LINE__,
    38223839                    PCSZ_WINCREATEWINDOW);
    3823           PostMsg(hwndClient, WM_CLOSE, MPVOID, MPVOID);
    3824           DosRequestMutexSem(hmtxFiltering, SEM_INDEFINITE_WAIT);
    3825           free(dcd);
    3826           DosReleaseMutexSem(hmtxFiltering);
     3840          PostMsg(hwndClient, WM_CLOSE, MPVOID, MPVOID);
     3841          DosRequestMutexSem(hmtxFiltering, SEM_INDEFINITE_WAIT);
     3842          free(dcd);
     3843          DosReleaseMutexSem(hmtxFiltering);
    38273844          hwndFrame = (HWND) 0;
    38283845        }
  • trunk/dll/filldir.c

    r1838 r1856  
    77
    88  Copyright (c) 1993-98 M. Kimes
    9   Copyright (c) 2001, 2011 Steven H. Levine
     9  Copyright (c) 2001, 2015 Steven H. Levine
    1010
    1111  10 Jan 04 SHL ProcessDirectory: avoid most large drive failures
     
    5656  24 Nov 08 GKY Replace 4 pass drive scan code with StubyScanThread multithread scan
    5757  28 Nov 08 SHL FreeCnrItemData: optimize and always NULL pointers
    58   28 Nov 08 SHL StubbyScanThread: add else lost in translation
    59   30 Nov 08 SHL StubbyScanThread: restore else - we want all drives listed
     58  28 Nov 08 SHL StubbyThread: add else lost in translation
     59  30 Nov 08 SHL StubbyThread: restore else - we want all drives listed
    6060  30 Nov 08 SHL FreeCnrItemData: report double free with Runtime_Error
    6161  04 Dec 08 GKY Use event semaphore to prevent scan of "last" directory container prior to
     
    9898                responsiveness when closing containers with large numbers of items
    9999  12 Jun 11 GKY Replaced SleepIfNeeded with IdleIfNeeded in the container loade loop
    100   22 Oct 11 GKY Removing unneeded UnFlesh call from StubbyScanThread appears to significantly speed opening of FM/2
     100  22 Oct 11 GKY Removing unneeded UnFlesh call from StubbyThread appears to significantly speed opening of FM/2
    101101  02 Mar 14 GKY !didone for fFirstTime so the suggest code works again. Also clear out the
    102102                garbage that was appearing in the string.
     
    111111  02 Aug 15 GKY Serialize local hard drive scanning to reduce drive thrashing continue to scan
    112112                all other drive types in separate threads.
    113   02 Aug 15 GKY Remove unneed SubbyScan code and improve suppression of blank lines and
     113  02 Aug 15 GKY Remove unneeded SubbyScan code and improve suppression of blank lines and
    114114                duplicate subdirectory name caused by running Stubby in worker threads.
     115  04 Aug 15 SHL Comments
     116  04 Aug 15 SHL Move StubbyThread to flesh.c
     117  07 Aug 15 SHL Rework to use AddFleshWorkRequest rather than direct calls to Stubby/Flesh/Unflesh
    115118
    116119***********************************************************************/
     
    142145#include "fortify.h"                    // 06 May 08 SHL
    143146#include "notebook.h"                   // INI file fields
    144 #include "flesh.h"                      // FleshEnv, Stubby
     147#include "flesh.h"                      // AddFleshWorkRequest
    145148#include "update.h"                     // SelectDriveIcon
    146149#include "valid.h"                      // CheckDrive
     
    152155#include "i18nutil.h"                   // CommaFmtULL
    153156#include "wrappers.h"                   // xDosFindNext
    154 #include "init.h"                       // GetTidForWindow
    155 #include "common.h"                     // IncrThreadUsage
     157#include "init.h"
     158#include "common.h"
    156159#include "excputil.h"                   // xbeginthread
    157160#include "fm3dlg.h"                     // INFO_LABEL
     
    163166#endif
    164167
    165 VOID StubbyScanThread(VOID * arg);
    166 
    167168// Data definitions
    168169static PSZ pszSrcFile = __FILE__;
     
    178179PCSZ FM3Tools = "<FM3_Tools>";
    179180PCSZ WPProgram = "WPProgram";
    180 
    181 typedef struct {
    182   PCNRITEM      pci;
    183   HWND          hwndCnr;                // hwnd you want the message posted to
    184 }
    185 STUBBYSCAN;
    186181
    187182/**
     
    240235
    241236  return apszAttrString[fileAttr];
    242 
    243 }
    244 
    245 VOID StubbyScanThread(VOID * arg)
    246 {
    247   STUBBYSCAN *StubbyScan;
    248   HAB thab;
    249   HMQ hmq = (HMQ) 0;
    250   static INT ProcessDirCount = 0;
    251 
    252   DosError(FERR_DISABLEHARDERR);
    253 
    254 # ifdef FORTIFY
    255   Fortify_EnterScope();
    256 #  endif
    257 
    258   StubbyScan = (STUBBYSCAN *)arg;
    259   if (StubbyScan && StubbyScan->pci && StubbyScan->pci->pszFileName && StubbyScan->hwndCnr) {
    260     thab = WinInitialize(0);
    261     if (thab) {
    262       hmq = WinCreateMsgQueue(thab, 0);
    263       if (hmq) {
    264         IncrThreadUsage();
    265         priority_normal();
    266         if (WinIsWindow((HAB)0, StubbyScan->hwndCnr)) {
    267           ULONG flags = driveflags[toupper(*StubbyScan->pci->pszFileName) - 'A'];
    268 
    269           if ((fRScanLocal && flags & DRIVE_LOCALHD ) ||
    270                (fRScanRemote && flags & DRIVE_REMOTE) ||
    271                (fRScanVirtual && flags & DRIVE_VIRTUAL)) {
    272             if (!(flags & ((fRScanNoWrite ? 0 : DRIVE_NOTWRITEABLE) ||
    273                            (fRScanSlow ? 0 : DRIVE_SLOW)))) {
    274               Flesh(StubbyScan->hwndCnr, StubbyScan->pci);
    275             }
    276             else {
    277               Stubby(StubbyScan->hwndCnr, StubbyScan->pci);
    278             }
    279           }
    280           else {
    281             Stubby(StubbyScan->hwndCnr, StubbyScan->pci);
    282           }
    283           if (flags & DRIVE_LOCALHD)
    284             DosReleaseMutexSem(hmtxScanningLocalHD);
    285         }
    286         WinDestroyMsgQueue(hmq);
    287       }
    288       DecrThreadUsage();
    289       WinTerminate(thab);
    290     }
    291     free(StubbyScan);
    292   } // if StubbyScan
    293   ProcessDirCount++;
    294   // DbgMsg(pszSrcFile, __LINE__, "ProcessDirCount %i FixedVolume %i", ProcessDirCount, FixedVolume);
    295   if (ProcessDirCount >= FixedVolume) {
    296     DosReleaseMutexSem(hmtxScanning);
    297     DosPostEventSem(hevTreeCnrScanComplete);   
    298     ProcessDirCount = 0;
    299     FixedVolume = 0;
    300   }
    301 # ifdef FORTIFY
    302   Fortify_LeaveScope();
    303 #  endif
    304237
    305238}
     
    660593#   ifdef FORTIFY
    661594    {
    662       unsigned tid = GetTidForWindow(hwndCnr);
     595      UINT tid = GetTidForWindow(hwndCnr);
    663596      if (tid == 1)
    664597        Fortify_ChangeScope(pci->pszFmtFileSize, -1);
     
    741674  pci->pszFileName = xstrdup(pszFileName, pszSrcFile, __LINE__);
    742675
    743   // 13 Jul 09 SHL fixme to know if fetch can be bypassed if pszFSType already filled
     676  // 13 Jul 09 SHL FIXME to know if fetch can be bypassed if pszFSType already filled
    744677  // If FSType not supplied, assume don't need EAs either
    745678  if (pfsa4->cbList > 4L && dcd &&
     
    814747    pci->pszDisplayName = p;
    815748
    816   // 13 Jul 09 SHL fixme to know why pszFSType check needed
     749  // 13 Jul 09 SHL FIXME to know why pszFSType check needed
    817750  // comma format the file size for large file support
    818751  if (!pszFSType || *pszFSType == 0) {
     
    1015948            }
    1016949            else {
    1017               // 04 Jan 08 SHL fixme like comp.c to handle less than ulSelCnt records
     950              // 04 Jan 08 SHL FIXME like comp.c to handle less than ulSelCnt records
    1018951              pci = pciFirst;
    1019952              ullTotalBytes = 0;
     
    10691002                                 pszSrcFile, __LINE__);
    10701003            if (paffbTemp) {
    1071               // 13 Aug 07 SHL fixme to optimize copy
     1004              // 13 Aug 07 SHL FIXME to optimize copy
    10721005              paffbTotal = paffbTemp;
    10731006              ullTotalBytes = 0;        // 15 Sep 09 SHL
     
    11351068            }
    11361069            else {
    1137               // 04 Jan 08 SHL fixme like comp.c to handle less than ulSelCnt records
     1070              // 04 Jan 08 SHL FIXME like comp.c to handle less than ulSelCnt records
    11381071              if (hwndStatus && dcd &&
    11391072                  dcd->hwndFrame == WinQueryActiveWindow(dcd->hwndParent)) {
     
    12321165    }
    12331166
    1234     // 13 Oct 09 SHL fixme to be saymsg if ERROR_NOT_READY and first try on volume
     1167    // 13 Oct 09 SHL FIXME to be saymsg if ERROR_NOT_READY and first try on volume
    12351168    if (rc && rc != ERROR_NO_MORE_FILES && (fDontSuggestAgain || !fInitialDriveScan)) {
    12361169      Dos_Error(MB_ENTER, rc, HWND_DESKTOP, pszSrcFile, __LINE__,
     
    12571190      }
    12581191      if ((pci->attrFile & FILE_DIRECTORY))
    1259         Stubby(hwndCnr, pci);
     1192        AddFleshWorkRequest(hwndCnr, pci, eStubby);
    12601193      pci = WinSendMsg(hwndCnr, CM_QUERYRECORD, MPFROMP(pci),
    12611194                       MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER));
     
    12891222  DosPostEventSem(CompactSem);
    12901223
    1291 #if 0 // 2011-05-31 SHL fixme to be gone or to be configurable
     1224#if 0 // 2011-05-31 SHL FIXME to be gone or to be configurable
    12921225  {
    12931226    int state = _heapchk();
     
    13281261  static ULONG ulLastDriveMap;
    13291262
     1263  DbgMsg(pszSrcFile, __LINE__, "FillTreeCnr hwndCnr %x hwndParent %x", hwndCnr, hwndParent);     // 2015-08-03 SHL FIXME debug
     1264
    13301265  fDummy = TRUE;
    13311266  *szSuggest = 0;
     
    13811316  if (!pciFirst) {
    13821317    Win_Error(hwndCnr, HWND_DESKTOP, pszSrcFile, __LINE__, GetPString(IDS_CMALLOCRECERRTEXT));
    1383     // 04 Jan 08 SHL fixme not just up and die
     1318    // 04 Jan 08 SHL FIXME not just up and die
    13841319    exit(0);
    13851320  }
    13861321
    1387   // 04 Jan 08 SHL fixme like comp.c to handle less than ulSelCnt records
     1322  // 04 Jan 08 SHL FIXME like comp.c to handle less than ulSelCnt records
    13881323  pci = pciFirst;
    13891324  for (iDrvNum = 0; iDrvNum < 26; iDrvNum++) {
     
    14071342
    14081343      if (iDrvNum > 1) {
    1409         // Hard drive (2..N)
     1344        // Hard drive, 2..N, C:..Z:
    14101345        if (~driveflags[iDrvNum] & DRIVE_NOPRESCAN) {
    14111346          *szFSType = 0;
     
    15031438          driveserial[iDrvNum] = -1;
    15041439        }
    1505         }
     1440      } // if not diskette
    15061441      else {
    15071442        // diskette drive (A or B)
     
    15471482  ulLastDriveMap = ulDriveMap;          // 13 Oct 09 SHL
    15481483
    1549   // insert the drives
     1484  // insert the drives in container
    15501485  if (numtoinsert && pciFirst) {
    15511486    RECORDINSERT ri;
     
    16621597    }
    16631598  } // if show env
    1664   {
    1665     STUBBYSCAN *stubbyScan;
    1666 
    1667     pci = (PCNRITEM) WinSendMsg(hwndCnr,
    1668                                 CM_QUERYRECORD,
    1669                                 MPVOID,
    1670                                 MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER));
    1671     while (pci && (INT)pci != -1) {
    1672       stubbyScan = xmallocz(sizeof(STUBBYSCAN), pszSrcFile, __LINE__);
    1673       if (!stubbyScan)
    1674         break;
    1675       stubbyScan->pci = pci;
    1676       stubbyScan->hwndCnr = hwndCnr;
    1677       pciNext = (PCNRITEM) WinSendMsg(hwndCnr,
    1678                                       CM_QUERYRECORD,
    1679                                       MPFROMP(pci),
    1680                                       MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER));
    1681       if (~pci->flags & RECFLAGS_ENV) {
    1682         iDrvNum = toupper(*pci->pszFileName) - 'A';     // 0..25
    1683         if (iDrvNum == ulCurDriveNum || iDrvNum >= 2) {
    1684           // Hard drive or current drive
    1685           ULONG flags = driveflags[iDrvNum];    // Speed up
    1686           if (~flags & DRIVE_INVALID &&
    1687               ~flags & DRIVE_NOPRESCAN && (!fNoRemovableScan || ~flags & DRIVE_REMOVABLE)) {
    1688             // DbgMsg(pszSrcFile, __LINE__, "Begin Thread %s", pci->pszFileName);
    1689             if (flags & DRIVE_LOCALHD) {
    1690               DosRequestMutexSem(hmtxScanningLocalHD, SEM_INDEFINITE_WAIT );
    1691               if (xbeginthread(StubbyScanThread,
    1692                                65536,
    1693                                stubbyScan,
    1694                                pszSrcFile, __LINE__) == -1) {
    1695                 DosReleaseMutexSem(hmtxScanningLocalHD);
    1696                 xfree(stubbyScan, pszSrcFile, __LINE__);
    1697               }
    1698             }
    1699             else {
    1700               if (xbeginthread(StubbyScanThread,
    1701                                65536,
    1702                                stubbyScan,
    1703                                pszSrcFile, __LINE__) == -1)
    1704                 xfree(stubbyScan, pszSrcFile, __LINE__);
    1705             }
    1706 
    1707           } // if drive needs to be scanned
    1708         }
    1709         else {
    1710           // Diskette and not current drive
    1711           WinSendMsg(hwndCnr,
    1712                      CM_INVALIDATERECORD,
    1713                      MPFROMP(&pci),
    1714                      MPFROM2SHORT(1, CMA_ERASE | CMA_REPOSITION));
    1715         }
    1716       }
    1717       pci = pciNext;
    1718     } // while
    1719   }
    1720 
    1721   // 13 Oct 09 SHL
     1599
     1600  // Run Stubby on each hard drive to ensure expand/collapse buttons correct
     1601  pci = (PCNRITEM) WinSendMsg(hwndCnr,
     1602                              CM_QUERYRECORD,
     1603                              MPVOID,
     1604                              MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER));
     1605  while (pci && (INT)pci != -1) {
     1606    pciNext = (PCNRITEM) WinSendMsg(hwndCnr,
     1607                                    CM_QUERYRECORD,
     1608                                    MPFROMP(pci),
     1609                                    MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER));
     1610    if (~pci->flags & RECFLAGS_ENV) {
     1611      iDrvNum = toupper(*pci->pszFileName) - 'A';       // 0..25
     1612      if (iDrvNum == ulCurDriveNum || iDrvNum >= 2) {
     1613        // Hard drive or current drive
     1614        ULONG flags = driveflags[iDrvNum];      // Speed up
     1615        if (~flags & DRIVE_INVALID &&
     1616            ~flags & DRIVE_NOPRESCAN &&
     1617            (!fNoRemovableScan || ~flags & DRIVE_REMOVABLE)) {
     1618          AddFleshWorkRequest(hwndCnr, pci, eFillDir);
     1619        } // if drive needs to be scanned
     1620      }
     1621      else {
     1622        // Diskette or not current drive
     1623        WinSendMsg(hwndCnr,
     1624                   CM_INVALIDATERECORD,
     1625                   MPFROMP(&pci),
     1626                   MPFROM2SHORT(1, CMA_ERASE | CMA_REPOSITION));
     1627      }
     1628    }
     1629    pci = pciNext;
     1630  } // while pci
     1631
     1632  // Deselect all
    17221633  if (hwndDrivelist)
    17231634    WinSendMsg(hwndDrivelist, LM_SELECTITEM, MPFROM2SHORT(0, 0), MPFROMLONG(TRUE));
    17241635
     1636  // Fill in environment CNRITEMs, if any
    17251637  pci = (PCNRITEM) WinSendMsg(hwndCnr,
    17261638                              CM_QUERYRECORD,
     
    17401652      while (pci && (INT)pci != -1) {
    17411653        if (pci->flags & RECFLAGS_ENV)
    1742           FleshEnv(hwndCnr, pci);
     1654          AddFleshWorkRequest(hwndCnr, pci, eFleshEnv);
    17431655        pci = (PCNRITEM) WinSendMsg(hwndCnr,
    17441656                                    CM_QUERYRECORD,
     
    17561668  if (hwndMain)
    17571669    PostMsg(hwndMain, UM_BUILDDRIVEBAR, MPVOID, MPVOID);
    1758   DosSleep(16);                         // 05 Aug 07 GKY 33
     1670
     1671  DosSleep(16);
    17591672  fDummy = FALSE;
     1673
    17601674  fInitialDriveScan = FALSE;
     1675  DbgMsg(pszSrcFile, __LINE__, "fInitialDriveScan now FALSE");   // 2015-08-03 SHL FIXME debug
    17611676  DosPostEventSem(CompactSem);
    17621677
     
    17771692      }
    17781693    }
    1779     //DbgMsg(pszSrcFile, __LINE__, "szSuggest %x info %x", *szSuggest, info);
     1694    // DbgMsg(pszSrcFile, __LINE__, "szSuggest %x info %x", *szSuggest, info);
    17801695    if (*szSuggest) {
    17811696      APIRET rc;
     
    18371752  } // if !fDontSuggestAgain
    18381753  didonce = TRUE;
     1754
     1755  DbgMsg(pszSrcFile, __LINE__, "FillTreeCnr finished");  // 2015-08-03 SHL FIXME debug
     1756
    18391757} // FillTreeCnr
    18401758
     
    20982016
    20992017#pragma alloc_text(FILLDIR,FillInRecordFromFFB,FillInRecordFromFSA,IDFile)
    2100 #pragma alloc_text(FILLDIR1,ProcessDirectory,FillDirCnr,FillTreeCnr,FileAttrToString,StubbyScanThread)
     2018#pragma alloc_text(FILLDIR1,ProcessDirectory,FillDirCnr,FillTreeCnr,FileAttrToString)
    21012019#pragma alloc_text(EMPTYCNR,EmptyCnr,FreeCnrItemData,FreeCnrItem,FreeCnrItemList,RemoveCnrItems)
    21022020
  • trunk/dll/flesh.c

    r1837 r1856  
    44  $Id$
    55
    6   Flesh
     6  Drive tree container management
    77
    88  Copyright (c) 1993-98 M. Kimes
    9   Copyright (c) 2005-2012 Steven H. Levine
     9  Copyright (c) 2005-2015 Steven H. Levine
    1010
    1111  24 May 05 SHL Rework Win_Error usage
     
    2626  08 Mar 09 GKY Additional strings move to PCSZs in init.c
    2727  13 Dec 09 GKY Fixed separate paramenters. Please note that appname should be used in
    28                 profile calls for user settings that work and are setable in more than one
    29                 miniapp; FM3Str should be used for setting only relavent to FM/2 or that
    30                 aren't user settable; realappname should be used for setting applicable to
    31                 one or more miniapp but not to FM/2
     28                profile calls for user settings that work and are setable in more than one
     29                miniapp; FM3Str should be used for setting only relavent to FM/2 or that
     30                aren't user settable; realappname should be used for setting applicable to
     31                one or more miniapp but not to FM/2
    3232  17 Jan 10 GKY Changes to get working with Watcom 1.9 Beta (1/16/10). Mostly cast CHAR CONSTANT * as CHAR *.
    3333  04 Aug 12 GKY Fix trap on close during drive scan
    3434  02 Aug 15 GKY Fix trap in Stubby
     35  03 Aug 15 SHL Document Stubby a bit better
     36  07 Aug 15 SHL Rework to use AddFleshWorkRequest rather than direct calls to Stubby/Flesh/Unflesh
    3537
    3638***********************************************************************/
     
    5860#include "flesh.h"
    5961#include "valid.h"                      // IsValidDir
    60 #include "misc.h"                       // LoadLibPath
     62#include "misc.h"                       // LoadLibPath GetTidForThread
    6163#include "findrec.h"                    // FindCnrRecord
    6264#include "notify.h"                     // Notify
    6365#include "wrappers.h"                   // xfree
    6466#include "excputil.h"                   // xbeginthread
     67#include "listutil.h"                   // List...
     68#include "common.h"                     // IncrThreadUsage DecrThreadUsage
     69
    6570#if 0
    6671#define  __PMPRINTF__
     
    7378static PSZ pszSrcFile = __FILE__;
    7479
     80
     81static INT tidFleshWorkListThread = -1; // 2015-08-08 SHL
     82
     83static CHAR chFleshFocusDrive;  // 2015-08-16 SHL A..Z or 0
     84
     85
     86BOOL fNoFleshDbgMsg;    // 2015-08-09 SHL FIXME to be gone
     87
    7588#pragma data_seg(GLOBAL1)
    7689ULONG NoBrokenNotify;
    7790BOOL fFilesInTree;
     91
     92BOOL Flesh(HWND hwndCnr, PCNRITEM pciParent);
     93
     94BOOL Stubby(HWND hwndCnr, PCNRITEM pciParent);
     95BOOL FleshEnv(HWND hwndCnr, PCNRITEM pciParent);
     96BOOL UnFlesh(HWND hwndCnr, PCNRITEM pciParent);
     97
     98/**
     99 * Insert CNRITEMs for members of PATH-like environment variable
     100 * @param hwndCnr is the container to be populated
     101 * @param pciParent is CNRITEM defining PATH-like environment variable
     102 * @return TRUE if OK, FALSE is error detected
     103 */
    78104
    79105BOOL FleshEnv(HWND hwndCnr, PCNRITEM pciParent)
     
    86112  if (!pciParent || (INT) pciParent == -1 || !hwndCnr)
    87113    return FALSE;
     114
    88115  dcd = (DIRCNRDATA *) WinQueryWindowPtr(hwndCnr, QWL_USER);
    89116  if (!dcd)
     
    187214}
    188215
     216/**
     217 * Insert CNRITEMs for all children of pciParent
     218 * @param hwnCnr is container to receive CNRITEMs
     219 * @param pciParent is CNRITEM to have children inserted
     220 * @return TRUE if OK, FALSE is error detected
     221 */
     222
    189223BOOL Flesh(HWND hwndCnr, PCNRITEM pciParent)
    190224{
    191225  PCNRITEM pciL;
    192226  DIRCNRDATA *dcd;
    193   BOOL includefiles = fFilesInTree;
    194 
    195   if (!pciParent || (INT) pciParent == -1 || !hwndCnr)
     227  BOOL includefiles;
     228
     229  if (!pciParent || (INT)pciParent == -1 || !hwndCnr)
    196230    return FALSE;
    197   pciL = (PCNRITEM) WinSendMsg(hwndCnr,
    198                                CM_QUERYRECORD,
    199                                MPFROMP(pciParent),
    200                                MPFROM2SHORT(CMA_FIRSTCHILD, CMA_ITEMORDER));
    201   if (!pciL || !*pciL->pszFileName) {
    202     if (pciL && (INT) pciL != -1)
     231
     232  // 2015-08-13 SHL FIXME to optimize
     233  if (fAmClosing) {
     234    // Can jiggle - see MainWndProc WM_CLOSE
     235    DosSleep(100);
     236    if (fAmClosing)
     237      return FALSE;                     // time to die
     238  }
     239
     240  // 2015-08-03 SHL FIXME debug
     241  if (!fNoFleshDbgMsg) {
     242    DbgMsg(pszSrcFile, __LINE__, "Flesh %s pciParent %p pszFileName %p",
     243           pciParent && (INT)pciParent != -1 && pciParent->pszFileName ?
     244             pciParent->pszFileName : "(null)",
     245           pciParent,
     246           pciParent && (INT)pciParent != -1 ? pciParent->pszFileName : (PVOID)-1); // 2015-08-03 SHL FIXME debug
     247  }
     248
     249  pciL = (PCNRITEM)WinSendMsg(hwndCnr,
     250                              CM_QUERYRECORD,
     251                              MPFROMP(pciParent),
     252                              MPFROM2SHORT(CMA_FIRSTCHILD, CMA_ITEMORDER));
     253
     254  // 2015-08-06 SHL allow pciL -1
     255  if (!pciL || (INT)pciL == -1 || !*pciL->pszFileName) {
     256
     257    // No children or filename null
     258    // 2015-08-06 SHL FIXME to know how this can happen
     259    if (pciL && (INT)pciL != -1) {
     260      // 2015-08-06 SHL FIXME to loop and timeout if Stubby threads working
     261      if (!fNoFleshDbgMsg)
     262        DbgMsg(pszSrcFile, __LINE__, "Flesh RemoveCnrItems() pciL %p", pciL); // 2015-08-04 SHL FIXME debug
    203263      RemoveCnrItems(hwndCnr, pciL, 1, CMA_FREE);
     264    }
     265
    204266    dcd = INSTDATA(hwndCnr);
    205267    if (dcd && dcd->size != sizeof(DIRCNRDATA))
    206268      dcd = NULL;
    207     if (driveflags[toupper(*pciParent->pszFileName) - 'A'] & DRIVE_INCLUDEFILES)
    208       includefiles = TRUE;
     269
     270    // DbgMsg(pszSrcFile, __LINE__, "Flesh %s dcd %p called by %s#%u", pciParent->pszFileName, dcd, pszSrcFile_, uSrcLineNo_); // 2015-08-03 SHL FIXME debug
     271
     272    // 2015-08-06 SHL FIXME to not trap here
     273    includefiles =
     274      driveflags[toupper(*pciParent->pszFileName) - 'A'] & DRIVE_INCLUDEFILES ?
     275        TRUE : fFilesInTree;
     276
    209277    ProcessDirectory(hwndCnr,
    210                      pciParent,
    211                      pciParent->pszFileName,
    212                      includefiles,      // filestoo
    213                      TRUE,              // recurse
    214                      TRUE,              // partial
    215                      NULL,              // stop flag
    216                      dcd,
    217                      NULL,              // total files
    218                      NULL);             // total bytes
     278                     pciParent,
     279                     pciParent->pszFileName,
     280                     includefiles,      // filestoo
     281                     TRUE,              // recurse
     282                     TRUE,              // partial
     283                     NULL,              // stop flag
     284                     dcd,
     285                     NULL,              // total files
     286                     NULL);             // total bytes
    219287    if (pciParent && pciParent->pszFileName && !(driveflags[toupper(*pciParent->pszFileName) - 'A'] & DRIVE_RSCANNED))
    220288      driveflags[toupper(*pciParent->pszFileName) - 'A'] |= DRIVE_RSCANNED;
    221289    return TRUE;
    222290  }
     291
    223292  return FALSE;
    224293}
    225294
     295// 2015-08-06 SHL FIXME to be VOID
     296
    226297BOOL UnFlesh(HWND hwndCnr, PCNRITEM pciParent)
    227298{
    228   BOOL ret = FALSE;
     299  BOOL removed = FALSE;
    229300  PCNRITEM pciL;
    230301
    231302  if (!pciParent || !hwndCnr)
    232303    return FALSE;
     304
     305  if (!fNoFleshDbgMsg)
     306    DbgMsg(pszSrcFile, __LINE__, "UnFlesh pciParent %p pszFileName %s", pciParent, pciParent->pszFileName ? pciParent->pszFileName : "(null)"); // 2015-08-03 SHL FIXME debug
     307
    233308  for (;;) {
    234309    pciL = (PCNRITEM) WinSendMsg(hwndCnr,
     
    236311                                 MPFROMP(pciParent),
    237312                                 MPFROM2SHORT(CMA_FIRSTCHILD, CMA_ITEMORDER));
    238     if (pciL && (INT) pciL != -1) {
    239       ret = TRUE;
    240       RemoveCnrItems(hwndCnr, pciL, 1, CMA_FREE);
    241     }
    242     else
    243       break;
    244   }
    245   if (ret) {
     313    if (!pciL || (INT)pciL == -1)
     314      break;                    // Done
     315
     316    if (!fNoFleshDbgMsg)
     317      DbgMsg(pszSrcFile, __LINE__, "UnFlesh RemoveCnrItems() pciL %p %s", pciL, pciL->pszFileName ? pciL->pszFileName : "(null)"); // 2015-08-03 SHL FIXME debug
     318    RemoveCnrItems(hwndCnr, pciL, 1, CMA_FREE);
     319    removed = TRUE;
     320  } // for
     321
     322  if (removed) {
    246323    WinSendMsg(hwndCnr,
    247324               CM_INVALIDATERECORD,
     
    249326               MPFROM2SHORT(1, CMA_ERASE | CMA_REPOSITION));
    250327  }
    251   return ret;
     328  return removed;
    252329}
    253330
     
    255332
    256333/**
    257  * Fill in drive tree subtree
    258  * @return TRUE if OK, else FALSE
    259  * This only scans the root directory and adds the first level directories
    260  * Flesh does a recursive scan and should be used on fast hardware.
     334 * Insert CNRITEM for 1st subdirectory [or file] of pciParent
     335 * @param hwdCnr is container to be filled
     336 * @param pciParent is CNRITEM to receive child record
     337 * @return TRUE if record inserted, else FALSE
     338 * Ensures that expand/collapse button displays if directory has children
     339 * Secondary purpose is to detect broken LANs and inaccesible mapped drives
    261340 */
    262341
     
    273352  PFILEFINDBUF3 pffb;
    274353  HDIR hDir = HDIR_CREATE;
    275   ULONG nm, ulM = 1, total = 0, fl = MUST_HAVE_DIRECTORY;
     354  ULONG nm, ulM = 1, total = 0, fl;
    276355  CHAR str[CCHMAXPATH];
    277356  register INT len;
    278357  APIRET rc, prc;
    279   BOOL isadir = FALSE, isremote = FALSE, includefiles = fFilesInTree;
     358  BOOL isadir = FALSE, isremote, includefiles;
    280359  ULONG ddepth = DDEPTH;
    281360  ULONG drvNum;
     
    286365      || pciParent->pszFileName == NullStr || !hwndCnr)
    287366    return FALSE;
    288  
     367
     368  if (!fNoFleshDbgMsg)
     369    DbgMsg(pszSrcFile, __LINE__, "Stubby pciParent %p pszFileName %s", pciParent, pciParent->pszFileName); // 2015-08-03 SHL FIXME debug
     370
     371  // Build wildcard
    289372  len = strlen(pciParent->pszFileName);
    290373  memcpy(str, pciParent->pszFileName, len + 1);
     
    302385      str[1] != ':' ||
    303386      str[2] != '\\' || ((flags & DRIVE_IGNORE)))
    304     return FALSE;                       // Not a directory
    305 
    306   if (flags & DRIVE_INCLUDEFILES)
    307     includefiles = TRUE;
    308 
    309   if (flags & DRIVE_REMOTE)
    310     isremote = TRUE;
     387    return FALSE;                       // Not a directory or ignore requested
     388
     389  includefiles = flags & DRIVE_INCLUDEFILES ? TRUE : fFilesInTree;
     390
     391  isremote = flags & DRIVE_REMOTE ? TRUE : FALSE;
    311392
    312393  if (isremote) {
     
    323404
    324405  if (!fRemoteBug)
    325     ulM = (ddepth <= DDEPTH) ? ddepth : 1;
     406    ulM = ddepth <= DDEPTH ? ddepth : 1;
    326407
    327408  nm = ulM;
    328409
    329410  DosError(FERR_DISABLEHARDERR);
    330   if (includefiles)
    331     fl = FILE_DIRECTORY;
     411
     412  fl = includefiles ? FILE_DIRECTORY : MUST_HAVE_DIRECTORY;
     413
    332414  rc = DosFindFirst(str,
    333415                    &hDir,
     
    337419                    &ffb, ulM * sizeof(FILEFINDBUF3), &nm, FIL_STANDARD);
    338420  if (ulM == 1 && !rc) {
     421    // Loop looking for 1st directory (or file)
    339422    do {
    340423      pffb = &ffb[0];
    341424      if (!includefiles && !(pffb->attrFile & FILE_DIRECTORY) && !brokenlan) {
     425        // Find returned file when only directories requested
    342426        brokenlan = TRUE;
    343427        ddepth = (ULONG) - 1;
     
    364448        }
    365449      }
     450
    366451      if (*pffb->achName &&
    367452          (includefiles || (pffb->attrFile & FILE_DIRECTORY)) &&
    368           // Skip . and ..
    369453          (pffb->achName[0] != '.' ||
    370454           (pffb->achName[1] &&
    371455            (pffb->achName[1] != '.' || pffb->achName[2])))) {
     456        // Got directory other than . or .. (or a file)
    372457        DosFindClose(hDir);
    373458        isadir = TRUE;
     
    376461      nm = 1;
    377462      DosError(FERR_DISABLEHARDERR);
    378     }
    379     while (++total < ddepth && !(rc = (DosFindNext(hDir,
    380                                                    &ffb,
    381                                                    sizeof(FILEFINDBUF3),
    382                                                    &nm))));
    383       DosFindClose(hDir);
    384     // If drive B:
     463    } while (++total < ddepth && !(rc = (DosFindNext(hDir,
     464                                                     &ffb,
     465                                                     sizeof(FILEFINDBUF3),
     466                                                     &nm))));
     467    DosFindClose(hDir);
     468
    385469    if (toupper(*pciParent->pszFileName) > 'B' &&
    386470        (*(pciParent->pszFileName + 1)) == ':' &&
    387471        (*(pciParent->pszFileName + 2)) == '\\' && !(*(pciParent->pszFileName + 3))) {
    388472
     473      // Searching root of hard or remote drive and find reported error
    389474      CHAR s[132];
    390475      sprintf(s,
     
    397482      Notify(s);
    398483    }
    399     goto None;
    400   }
    401  
     484    goto None;                          // Done
     485  }
     486
    402487  if (!rc) {
    403488    DosFindClose(hDir);
     
    407492        pffb = (PFILEFINDBUF3) fb;
    408493        if (!includefiles && !(pffb->attrFile & FILE_DIRECTORY)) {
     494          // Got file(s), but did not ask for files
    409495          if (!isbroken) {
    410496            isbroken = TRUE;
     
    432518                                  &NoBrokenNotify, sizeof(ULONG));
    433519            }
    434           }
    435         }
     520          } // if !broken
     521        } // if !directory
     522
    436523        if (*pffb->achName &&
    437524            (includefiles || (pffb->attrFile & FILE_DIRECTORY)) &&
    438             // Skip . and ..
    439             ((pffb->achName[0] && pffb->achName[0] != '.') || (pffb->achName[1]
    440                                          && (pffb->achName[1] != '.'
    441                                              || pffb->achName[2])))) {
     525            ((pffb->achName[0] && pffb->achName[0] != '.') ||
     526             (pffb->achName[1] &&
     527              (pffb->achName[1] != '.' || pffb->achName[2]))))
     528        {
     529          // Got directory other than . or .. (or a file)
    442530          isadir = TRUE;
    443531          break;
     
    450538      if (isadir) {
    451539
     540        // Insert CNRITEM for selected directory (or file)
    452541        PCNRITEM pci;
    453542
     
    471560            ri.zOrder = (ULONG) CMA_TOP;
    472561            ri.cRecordsInsert = 1;
    473             ri.fInvalidateRecord = TRUE;
    474             //DbgMsg(pszSrcFile, __LINE__, "Stubby %p CM_INSERTRECORD \"%s\" %.255s", hwndCnr, pci->pszFileName, pffb->achName); // 18 Dec 08 SHL fixme debug
     562            ri.fInvalidateRecord = TRUE;
     563            // DbgMsg(pszSrcFile, __LINE__, "Stubby CM_INSERTRECORD %p \"%s\" %.255s", pci, pci->pszFileName, pffb->achName); // 2015-08-03 SHL FIXME debug
    475564            if (!WinSendMsg(hwndCnr,
    476565                            CM_INSERTRECORD, MPFROMP(pci), MPFROMP(&ri))) {
     566              // Assume busy and try again
    477567              DosSleep(50); //05 Aug 07 GKY 100
    478               WinSetFocus(HWND_DESKTOP, hwndCnr);
    479               if (WinIsWindow((HAB)0, hwndCnr)) {
    480                 //DbgMsg(pszSrcFile, __LINE__, "Stubby %p CM_INSERTRECORD %s", hwndCnr, pci->pszFileName); // 18 Dec 08 SHL fixme debug
     568              WinSetFocus(HWND_DESKTOP, hwndCnr);
     569              if (WinIsWindow((HAB)0, hwndCnr)) {
     570                if (!fNoFleshDbgMsg)
     571                  DbgMsg(pszSrcFile, __LINE__, "Stubby CM_INSERTRECORD pci %p pszFileName %s", pci, pci->pszFileName); // 2015-08-03 SHL FIXME debug
    481572                if (!WinSendMsg(hwndCnr,
    482573                                CM_INSERTRECORD, MPFROMP(pci), MPFROMP(&ri))) {
     
    490581            }
    491582            else
    492               ok = TRUE;
    493             }
     583              ok = TRUE;
    494584          }
    495585        }
     586      } // if isadir
    496587      else if (toupper(*str) > 'B' && str[1] == ':' && str[2] == '\\' &&
    497588               !str[3]) {
    498589
     590        // Is root and no subdirectories
    499591        CHAR s[162];
    500 
    501592        sprintf(s,
    502593                GetPString(IDS_NOSUBDIRS2TEXT),
    503594                nm,
    504595                toupper(*pciParent->pszFileName),
    505                 (isremote) ? GetPString(IDS_NOSUBDIRS3TEXT) : NullStr);
     596                isremote ? GetPString(IDS_NOSUBDIRS3TEXT) : NullStr);
    506597        Notify(s);
    507598      }
     
    509600  }
    510601  else if (toupper(*str) > 'B' && rc != ERROR_NO_MORE_FILES) {
     602    // Find for remote or hard drive failed with error
    511603    CHAR s[CCHMAXPATH + 80];
    512604    sprintf(s, GetPString(IDS_SEARCHERRORTEXT), rc, str);
     
    518610  DosError(FERR_DISABLEHARDERR);
    519611  return ok;
    520 }
    521 
    522 #pragma alloc_text(FLESH,Flesh,FleshEnv,UnFlesh,Stubby)
     612} // Stubby
     613
     614// Stubby/Flesh/Unflesh work list item
     615
     616typedef struct {
     617  LIST2 list;
     618  HWND hwndCnr;
     619  PCNRITEM pci;
     620  FLESHWORKACTION action;
     621} FLESHWORKITEM;
     622typedef FLESHWORKITEM *PFLESHWORKITEM;
     623
     624// Stubby/Flesh/Unflesh work list
     625LIST2 FleshWorkList;
     626
     627HMTX hmtxFleshWork;
     628HEV  hevFleshWorkListChanged;
     629
     630/**
     631 * Check pci matches
     632 */
     633
     634BOOL WorkListItemMatches(PLIST2 item, PVOID data)
     635{
     636  return ((PFLESHWORKITEM)data)->pci == ((PFLESHWORKITEM)item)->pci;
     637}
     638
     639/**
     640 * Delete stale items from flesh queue
     641 */
     642
     643VOID DeleteStaleFleshWorkListItems(PCNRITEM pci)
     644{
     645  FLESHWORKITEM match;
     646  PLIST2 item;
     647
     648  match.pci = pci;
     649
     650  for (;;) {
     651    item = List2Search(&FleshWorkList, WorkListItemMatches, &match);
     652    if (!item)
     653      break;
     654    DbgMsg(pszSrcFile, __LINE__, "DeleteStaleFleshWorkListItems deleting %p %s", pci, pci->pszFileName ? pci->pszFileName : "(null)"); // 2015-08-03 SHL FIXME debug
     655    List2Delete(&FleshWorkList, item);
     656    xfree(item, pszSrcFile, __LINE__);
     657  }
     658}
     659
     660/**
     661 * Add item to flesh work list
     662 * eUnFlesh requests get special handling
     663 * eFlesh etc. items for the same CNRITEM are considered stale and are
     664 * deleted because eUnFlesh will free the CNRITEM associated with the item
     665 * before the work list item is processed
     666 */
     667
     668#if 0 // 2015-08-03 SHL FIXME debug
     669BOOL AddFleshWorkRequest(HWND hwndCnr, PCNRITEM pci, FLESHWORKACTION action)
     670#else
     671BOOL AddFleshWorkRequestDbg(HWND hwndCnr, PCNRITEM pci, FLESHWORKACTION action, PCSZ pszSrcFile_, UINT uSrcLineNo)
     672#endif
     673{
     674  APIRET rc;
     675
     676  PFLESHWORKITEM item = xmallocz(sizeof(FLESHWORKITEM), pszSrcFile, __LINE__);
     677  item->hwndCnr = hwndCnr;
     678  item->pci = pci;
     679  item->action= action;
     680
     681  if (fAmClosing) {
     682    // Can jiggle - see MainWndProc WM_CLOSE
     683    DosSleep(100);
     684    if (fAmClosing)
     685      return FALSE;
     686  }
     687
     688  // 2015-08-03 SHL FIXME debug
     689  {
     690#if 0 // 2015-08-13 SHL FIXME to be gone
     691    static PSZ itemNames[] = {
     692            "eStubby", "eFlesh", "eFleshEnv", "eUnFlesh"
     693    };
     694
     695#   ifdef AddFleshWorkRequest
     696    if (!pci || (INT)pci == -1) {
     697      Runtime_Error(pszSrcFile, __LINE__, "AddFleshWorkRequest called with action %s pci %p by %s:%u",
     698             itemNames[item->action],
     699             pci,
     700             pszSrcFile_, uSrcLineNo); // 2015-08-03 SHL FIXME debug
     701    }
     702    else if (!pci->pszFileName) {
     703      Runtime_Error(pszSrcFile, __LINE__, "AddFleshWorkRequest call with action %s pci %p pszFileName (null) by %s:%u",
     704             itemNames[item->action],
     705             pci,
     706             pszSrcFile_, uSrcLineNo); // 2015-08-03 SHL FIXME debug
     707    }
     708    else if (!fNoFleshDbgMsg) {
     709      DbgMsg(pszSrcFile, __LINE__, "AddFleshWorkRequest called with action %s pci %p pszFileName %s by %s:%u",
     710             itemNames[item->action],
     711             pci,
     712             pci->pszFileName,
     713             pszSrcFile_, uSrcLineNo); // 2015-08-03 SHL FIXME debug
     714    }
     715#else
     716    if (!pci || (INT)pci == -1) {
     717      Runtime_Error(pszSrcFile, __LINE__, "AddFleshWorkRequest call with action %s pci %p",
     718             itemNames[item->action],
     719             pci); // 2015-08-03 SHL FIXME debug
     720    }
     721    else if (!pci->pszFileName) {
     722      Runtime_Error(pszSrcFile, __LINE__, "AddFleshWorkRequest called with action %s pci %p pszFileName (null)",
     723             itemNames[item->action],
     724             pci); // 2015-08-03 SHL FIXME debug
     725    }
     726    else if (!fNoFleshDbgMsg) {
     727      DbgMsg(pszSrcFile, __LINE__, "AddFleshWorkRequest action %s pci %p pszFileName %s",
     728             itemNames[item->action],
     729             pci,
     730             pci->pszFileName); // 2015-08-03 SHL FIXME debug
     731    }
     732#endif
     733#endif
     734  }
     735
     736  rc = DosRequestMutexSem(hmtxFleshWork, SEM_INDEFINITE_WAIT);
     737  if (rc)
     738    Dos_Error(MB_ENTER, rc, HWND_DESKTOP, pszSrcFile, __LINE__, "DosRequestMutexSem");
     739
     740  // 2015-08-13 SHL FIXME to be done
     741  // Delete stale requests
     742  if (item->action == eUnFlesh) {
     743    DeleteStaleFleshWorkListItems(pci);
     744  }
     745
     746  List2Append(&FleshWorkList, (PLIST2)item);
     747
     748  rc = DosReleaseMutexSem(hmtxFleshWork);
     749  if (rc)
     750    Dos_Error(MB_ENTER, rc, HWND_DESKTOP, pszSrcFile, __LINE__, "DosReleaseMutexSem");
     751
     752  rc = DosPostEventSem(hevFleshWorkListChanged);
     753  if (rc && rc != ERROR_ALREADY_POSTED)
     754    Dos_Error(MB_ENTER, rc, HWND_DESKTOP, pszSrcFile, __LINE__, "DosPostEventSem");
     755
     756  return TRUE;
     757}
     758
     759/**
     760 * Return TRUE if work list empty
     761 * Advisory only
     762 */
     763
     764BOOL IsFleshWorkListEmpty()
     765{
     766  return FleshWorkList.next == NULL;
     767}
     768
     769/**
     770 * Wait until work list empty
     771 * Advisory only
     772 */
     773
     774#if 0 // 2015-08-03 SHL FIXME debug
     775VOID WaitFleshWorkListEmpty()
     776#else
     777VOID WaitFleshWorkListEmptyDbg(PCSZ pszSrcFile_, UINT uSrcLineNo_)
     778#endif
     779{
     780  INT tid = GetTidForThread();
     781
     782  if (tid == 1 || tid == tidFleshWorkListThread) {
     783#   ifdef WaitFleshWorkListEmpty
     784    Runtime_Error(pszSrcFile, __LINE__, "WaitFleshWorkListEmpty called with worklist %sempty by tid %u at %s:%u", IsFleshWorkListEmpty() ? "" : "not ", tid, pszSrcFile_, uSrcLineNo_);
     785#   else
     786    Runtime_Error(pszSrcFile, __LINE__, "WaitFleshWorkListEmpty called by tid %u", tid);
     787#   endif
     788    return;             // Avoid hang
     789  }
     790  else if (IsFleshWorkListEmpty()) {
     791#   ifdef WaitFleshWorkListEmpty
     792    DbgMsg(pszSrcFile, __LINE__, "WaitFleshWorkListEmpty called with worklist empty by tid %u at %s:%u", tid, pszSrcFile_, uSrcLineNo_);
     793#   else
     794    DbgMsg(pszSrcFile, __LINE__, "WaitFleshWorkListEmpty called with work list empty by tid %u", tid);
     795#   endif
     796  }
     797
     798  // Can not wait if call from thread 1 or FleshWorkListThread
     799  while (!IsFleshWorkListEmpty()) {
     800#   ifdef WaitFleshWorkListEmpty
     801    if (!fNoFleshDbgMsg)
     802      // DbgMsg(pszSrcFile, __LINE__, "WaitFleshWorkListEmpty called with work list not empty by %s:%u", pszSrcFile_, uSrcLineNo_); // 2015-08-07 SHL FIXME debug
     803#   else
     804    if (!fNoFleshDbgMsg)
     805      // DbgMsg(pszSrcFile, __LINE__, "WaitFleshWorkListEmpty called with work list not empty"); // 2015-08-07 SHL FIXME debug
     806#   endif
     807    // 2015-08-13 SHL FIXME to optimize
     808    if (fAmClosing) {
     809      // Can jiggle - see MainWndProc WM_CLOSE
     810      DosSleep(100);
     811      if (fAmClosing)
     812        return;
     813    }
     814    DosSleep(250);
     815  }
     816}
     817
     818/**
     819 * Set focus drive to optimize work list processing
     820 * @param chDriveLetter is upper case drive letter (A-Z)
     821 */
     822
     823VOID SetFleshFocusDrive(CHAR chDriveLetter) {
     824  chFleshFocusDrive = chDriveLetter;
     825  DbgMsg(pszSrcFile, __LINE__, "SetFleshFocusDrive focus drive set to %c", chFleshFocusDrive); // 2015-08-03 SHL FIXME debug
     826
     827}
     828
     829/**
     830 * Check pci pathname matches focus drive
     831 * @param data is uppercase drive letter mapped to PVOID
     832 * @return TRUE if drive letter matches
     833 */
     834
     835BOOL MatchesFocusDrive(PLIST2 item, PVOID data)
     836{
     837  if (!((PFLESHWORKITEM)item)->pci->pszFileName) {
     838    Runtime_Error(pszSrcFile, __LINE__, "MatchesFocusDrive called with pci %p pszFileName (null) by %s:%u", ((PFLESHWORKITEM)item)->pci);
     839    return FALSE;
     840  }
     841  return ((PFLESHWORKITEM)item)->pci->pszFileName[0] == (CHAR)data;
     842}
     843
     844/**
     845 * Run Flesh, UnFlesh, FleshEnv, Stubby for directory for items in work list
     846 */
     847
     848VOID FleshWorkThread(PVOID arg)
     849{
     850  HAB thab;
     851  HMQ hmq = (HMQ)0;
     852  APIRET rc;
     853
     854  // 2015-08-07 SHL FIXME to be gone
     855  static INT ProcessDirCount = 0;
     856
     857  DosError(FERR_DISABLEHARDERR);
     858
     859# ifdef FORTIFY
     860  Fortify_EnterScope();
     861#  endif
     862
     863  thab = WinInitialize(0);
     864  if (thab) {
     865    hmq = WinCreateMsgQueue(thab, 0);
     866    if (hmq) {
     867      IncrThreadUsage();
     868      priority_normal();
     869
     870      // 2015-08-07 SHL FIXME to know when to terminate
     871      // process list entries forever
     872      for (;;) {
     873
     874        PFLESHWORKITEM item;
     875
     876        // 2015-08-13 SHL FIXME to optimize
     877        if (fAmClosing) {
     878          // Can jiggle - see MainWndProc WM_CLOSE
     879          DosSleep(100);
     880          if (fAmClosing)
     881            break;                      // time to die
     882        }
     883
     884        // 2015-08-07 SHL FIXME to use SMPSafe...
     885        rc = DosRequestMutexSem(hmtxFleshWork, SEM_INDEFINITE_WAIT);
     886        if (rc)
     887          Dos_Error(MB_ENTER, rc, HWND_DESKTOP, pszSrcFile, __LINE__, "DosRequestMutexSem");
     888
     889        // 2015-08-14 SHL
     890        // Get next work list item and remove from list
     891        // If focus drive known, process items for focus drive first
     892        if (chFleshFocusDrive) {
     893          item = (PFLESHWORKITEM)List2Search(&FleshWorkList, MatchesFocusDrive, (PVOID)chFleshFocusDrive);
     894          if (!item)
     895            chFleshFocusDrive = 0;              // Revert to normal
     896          else
     897            List2Delete(&FleshWorkList, (PLIST2)item);
     898        }
     899        else
     900          item = NULL;
     901
     902        if (!item)
     903          item = (PFLESHWORKITEM)List2DeleteFirst(&FleshWorkList);
     904
     905        rc = DosReleaseMutexSem(hmtxFleshWork);
     906        if (rc)
     907          Dos_Error(MB_ENTER, rc, HWND_DESKTOP, pszSrcFile, __LINE__, "DosReleaseMutexSem");
     908
     909        // 2015-08-07 SHL FIXME to have event sem
     910        if (!item) {
     911          ULONG ul;
     912          if (!fNoFleshDbgMsg)
     913            DbgMsg(pszSrcFile, __LINE__, "FleshWorkThread work list empty - waiting"); // 2015-08-03 SHL FIXME debug
     914          rc = DosWaitEventSem(hevFleshWorkListChanged, SEM_INDEFINITE_WAIT);
     915          if (rc)
     916            Dos_Error(MB_ENTER, rc, HWND_DESKTOP, pszSrcFile, __LINE__, "DosWaitEventSem");
     917          rc = DosResetEventSem(hevFleshWorkListChanged, &ul);
     918          if (rc)
     919            Dos_Error(MB_ENTER, rc, HWND_DESKTOP, pszSrcFile, __LINE__, "DosResetEventSem");
     920          if (!fNoFleshDbgMsg)
     921            DbgMsg(pszSrcFile, __LINE__, "FleshWorkThread work hev posted"); // 2015-08-03 SHL FIXME debug
     922          continue;
     923        }
     924
     925        if (WinIsWindow((HAB)0, item->hwndCnr)) {
     926
     927          ULONG flags;
     928
     929#if 0 // 2015-08-07 SHL FIXME debug
     930          // 2015-08-03 SHL FIXME debug
     931          {
     932            static PSZ itemNames[] = {
     933                    "eStubby", "eFlesh", "eFleshEnv", "eUnFlesh"
     934            };
     935
     936            PCNRITEM pci = item->pci;
     937            if (!fNoFleshDbgMsg) {
     938              DbgMsg(pszSrcFile, __LINE__, "FleshWorkThread action %s pci %p pszFileName %s",
     939                     itemNames[item->action],
     940                     pci,
     941                     pci && (INT)pci != -1 ?
     942                       (pci->pszFileName ? pci->pszFileName : "(nullname)") :
     943                       "(nullpci)"); // 2015-08-03 SHL FIXME debug
     944            }
     945          }
     946#endif
     947
     948          switch (item->action) {
     949          case eUnFlesh:
     950            UnFlesh(item->hwndCnr, item->pci);
     951            break;
     952          case eFleshEnv:
     953            FleshEnv(item->hwndCnr, item->pci);
     954            break;
     955          case eFillDir:
     956          case eStubby:
     957            // DbgMsg(pszSrcFile, __LINE__, "FleshWorkThread pci %p pszFileName %s", stubbyArgs->pci, stubbyArgs->pci->pszFileName); // 2015-08-03 SHL FIXME debug
     958            flags = driveflags[toupper(*item->pci->pszFileName) - 'A'];
     959
     960#if 0 // 2015-08-07 SHL FIXME to be gone
     961            if (flags & DRIVE_LOCALHD) {
     962              // Serialize to prevent head thrashing
     963              rc = DosRequestMutexSem(hmtxScanningLocalHD, SEM_INDEFINITE_WAIT);
     964              if (rc)
     965                Dos_Error(MB_ENTER, rc, HWND_DESKTOP, pszSrcFile, __LINE__, "DosRequestMutexSem");
     966            }
     967#endif
     968
     969#if 1
     970            if (item->action == eFillDir) {
     971              // eFillDir maps to eFlesh or eStubby depending on fRScan.. settings
     972              if (((fRScanLocal && flags & DRIVE_LOCALHD) ||
     973                   (fRScanRemote && flags & DRIVE_REMOTE) ||
     974                   (fRScanVirtual && flags & DRIVE_VIRTUAL))  &&
     975                  (!(flags & ((fRScanNoWrite ? 0 : DRIVE_NOTWRITEABLE) |
     976                              (fRScanSlow ? 0 : DRIVE_SLOW)))))
     977              {
     978                item->action = eFlesh;
     979              }
     980              else
     981                item->action = eStubby;
     982            }
     983#else
     984            wantFlesh = ((fRScanLocal && flags & DRIVE_LOCALHD ) ||
     985                         (fRScanRemote && flags & DRIVE_REMOTE) ||
     986                         (fRScanVirtual && flags & DRIVE_VIRTUAL))  &&
     987                         // 2015-08-11 SHL typo - should not be local or
     988                        (!(flags & ((fRScanNoWrite ? 0 : DRIVE_NOTWRITEABLE) ||
     989                                    (fRScanSlow ? 0 : DRIVE_SLOW))));
     990#endif
     991            if (item->action == eStubby) {
     992              Stubby(item->hwndCnr, item->pci);
     993              break;
     994            }
     995            // Drop through to eFlesh
     996
     997
     998#if 0 // 2015-08-07 SHL FIXME to be gone
     999            if (flags & DRIVE_LOCALHD) {
     1000              rc = DosReleaseMutexSem(hmtxScanningLocalHD);
     1001              if (rc) {
     1002                Dos_Error(MB_ENTER, rc, HWND_DESKTOP, pszSrcFile, __LINE__,
     1003                          "DosReleaseMutexSem(hmtxScanningLocalHD)");
     1004              }
     1005            }
     1006#endif // 2015-08-07 SHL FIXME to be gone
     1007
     1008            // Drop through
     1009          case eFlesh:
     1010            if (Flesh(item->hwndCnr, item->pci)) {
     1011              // 2015-08-06 SHL FIXME to report?
     1012            }
     1013            break;
     1014          default:
     1015            Runtime_Error(pszSrcFile, __LINE__, "item %u unexpected", item->action);
     1016          } // switch
     1017
     1018
     1019        } // if window
     1020
     1021        xfree(item, pszSrcFile, __LINE__);
     1022
     1023      } // for
     1024
     1025      WinDestroyMsgQueue(hmq);
     1026    }
     1027    DecrThreadUsage();
     1028    WinTerminate(thab);
     1029  }
     1030
     1031  ProcessDirCount++;
     1032  // DbgMsg(pszSrcFile, __LINE__, "ProcessDirCount %i FixedVolume %i", ProcessDirCount, FixedVolume);
     1033  if (ProcessDirCount >= FixedVolume) {
     1034
     1035#if 0 // 2015-08-04 SHL FIXME to be gone
     1036    rc = DosReleaseMutexSem(hmtxScanning);
     1037    if (rc)
     1038      Dos_Error(MB_ENTER, rc, HWND_DESKTOP, pszSrcFile, __LINE__, "DosReleaseMutexSem");
     1039#endif // 2015-08-04 SHL FIXME to be gone
     1040
     1041#if 0 // 2015-08-04 SHL FIXME to be gone
     1042    rc = DosPostEventSem(hevTreeCnrScanComplete);
     1043    if (rc && rc != ERROR_ALREADY_POSTED)
     1044      Dos_Error(MB_ENTER, rc, HWND_DESKTOP, pszSrcFile, __LINE__, "DosPostEventSem");
     1045#endif // 2015-08-04 SHL FIXME to be gone
     1046
     1047    ProcessDirCount = 0;
     1048    FixedVolume = 0;
     1049  }
     1050
     1051# ifdef FORTIFY
     1052  Fortify_LeaveScope();
     1053#  endif
     1054
     1055}
     1056
     1057/**
     1058 * Allocate resources and start FleshWorkThread
     1059 * @return TRUE if OK
     1060 */
     1061
     1062BOOL StartFleshWorkThread()
     1063{
     1064  APIRET rc = DosCreateMutexSem(NULL, &hmtxFleshWork, 0L /* Not shared */, FALSE /* Not owned */);
     1065  if (rc) {
     1066    Dos_Error(MB_CANCEL, rc, HWND_DESKTOP, pszSrcFile, __LINE__,
     1067              PCSZ_DOSCREATEMUTEXSEM);
     1068    return FALSE;
     1069  }
     1070
     1071  rc = DosCreateEventSem(NULL, &hevFleshWorkListChanged, 0 /* Not shared */, FALSE /* Reset */);
     1072  if (rc) {
     1073    Dos_Error(MB_CANCEL, rc, HWND_DESKTOP, pszSrcFile, __LINE__,
     1074              PCSZ_DOSCREATEEVENTSEM);
     1075    return FALSE;
     1076  }
     1077
     1078  /* DbgMsg is time consuming
     1079     define FM2_NO_FLESH_DBGMSG to suppress
     1080     2015-08-09 SHL FIXME to be gone
     1081   */
     1082
     1083  fNoFleshDbgMsg = getenv("FM2_NO_FLESH_DBGMSG") != NULL;
     1084
     1085  tidFleshWorkListThread = xbeginthread(FleshWorkThread,
     1086                           65536,
     1087                           NULL,
     1088                           pszSrcFile, __LINE__);
     1089  return tidFleshWorkListThread != -1;
     1090
     1091}
     1092
     1093#pragma alloc_text(FLESH,Flesh,FleshEnv,UnFlesh,Stubby,FleshWorkThread,StartFleshWorkThread,AddFleshWorkRequest)
  • trunk/dll/flesh.h

    r1207 r1856  
    44  $Id$
    55
    6   <<<description here>>>
     6  Drive tree container management
    77
    88  Copyright (c) 1993-98 M. Kimes
    9   Copyright (c) 2008 Steven H. Levine
     9  Copyright (c) 2008, 2015 Steven H. Levine
    1010
    11   Change log
     11  07 Aug 15 SHL Rework to use AddFleshWorkRequest rather than direct calls to Stubby/Flesh/Unflesh
    1212
    1313***********************************************************************/
     
    1616#define FLESH_H
    1717
    18 BOOL Flesh(HWND hwndCnr, PCNRITEM pciParent);
    19 BOOL FleshEnv(HWND hwndCnr, PCNRITEM pciParent);
    20 BOOL Stubby(HWND hwndCnr, PCNRITEM pciParent);
    21 BOOL UnFlesh(HWND hwndCnr, PCNRITEM pciParent);
     18BOOL StartFleshWorkThread(VOID);
     19
     20typedef enum {eStubby, eFlesh, eFleshEnv, eUnFlesh, eFillDir} FLESHWORKACTION;
     21
     22BOOL IsFleshWorkListEmpty();
     23
     24VOID SetFleshFocusDrive(CHAR chDriveLetter);
     25
     26#if 0 // 2015-08-03 SHL FIXME debug
     27VOID WaitFleshWorkListEmpty();
     28#else
     29#define WaitFleshWorkListEmpty() WaitFleshWorkListEmptyDbg(__FILE__, __LINE__)
     30VOID WaitFleshWorkListEmptyDbg(PCSZ pszSrcFile, UINT uSrcLineNo);
     31#endif
     32
     33#if 0 // 2015-08-03 SHL FIXME debug
     34BOOL AddFleshWorkRequest(HWND hwndCnr, PCNRITEM pci, FLESHWORKACTION action);
     35#else
     36#define AddFleshWorkRequest(hwnCnr, pciParent, action) AddFleshWorkRequestDbg(hwnCnr, pciParent, action, __FILE__, __LINE__)
     37BOOL AddFleshWorkRequestDbg(HWND hwndCnr, PCNRITEM pci, FLESHWORKACTION action, PCSZ pszSrcFile, UINT uSrcLineNo);
     38#endif
    2239
    2340// Data declarations
     
    2542extern BOOL fFilesInTree;
    2643
     44
    2745#endif // FLESH_H
  • trunk/dll/init.c

    r1846 r1856  
    77
    88  Copyright (c) 1993-98 M. Kimes
    9   Copyright (c) 2001, 2010 Steven H. Levine
     9  Copyright (c) 2001, 2015 Steven H. Levine
    1010
    1111  11 Jun 02 SHL Add CheckVersion
     
    211211#include "excputil.h"                   // xbeginthread
    212212#include "systemf.h"                    // runemf2
     213
    213214#if 0
    214215#define  __PMPRINTF__
    215216#include "PMPRINTF.H"
    216217#endif
     218
    217219extern int _CRT_init(void);
    218220extern void _CRT_term(void);
     
    236238HMTX hmtxFM2Delete;
    237239HMTX hmtxFM2Globals;
     240
     241#if 0 // 2015-08-04 SHL FIXME to be gone
    238242HMTX hmtxScanning;
     243#endif // 2015-08-04 SHL FIXME to be gone
     244
     245#if 0 // 2015-08-07 SHL FIXME to be gone
    239246HMTX hmtxScanningLocalHD;
    240 HMTX hmtxScanningLocal;
     247#endif // 2015-08-07 SHL FIXME to be gone
     248
    241249HMTX hmtxFiltering;
     250
     251#if 0 // 2015-08-04 SHL FIXME to be gone
    242252HEV  hevTreeCnrScanComplete;
     253#endif // 2015-08-04 SHL FIXME to be gone
     254
    243255ULONG OS2ver[2];
    244256PFNWP PFNWPCnr;
     
    249261ULONG ulTimeFmt;
    250262ULONG ulDateFmt;
    251 ULONG ulScanPostCnt;
    252263BOOL fDontSuggestAgain;
    253264BOOL fInitialDriveScan;
     
    712723  }
    713724
    714     rc = DosExitList(EXLST_ADD, DeInitFM3DLL);
    715     if (rc) {
    716       Dos_Error(MB_ENTER, rc, HWND_DESKTOP, pszSrcFile, __LINE__,
    717                "DosExitList");
    718     }
    719 
    720     rcq = DosQueryProcAddr(FM3ModHandle, 1, "ResVersion", &pfnResVersion);
    721     if (!rcq)
    722       ret = pfnResVersion(&RVMajor, &RVMinor);
     725  rc = DosExitList(EXLST_ADD, DeInitFM3DLL);
     726  if (rc) {
     727    Dos_Error(MB_ENTER, rc, HWND_DESKTOP, pszSrcFile, __LINE__,
     728             "DosExitList");
     729  }
     730
     731  rcq = DosQueryProcAddr(FM3ModHandle, 1, "ResVersion", &pfnResVersion);
     732  if (!rcq)
     733    ret = pfnResVersion(&RVMajor, &RVMinor);
    723734  else {
    724735    ret = 0;
     
    739750    return FALSE;
    740751  }
     752
    741753#if 0
    742754  PmPrintfDisplayInterfaceVersionInfo();
    743755  PmPrintfQueueNameThisProcess(NULL);
    744756#endif
     757
    745758  if (!*profile)
    746759    strcpy(profile, PCSZ_FM3DOTINI);
     
    769782  }
    770783
    771   //Save the FM2 save directory name. This is the location of the ini, dat files etc.
     784  // Save the FM2 save directory name. This is the location of the ini, dat files etc.
    772785  rc = save_dir2(temp);
    773786  if (rc) {
     
    885898  }
    886899
     900  if (!StartFleshWorkThread())
     901    return FALSE;
     902
    887903  // timer messages are sent from a separate thread -- start it
    888904  if (!StartTimer()) {
     
    11661182                   sizeof(PVOID));
    11671183
    1168   if (DosCreateMutexSem(NULL, &hmtxFM2Globals, 0L, FALSE))
     1184  rc = DosCreateMutexSem(NULL, &hmtxFM2Globals, 0L, FALSE);
     1185  if (rc) {
    11691186    Dos_Error(MB_CANCEL, rc, HWND_DESKTOP, pszSrcFile, __LINE__,
    11701187              PCSZ_DOSCREATEMUTEXSEM);
     1188  }
     1189#if 0 // 2015-08-04 SHL FIXME to be gone
    11711190  if (DosCreateMutexSem(NULL, &hmtxScanning, 0L, TRUE))
    11721191    Dos_Error(MB_CANCEL, rc, HWND_DESKTOP, pszSrcFile, __LINE__,
    11731192              PCSZ_DOSCREATEMUTEXSEM);
    1174   if (DosCreateMutexSem(NULL, &hmtxScanningLocalHD, 0L, FALSE))
     1193#endif // 2015-08-04 SHL FIXME to be gone
     1194#if 0 // 2015-08-07 SHL FIXME to be gone
     1195  rc = DosCreateMutexSem(NULL, &hmtxScanningLocalHD, 0L, FALSE);
     1196  if (rc) {
    11751197    Dos_Error(MB_CANCEL, rc, HWND_DESKTOP, pszSrcFile, __LINE__,
    11761198              PCSZ_DOSCREATEMUTEXSEM);
    1177     if (DosCreateMutexSem(NULL, &hmtxScanningLocal, 0L, FALSE))
    1178     Dos_Error(MB_CANCEL, rc, HWND_DESKTOP, pszSrcFile, __LINE__,
    1179               PCSZ_DOSCREATEMUTEXSEM);
    1180   if (DosCreateMutexSem(NULL, &hmtxFM2Delete, 0L, FALSE))
     1199  }
     1200#endif // 2015-08-07 SHL FIXME to be gone
     1201  rc = DosCreateMutexSem(NULL, &hmtxFM2Delete, 0L, FALSE);
     1202  if (rc) {
    11811203    Dos_Error(MB_CANCEL, rc, HWND_DESKTOP, pszSrcFile, __LINE__,
    11821204              PCSZ_DOSCREATEMUTEXSEM);
    1183   if (DosCreateMutexSem(NULL, &hmtxFiltering, 0L, FALSE))
     1205  }
     1206  rc = DosCreateMutexSem(NULL, &hmtxFiltering, 0L, FALSE);
     1207  if (rc) {
    11841208    Dos_Error(MB_CANCEL, rc, HWND_DESKTOP, pszSrcFile, __LINE__,
    11851209              PCSZ_DOSCREATEMUTEXSEM);
    1186   if (DosCreateEventSem(NULL, &hevTreeCnrScanComplete, 0L, TRUE))
     1210  }
     1211#if 0 // 2015-08-04 SHL FIXME to be gone
     1212  rc = DosCreateEventSem(NULL, &hevTreeCnrScanComplete, 0L, TRUE);
     1213  if (rc) {
    11871214    Dos_Error(MB_CANCEL, rc, HWND_DESKTOP, pszSrcFile, __LINE__,
    11881215              PCSZ_DOSCREATEEVENTSEM);
     1216  }
     1217#endif // 2015-08-04 SHL FIXME to be gone
    11891218
    11901219  /**
     
    16531682  PrfQueryProfileData(fmprof, FM3Str, "DontAskGzip", &fDontAskGzip, &size);
    16541683
     1684  // 2015-08-11 SHL FIXME debug
     1685  DbgMsg(pszSrcFile, __LINE__, "ShowEnv %u SwitchTree %u SwitchTreeExpand %u SwitchTreeOnFocus %u CollapseFirst %u", fShowEnv, fSwitchTreeOnDirChg, fSwitchTreeExpand, fSwitchTreeOnFocus, fCollapseFirst);
     1686  DbgMsg(pszSrcFile, __LINE__, "RScanLocal %u RScanRemote %u RScanVirtual %u RScanSlow RScanNoWrite %u", fRScanLocal, fRScanRemote, fRScanVirtual, fRScanSlow, fRScanNoWrite);
     1687
    16551688  LoadDetailsSwitches(PCSZ_DIRCNR, &dsDirCnrDefault, FALSE);
    16561689
  • trunk/dll/init.h

    r1838 r1856  
    44  $Id$
    55
    6   <<<description here>>>
     6  Initialization
    77
    88  Copyright (c) 1993-98 M. Kimes
    9   Copyright (c) 2008-10 Steven H. Levine
     9  Copyright (c) 2008, 2015 Steven H. Levine
    1010
    1111  Change log
     
    107107extern ULONG ulTimeFmt;
    108108extern ULONG ulDateFmt;
    109 extern ULONG ulScanPostCnt;
    110109extern PCSZ FNT_HELVETICA;
    111110extern PCSZ FNT_6HELVETICA;
     
    239238extern HMTX hmtxFM2Globals;
    240239extern HMTX hmtxFM2Delete;
     240
     241#if 0 // 2015-08-07 SHL FIXME to be gone
    241242extern HMTX hmtxScanning;
     243#endif // 2015-08-07 SHL FIXME to be gone
     244
     245#if 0 // 2015-08-07 SHL FIXME to be gone
    242246extern HMTX hmtxScanningLocalHD;
    243 extern HMTX hmtxScanningLocal;
     247#endif // 2015-08-07 SHL FIXME to be gone
     248
    244249extern HMTX hmtxFiltering;
     250
     251#if 0 // 2015-08-04 SHL FIXME to be gone
    245252extern HEV  hevTreeCnrScanComplete;
     253#endif // 2015-08-04 SHL FIXME to be gone
     254
    246255#endif
    247256
  • trunk/dll/mainwnd.c

    r1844 r1856  
    117117  02 Aug 15 GKY Remove unneed SubbyScan code and improve suppression of blank lines and
    118118                duplicate subdirectory name caused by running Stubby in worker threads.
     119                duplicate subdirectory name caused by running Stubby in worker threads.
    119120  09 Aug 15 SHL Use RESTORE_STATE_...
     121  13 Aug 15 SHL Sync with Flesh/Stubby mods
    120122
    121123***********************************************************************/
     
    239241USHORT shiftstate;
    240242
     243UINT cDirectoriesRestored;              // 2015-08-12 SHL Incremented by RestoreDirCnrState
     244
    241245#pragma data_seg(GLOBAL2)
    242246HMODULE FM3ModHandle;
     
    18201824MRESULT EXPENTRY DriveBackProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
    18211825{
     1826#if 0 // 2015-08-04 SHL FIXME to be gone
    18221827  APIRET rc;
     1828#endif // 2015-08-04 SHL FIXME to be gone
    18231829
    18241830  static BOOL emphasized;
     
    20952101
    20962102  case WM_COMMAND:
     2103#if 0 // 2015-08-04 SHL FIXME to be gone
    20972104    rc = DosWaitEventSem(hevTreeCnrScanComplete, SEM_INDEFINITE_WAIT);
    20982105    if (rc)
    20992106      Dos_Error(MB_ENTER, rc, HWND_DESKTOP, pszSrcFile, __LINE__, "DosWaitEventSem");
     2107#endif // 2015-08-04 SHL FIXME to be gone
    21002108
    21012109    switch(SHORT1FROMMP(mp1)) {
     
    21362144          HWND hwndActive = TopWindow(hwnd, (HWND) 0);
    21372145          if (hwndActive)
     2146            DbgMsg(pszSrcFile, __LINE__, "WinSendMsg UM_DRIVECMD %c", *dv); // 2015-08-04 SHL FIXME debug
    21382147            WinSendMsg(WinWindowFromID(hwndActive, FID_CLIENT),
    21392148                       UM_DRIVECMD, MPFROMP(dv), MPVOID);
     
    34463455  HWND hwndDir, hwndC, hwndPPSave = NULLHANDLE;
    34473456  SWP swp, swpO, swpN;
    3448   ULONG size, numsaves = 0;
     3457  ULONG size;
     3458  ULONG numsaves = 0;
    34493459  LONG x;
    34503460  double xtrans, ytrans;
     
    34643474
    34653475  sprintf(szPrefix, "%s.", pszStateName);
     3476
     3477  DbgMsg(pszSrcFile, __LINE__, "RestoreDirCnrState %s", pszStateName);  // 2015-08-13 SHL FIXME debug
    34663478
    34673479  // If restoring shutdown state bypass no-prescan drives
     
    35333545  size = sizeof(ULONG);
    35343546  if (PrfQueryProfileData(fmprof, FM3Str, szKey, (PVOID) &numsaves, &size)) {
     3547    // 2015-08-13 SHL TreeCnrWndProc UM_RESCAN has already requested a UM_RESCAN2 which
     3548    // will result in an extra UM_SHOWME
     3549    // RestoreDirCnrState can be called before pending UM_SHOWMEs complete - oh well
     3550    if (fSwitchTreeOnFocus && numsaves)
     3551      cDirectoriesRestored = 1;
     3552    else
     3553      cDirectoriesRestored = 0;
    35353554    if (fDeleteState)
    35363555      PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
     
    36313650                  }
    36323651                }
     3652                // 2015-08-12 SHL Suppress drive tree updates if not last container to restore
     3653                if (fSwitchTreeOnFocus)
     3654                  cDirectoriesRestored++;       // 2015-08-12 SHL
     3655
    36333656                if (!PostMsg(hwndCnr, UM_SETUP2, NULL, NULL))
    36343657                  WinSendMsg(hwndCnr, UM_SETUP2, NULL, NULL);
     
    36603683        }
    36613684      }
    3662     } // for
     3685    } // for numsaves
    36633686    if (hwndPPSave) {
    36643687      SavePresParams(hwndPPSave, PCSZ_DIRCNR);
    36653688      WinDestroyWindow(hwndPPSave);
    36663689    }
     3690    DbgMsg(pszSrcFile, __LINE__, "RestoreDirCnrState returning fRestored %u", fRestored);       // 2015-08-13 SHL FIXME debug
    36673691  }
     3692
    36683693  return fRestored;
    36693694}
     
    65336558            }
    65346559            else if (SHORT1FROMMP(mp1) == MAIN_DRIVELIST) {
     6560              DbgMsg(pszSrcFile, __LINE__, "MainWndProc CBN_ENTER ShowTreeRec(\"%s\")", path); // 2015-08-04 SHL FIXME debug
    65356561              ShowTreeRec(WinWindowFromID(WinWindowFromID(hwndTree,
    65366562                                                          FID_CLIENT),
     
    66636689    }
    66646690    DosSleep(1);
    6665     DbgMsg(pszSrcFile, __LINE__, "MainWndProc WM_CLOSE returning");
     6691    DbgMsg(pszSrcFile, __LINE__, "MainWndProc WM_CLOSE returning with fAmClosing %u", fAmClosing); // 2015-08-16 SHL
    66666692
    66676693    return 0;           // Suppress WinDefWindowProc WM_QUIT message generation
     
    66936719
    66946720  case WM_DESTROY:
     6721    DbgMsg(pszSrcFile, __LINE__, "MainWndProc WM_DESTROY hwnd %p TID %u", hwnd, GetTidForThread());     // 2015-08-09 SHL FIXME debug
    66956722    hwndMain = (HWND)0;
    66966723    if (!PostMsg((HWND)0, WM_QUIT, MPVOID, MPVOID))
    66976724      WinSendMsg((HWND)0, WM_QUIT, MPVOID, MPVOID);
    66986725#   ifdef FORTIFY
     6726    DbgMsg(pszSrcFile, __LINE__, "MainWndProc WM_DESTROY hwnd %p TID %u", hwnd, GetTidForThread());     // 2015-08-09 SHL FIXME debug
    66996727    free_commands();
    67006728    free_associations();
  • trunk/dll/mainwnd.h

    r1550 r1856  
    44  $Id$
    55
    6   <<description here>>
     6  fm/2 main window
    77
    88  Copyright (c) 1993-98 M. Kimes
    9   Copyright (c) 2001, 2009 Steven H. Levine
     9  Copyright (c) 2001, 2015 Steven H. Levine
    1010
    1111  05 Sep 08 JBS Ticket 187: Refactor FM3DLL.H
     
    1414  21 Jun 09 GKY Added drive letter to bitmap buttons in drive bar; Eliminate static drive
    1515                letter windows; Use button ID to identify drive letter for processing.
     16  13 Aug 15 SHL Sync with Flesh/Stubby updates
    1617
    1718***********************************************************************/
     
    9192extern PSZ pszFocusDir;
    9293
     94extern UINT cDirectoriesRestored;               // 2015-08-12 SHL Incremented by RestoreDirCnrState
     95
    9396#define STATE_NAME_MAX_BYTES 256
    9497
  • trunk/dll/mainwnd2.c

    r1782 r1856  
    12651265      break;
    12661266    case IDM_CONFIGMENU:
    1267       // 2014-05-17 SHL FIXME to use SetToggleChecks maybe
     1267      // 2014-05-17 SHL FIXME to use SetToggleChecks maybe
    12681268      WinCheckMenuItem((HWND) mp2, IDM_TOOLSUBMENU, fToolbar);
    12691269      WinCheckMenuItem((HWND) mp2, IDM_AUTOVIEW, fAutoView);
     
    12721272      break;
    12731273    case IDM_TOOLSUBMENU:
    1274       // 2014-05-17 SHL FIXME to use SetToggleChecks maybe
     1274      // 2014-05-17 SHL FIXME to use SetToggleChecks maybe
    12751275      WinCheckMenuItem((HWND) mp2, IDM_TOOLBAR, fToolbar);
    12761276      WinCheckMenuItem((HWND) mp2, IDM_TEXTTOOLS, fTextTools);
     
    12781278      break;
    12791279    case IDM_WINDOWSMENU:
    1280       // 2014-05-17 SHL FIXME to use SetToggleChecks maybe
     1280      // 2014-05-17 SHL FIXME to use SetToggleChecks maybe
    12811281      WinCheckMenuItem((HWND) mp2, IDM_VTREE, (hwndTree != (HWND) 0));
    12821282      WinCheckMenuItem((HWND) mp2, IDM_TILEBACKWARDS, fTileBackwards);
     
    14041404    CloseChildren(hwnd);
    14051405    PostMsg(hwnd, UM_CLOSE, MPVOID, MPVOID);
     1406    DbgMsg(pszSrcFile, __LINE__, "MainWndProc2 WM_CLOSE returning with fAmClosing %u", fAmClosing); // 2015-08-16 SHL
    14061407    DosSleep(1);
    14071408    return 0;                   // Suppress WinDefWindowProc WM_QUIT message generation
  • trunk/dll/makefile

    r1852 r1856  
    33
    44# Copyright (c) 1993-98 M. Kimes
    5 # Copyright (c) 2002, 2014 Steven H. Levine
     5# Copyright (c) 2002, 2015 Steven H. Levine
    66
    77# 22 May 03 SHL Correct icon dependencies
     
    4747# 21 Feb 14 JBS Ticket #500: Set only non-resource objects in FM3RES.DLL to high memory
    4848# 24 Feb 14 JBS Ticket #500: Suspended use of high memory by commenting out the calls to exehdr
     49# 13 Aug 15 SHL Add listutil
    4950
    5051# Environment: see makefile_pre.mk and makefile_post.mk
     
    196197       fonts.obj fortify.obj &
    197198       getnames.obj grep.obj grep2.obj i18nutil.obj info.obj inis.obj &
    198        init.obj input.obj instant.obj key.obj killproc.obj literal.obj &
     199       init.obj input.obj instant.obj key.obj killproc.obj &
     200       listutil.obj literal.obj &
    199201       loadbmp.obj mainwnd.obj mainwnd2.obj makelist.obj menu.obj misc.obj &
    200202       mkdir.obj mle.obj newview.obj notebook.obj notify.obj objcnr.obj &
  • trunk/dll/treecnr.c

    r1828 r1856  
    77
    88  Copyright (c) 1993-98 M. Kimes
    9   Copyright (c) 2001-2012 Steven H. Levine
     9  Copyright (c) 2001, 2015 Steven H. Levine
    1010
    1111  16 Oct 02 SHL Handle large partitions
     
    7878  15 Sep 09 SHL Use UM_GREP when passing pathname
    7979  15 Nov 09 GKY Add semaphore to fix double names in tree container caused by UM_SHOWME
    80                 before scan completes
     80                before scan completes
    8181  22 Nov 09 GKY Add LVM.EXE to partition submenu
    8282  17 JAN 10 GKY Changes to get working with Watcom 1.9 Beta (1/16/10). Mostly cast
    83                 CHAR CONSTANT * as CHAR *.
     83                CHAR CONSTANT * as CHAR *.
    8484  11 Apr 10 GKY Fix drive tree rescan failure and program hang caused by event sem
    85                 never being posted
     85                never being posted
    8686  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
     87                entries in the tree container, fix related semaphore performance using
     88                combination of event and mutex semaphores
    8989  04 Aug 12 GKY Fix trap reported by Ben
    9090  30 Dec 12 GKY Changed refresh removable media to query LVM directly to call Rediscover_PRMs (Ticket 472);
    91                 Also added a tree rescan following volume detach.
     91                Also added a tree rescan following volume detach.
    9292  22 Feb 14 GKY Fix warn readonly yes don't ask to work when recursing directories.
    9393  07 Sep 14 GKY Fix tree container mis-draws (stacked icons with RWS) The problem was magnified
    94                 by RWS but I think the occasional extra blank directory or duplicating
    95                 directories is related.
     94                by RWS but I think the occasional extra blank directory or duplicating
     95                directories is related.
    9696  16 Mar 15 GKY Add semaphore hmtxFiltering to prevent freeing dcd while filtering. Prevents
    97                 a trap when FM2 is shutdown or the container is closed while tree
    98                 container is still populating
     97                a trap when FM2 is shutdown or the container is closed while tree
     98                container is still populating
    9999  02 May 15 GKY Changes to allow a JAVA executable object to be created using "Real object"
    100                 menu item on a jar file.
     100                menu item on a jar file.
    101101  12 Jul 15 GKY Fixed trap caused by pci->pszFileName being NullStr
     102  07 Aug 15 SHL Rework to use AddFleshWorkRequest rather than direct calls to Stubby/Flesh/Unflesh
    102103
    103104***********************************************************************/
     
    141142#include "select.h"                     // ExpandAll
    142143#include "findrec.h"                    // FindCnrRecord, FindParentRecord, ShowCnrRecord
    143 #include "flesh.h"                      // Flesh, UnFlesh
     144#include "flesh.h"                      // AddFleshWorkRequest
    144145#include "notify.h"                     // HideNote
    145146#include "objwin.h"                     // MakeObjWin
     
    165166#include "dirs.h"                       // save_dir2
    166167#include "fortify.h"
    167 #include "init.h"                       // GetTidForWindow
     168#include "init.h"                       // NullStr etc.
    168169#include "excputil.h"                   // xbeginthread
    169170#include "copyf.h"                      // ignorereadonly
     
    273274}
    274275
     276/**
     277 * Find a record in tree view, move it so it shows in container and
     278 * make it the current record
     279 * @param hwndCnr is container which must be in tree view
     280 * @param pszDir_ is full path name to find
     281 */
     282
    275283VOID ShowTreeRec(HWND hwndCnr,
    276                  CHAR *dirname,
     284                 CHAR *pszDir_,
    277285                 BOOL collapsefirst,
    278286                 BOOL maketop)
    279287{
    280     /**
    281      * Find a record in tree view, move it so it shows in container and
    282      * make it the current record
    283      */
    284 
    285   PCNRITEM pci, pciToSelect, pciP;
     288  PCNRITEM pci;
     289  PCNRITEM pciToSelect;
     290  PCNRITEM pciP;
     291  UINT retries;
    286292  BOOL quickbail = FALSE;
    287   CHAR szDir[CCHMAXPATH], *p;
     293  PSZ p;
     294  UINT cDirLen;
     295  BOOL found;
     296  CHAR szDir[CCHMAXPATH];
     297
     298  DbgMsg(pszSrcFile, __LINE__, "ShowTreeRec pszDir_ %s", pszDir_); // 2015-08-04 SHL FIXME debug
    288299
    289300  // already positioned to requested record?
     
    291302                   CM_QUERYRECORDEMPHASIS,
    292303                   MPFROMLONG(CMA_FIRST), MPFROMSHORT(CRA_CURSORED));
    293   if (pci && (INT) pci != -1 && !stricmp(pci->pszFileName, dirname)) {
    294     quickbail = TRUE;                   // Bypass repositioning
     304  if (pci && (INT)pci != -1 && !stricmp(pci->pszFileName, pszDir_)) {
     305    found = TRUE;
     306    quickbail = TRUE;                   // Already at requested record - bypass repositioning
    295307    goto MakeTop;
    296308  }
     309
    297310  WinEnableWindowUpdate(hwndCnr, FALSE);
    298   pci = FindCnrRecord(hwndCnr, dirname, NULL, TRUE, FALSE, TRUE);
    299   if (!pci || (INT) pci == -1) {
    300     *szDir = *dirname;
     311
     312  // 2015-08-13 SHL add retry logic
     313  for (found = FALSE, retries = 0; !found && retries < 10; retries++) {
     314
     315    pci = FindCnrRecord(hwndCnr,
     316                        pszDir_,
     317                        NULL,           // pciParent
     318                        TRUE,           // partial
     319                        FALSE,          // partmatch
     320                        TRUE);          // noenv
     321
     322    if (pci && (INT)pci != -1) {
     323      found = TRUE;
     324      break;                    // Found it
     325    }
     326
     327    // Try again expanding as needed
     328
     329    DbgMsg(pszSrcFile, __LINE__, "ShowTreeRec need expand"); // 2015-08-04 SHL FIXME debug
     330
     331    cDirLen = strlen(pszDir_);
     332
     333    *szDir = *pszDir_;                  // Drive letter
    301334    szDir[1] = ':';
    302335    szDir[2] = '\\';
    303336    szDir[3] = 0;
    304337    p = szDir + 3;                      // Point after root backslash
     338
    305339    for (;;) {
    306       pciP = FindCnrRecord(hwndCnr, szDir, NULL, TRUE, FALSE, TRUE);
    307       if (pciP && (INT) pciP != -1) {
    308         if (!stricmp(dirname, pciP->pszFileName))
    309           break;                        // Found it
    310         if (~pciP->rc.flRecordAttr & CRA_EXPANDED)
    311           WinSendMsg(hwndCnr, CM_EXPANDTREE, MPFROMP(pciP), MPVOID);
    312         strcpy(szDir, dirname);
    313         if (p - szDir >= strlen(szDir))
    314           break;                        // Not root dir
    315         p = strchr(p, '\\');
    316         if (p) {
    317           *p = 0;                       // fixme?
    318           p++;
    319         }
    320         else
    321           break;
    322       }
    323       else
    324         break;
    325       DosSleep(0);
    326     } // for
    327     pci = FindCnrRecord(hwndCnr, dirname, NULL, TRUE, FALSE, TRUE);
    328   }
    329   if (pci && (INT) pci != -1) {
     340      // Try to match path prefix
     341      pciP = FindCnrRecord(hwndCnr,
     342                           szDir,
     343                           NULL,                // pciParent
     344                           TRUE,                // partial
     345                           FALSE,               // partmatch
     346                           TRUE);               // noenv
     347      if (!pciP || (INT)pciP == -1) {
     348        DbgMsg(pszSrcFile, __LINE__, "ShowTreeRec FindCnrRecord(%s) returned %p", szDir, pciP); // 2015-08-04 SHL FIXME debug
     349        WaitFleshWorkListEmpty();               // 2015-08-13 SHL
     350        DosSleep(1000);
     351        break;                                  // No match
     352      }
     353
     354      DbgMsg(pszSrcFile, __LINE__, "ShowTreeRec FindCnrRecord returned %p %s", pciP, pciP->pszFileName); // 2015-08-04 SHL FIXME debug
     355
     356      if (!stricmp(pszDir_, pciP->pszFileName)) {
     357        pci = pciP;
     358        found = TRUE;
     359        break;                  // Got full match
     360      }
     361
     362      if (~pciP->rc.flRecordAttr & CRA_EXPANDED) {
     363        DbgMsg(pszSrcFile, __LINE__, "ShowTreeRec expanding %s", pciP->pszFileName); // 2015-08-04 SHL FIXME debug
     364        WinSendMsg(hwndCnr, CM_EXPANDTREE, MPFROMP(pciP), MPVOID);
     365        DosSleep(100);                          // 2015-08-13 SHL Let PM catch up
     366        // WaitFleshWorkListEmpty();            // 2015-08-13 SHL
     367      }
     368
     369      WaitFleshWorkListEmpty();         // 2015-08-13 SHL
     370
     371      // Add next component to path
     372      if (p - szDir >= cDirLen)
     373        break;                          // Done
     374      strcpy(szDir, pszDir_);           // Reset
     375      p = strchr(p, '\\');              // Find next backslash
     376      if (!p)
     377        break;                          // Give up
     378
     379      *p++ = 0;                         // Truncate at backslash
     380
     381    } // while expanding
     382
     383  } // for
     384
     385  DbgMsg(pszSrcFile, __LINE__, "ShowTreeRec retries %u pci %p pci->pszFileName %s",retries, pci, pci && (INT)pci != -1 ? pci->pszFileName : "(null)"); // 2015-08-04 SHL FIXME debug
     386
     387  if (found) {
     388    // Found it
    330389    if (~pci->rc.flRecordAttr & CRA_CURSORED) {
    331390      if (collapsefirst) {
     
    334393                          MPVOID, MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER));
    335394        while (pciP && (INT) pciP != -1) {
    336 #if 1 // 05 Jan 08 SHL fixme to be sure this is correct code
    337395          if (pciP->rc.flRecordAttr & CRA_EXPANDED) {
    338396            // collapse top level of all branches
    339397            WinSendMsg(hwndCnr, CM_COLLAPSETREE, MPFROMP(pciP), MPVOID);
    340398          }
    341 #else // fixme to be gone
    342           if (toupper(*pciP->pszFileName) == toupper(*dirname)) {
    343             // collapse all levels if branch is our drive
    344             if (pciP->rc.flRecordAttr & CRA_EXPANDED)
    345               ExpandAll(hwndCnr, FALSE, pciP);
    346           }
    347           else if (pciP->rc.flRecordAttr & CRA_EXPANDED) {
    348             // collapse top level of all branches
    349             WinSendMsg(hwndCnr, CM_COLLAPSETREE, MPFROMP(pciP), MPVOID);
    350           }
    351 #endif
    352399          pciP = WinSendMsg(hwndCnr,
    353400                            CM_QUERYRECORD,
     
    355402                            MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER));
    356403        } // while
    357       }
    358       // expand all parent branches
     404      } // if collapse
     405
     406      // Expand parent branches
     407      // 2015-08-06 SHL FIXME to bypass if we did not collapse since search already expanded - maybe?
    359408      pciToSelect = pci;
    360409      for (;;) {
     
    363412                          MPFROMP(pciToSelect),
    364413                          MPFROM2SHORT(CMA_PARENT, CMA_ITEMORDER));
    365         if (pciP && (INT) pciP != -1) {
    366           if (!(pciP->rc.flRecordAttr & CRA_EXPANDED))
    367             WinSendMsg(hwndCnr, CM_EXPANDTREE, MPFROMP(pciP), MPVOID);
    368           pciToSelect = pciP;
    369         }
    370         else
    371           break;
     414        if (!pciP || (INT)pciP == -1)
     415          break;                        // Done
     416        // Got parent
     417        if (~pciP->rc.flRecordAttr & CRA_EXPANDED)
     418          WinSendMsg(hwndCnr, CM_EXPANDTREE, MPFROMP(pciP), MPVOID);
     419        pciToSelect = pciP;
    372420        DosSleep(0);                    // Let GUI update
    373421      } // for
    374     }
     422    } // if not cursored
     423
     424  MakeTop:
    375425    // make record visible
    376   MakeTop:
    377426    pciToSelect = pci;
    378427    if (pciToSelect && (INT) pciToSelect != -1) {
    379       //DbgMsg(pszSrcFile, __LINE__, "TOP %i %i", fTopDir, maketop);
     428      DbgMsg(pszSrcFile, __LINE__, "ShowTreeRec %p fTopDir %i maketop %i", pciToSelect, fTopDir, maketop); // 2015-08-04 SHL FIXME debug
    380429      if (fSwitchTreeExpand && ~pciToSelect->rc.flRecordAttr & CRA_EXPANDED)
    381         WinSendMsg(hwndCnr, CM_EXPANDTREE, MPFROMP(pciToSelect), MPVOID);
    382       if (fTopDir || maketop) {
    383         ShowCnrRecord(hwndCnr, (PMINIRECORDCORE) pciToSelect);
    384       }
     430        WinSendMsg(hwndCnr, CM_EXPANDTREE, MPFROMP(pciToSelect), MPVOID);
     431      if (fTopDir || maketop)
     432        ShowCnrRecord(hwndCnr, (PMINIRECORDCORE)pciToSelect);
     433
    385434      if (!quickbail) {
     435        WaitFleshWorkListEmpty();       // 2015-08-07 SHL FIXME try to ensure contents stable
     436        DbgMsg(pszSrcFile, __LINE__, "WinSendMsg(CM_SETRECORDEMPHASIS, CRA_SELECTED | CRA_CURSORED) \"%s\"", pszDir_); // 2015-08-04 SHL FIXME debug
    386437        WinSendMsg(hwndCnr,
    387438                   CM_SETRECORDEMPHASIS,
     
    391442    }
    392443  }
     444
    393445  WinEnableWindowUpdate(hwndCnr, TRUE);
    394446}
     
    649701}
    650702
     703ULONG ulScanPostCnt;
     704
    651705MRESULT EXPENTRY TreeObjWndProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
    652706{
    653707  DIRCNRDATA *dcd;
     708
     709#if 0 // 2015-08-04 SHL FIXME to be gone
     710  APIRET rc;
     711#endif // 2015-08-04 SHL FIXME to be gone
    654712
    655713  switch (msg) {
     
    661719      dcd = INSTDATA(hwnd);
    662720      if (dcd) {
    663         BOOL tempsusp, tempfollow, temptop;
    664 
    665         DosWaitEventSem(hevTreeCnrScanComplete, SEM_INDEFINITE_WAIT);
    666         tempsusp = dcd->suspendview;
    667         dcd->suspendview = TRUE;
    668         tempfollow = fFollowTree;
    669         fFollowTree = FALSE;
    670         if (mp2) {
    671           temptop = fTopDir;
    672           fTopDir = TRUE;
    673         }
    674         ShowTreeRec(dcd->hwndCnr, (CHAR *)mp1, fCollapseFirst, TRUE);
    675         PostMsg(hwndTree, WM_COMMAND, MPFROM2SHORT(IDM_UPDATE, 0), MPVOID);
    676         dcd->suspendview = (USHORT) tempsusp;
    677         fFollowTree = tempfollow;
    678         if (mp2)
    679           fTopDir = temptop;
     721
     722#if 0 // 2015-08-04 SHL FIXME to be gone
     723        rc = DosWaitEventSem(hevTreeCnrScanComplete, SEM_INDEFINITE_WAIT);
     724        if (rc)
     725          Dos_Error(MB_ENTER, rc, HWND_DESKTOP, pszSrcFile, __LINE__, "DosPostEventSem");
     726#endif // 2015-08-04 SHL FIXME to be gone
     727
     728        /* Hold off if switching on focus change and
     729           RestoreDirCnrState has restored one or directory directory containers
     730           See RestoreDirCnrState()
     731        */
     732        DbgMsg(pszSrcFile, __LINE__, "TreeObjWndProc UM_SHOWME cDirectoriesRestored %u", cDirectoriesRestored, fInitialDriveScan); // 2015-08-04 SHL FIXME debug
     733        DbgMsg(pszSrcFile, __LINE__, "TreeObjWndProc UM_SHOWME %s)", mp1); // 2015-08-04 SHL FIXME debug
     734
     735        if (cDirectoriesRestored > 0)
     736          cDirectoriesRestored--;
     737
     738        if (!cDirectoriesRestored) {
     739          BOOL tempsusp = dcd->suspendview;
     740          BOOL tempfollow = fFollowTree;
     741          BOOL temptop;
     742          dcd->suspendview = TRUE;
     743          fFollowTree = FALSE;
     744          if (mp2) {
     745            temptop = fTopDir;
     746            fTopDir = TRUE;
     747          }
     748
     749          DbgMsg(pszSrcFile, __LINE__, "TreeObjWndProc UM_SHOWME calling ShowTreeRec(\"%s\")", mp1); // 2015-08-04 SHL FIXME debug
     750          ShowTreeRec(dcd->hwndCnr, (CHAR *)mp1, fCollapseFirst, TRUE);
     751          DbgMsg(pszSrcFile, __LINE__, "TreeObjWndProc UM_SHOWME calling PostMsg(IDM_UPDATE)"); // 2015-08-04 SHL FIXME debug
     752          PostMsg(hwndTree, WM_COMMAND, MPFROM2SHORT(IDM_UPDATE, 0), MPVOID);
     753
     754          dcd->suspendview = (USHORT)tempsusp;  // Restore
     755          fFollowTree = tempfollow;             // Restore
     756          if (mp2)
     757            fTopDir = temptop;                  // Restore
     758        }
    680759      }
    681760      free((CHAR *)mp1);
     
    717796      dcd->suspendview = TRUE;
    718797      ExpandAll(dcd->hwndCnr,
    719                 (SHORT1FROMMP(mp1) == IDM_EXPAND), (PCNRITEM) mp2);
     798                (SHORT1FROMMP(mp1) == IDM_EXPAND), (PCNRITEM) mp2);
    720799      DosSleep(1); // Fixes tree epansion (dir text and icons all placed on
    721                        // the same line as the drive) failure on startup using RWS
     800                       // the same line as the drive) failure on startup using RWS
    722801      dcd->suspendview = (USHORT) tempsusp;
    723802      PostMsg(dcd->hwndCnr, UM_FILTER, MPVOID, MPVOID);
     
    789868      if (cnri.cRecords) {
    790869        sprintf(s, GetPString(IDS_NUMDRIVESTEXT), cnri.cRecords);
    791         if (pci && (INT) pci != -1 && pci->pszFileName != NullStr) { //fixme? will try checking pci->pszFileName instead of the pointer
     870        if (pci && (INT) pci != -1 && pci->pszFileName != NullStr) { //fixme? will try checking pci->pszFileName instead of the pointer
    792871          if (!(driveflags[toupper(*pci->pszFileName) - 'A'] &
    793872                DRIVE_REMOVABLE) ||
     
    809888              }
    810889              else
    811                 *szFree = 0;
    812               //Show information on status line not shown in the tree container
     890                *szFree = 0;
     891              //Show information on status line not shown in the tree container
    813892              driveserial[toupper(*pci->pszFileName) - 'A'] = volser.serial;
    814               if (CheckDrive(toupper(*pci->pszFileName), FileSystem, &type) == -1 ||
    815                   fShowFSTypeInTree)
     893              if (CheckDrive(toupper(*pci->pszFileName), FileSystem, &type) == -1 ||
     894                  fShowFSTypeInTree)
    816895                strcpy(FileSystem, NullStr);
    817896              if (fShowDriveLabelInTree)
     
    826905                sprintf(s,
    827906                        GetPString(fShowFSTypeInTree ? IDS_TREESTATUSSTART1TEXT :
    828                                    fShowDriveLabelInTree ? IDS_TREESTATUSSTART2TEXT :
    829                                    IDS_TREESTATUSSTARTTEXT), toupper(*pci->pszFileName),
    830                         FileSystem, szTmpLabel, volser.serial, szFree);
     907                                   fShowDriveLabelInTree ? IDS_TREESTATUSSTART2TEXT :
     908                                   IDS_TREESTATUSSTARTTEXT), toupper(*pci->pszFileName),
     909                        FileSystem, szTmpLabel, volser.serial, szFree);
    831910                strcat(s, temp);
    832911              }
     
    835914                sprintf(&s[strlen(s)],
    836915                        GetPString(fShowFSTypeInTree ? IDS_TREESTATUSSTART1TEXT :
    837                                    fShowDriveLabelInTree ? IDS_TREESTATUSSTART2TEXT :
    838                                    IDS_TREESTATUSSTARTTEXT), toupper(*pci->pszFileName),
    839                         FileSystem, szTmpLabel, volser.serial, szFree);
     916                                   fShowDriveLabelInTree ? IDS_TREESTATUSSTART2TEXT :
     917                                   IDS_TREESTATUSSTARTTEXT), toupper(*pci->pszFileName),
     918                        FileSystem, szTmpLabel, volser.serial, szFree);
    840919                strcat(s, "]");
    841920              }
     
    861940            pci = FindParentRecord(dcd->hwndCnr, pci);
    862941            driveserial[toupper(*pci->pszFileName) - 'A'] = -1;
    863             UnFlesh(dcd->hwndCnr, pci);
    864           }
    865         }
    866       }
    867       // 21 Sep 09 SHL fixme to know why checking again - focus change?
     942            WaitFleshWorkListEmpty();   // 2015-08-13 SHL in case pci still in work list
     943            AddFleshWorkRequest(dcd->hwndCnr, pci, eUnFlesh);
     944          }
     945        }
     946      }
     947      // 21 Sep 09 SHL FIXME to know why checking again - focus change?
    868948      if (dcd->hwndFrame == WinQueryActiveWindow(dcd->hwndParent))
    869949        WinSetWindowText(hwndStatus, s);
     
    873953  case UM_RESCAN:
    874954    // populate container
    875     DosWaitEventSem(hevTreeCnrScanComplete, SEM_INDEFINITE_WAIT);
    876     DosResetEventSem(hevTreeCnrScanComplete, &ulScanPostCnt);
     955#if 0 // 2015-08-04 SHL FIXME to be gone
     956    rc = DosWaitEventSem(hevTreeCnrScanComplete, SEM_INDEFINITE_WAIT);
     957    if (rc)
     958      Dos_Error(MB_ENTER, rc, HWND_DESKTOP, pszSrcFile, __LINE__, "DosWaitEventSem");
     959    rc = DosResetEventSem(hevTreeCnrScanComplete, &ulScanPostCnt);
     960    if (rc)
     961      Dos_Error(MB_ENTER, rc, HWND_DESKTOP, pszSrcFile, __LINE__, "DosResetEventSem");
     962#endif // 2015-08-04 SHL FIXME to be gone
     963
    877964    dcd = WinQueryWindowPtr(hwnd, QWL_USER);
    878965    if (!dcd)
     
    885972                 CM_SCROLLWINDOW,
    886973                 MPFROMSHORT(CMA_HORIZONTAL), MPFROMLONG(-1));
     974      DbgMsg(pszSrcFile, __LINE__, "TreeObjWndProc FillTreeCnr()"); // 2015-08-04 SHL FIXME debug
    887975      FillTreeCnr(dcd->hwndCnr, dcd->hwndParent);
    888976      if (fOkayMinimize) {
     
    892980      WinSendMsg(dcd->hwndCnr,
    893981                 CM_INVALIDATERECORD,
    894                  MPVOID, MPFROM2SHORT(0, CMA_ERASE | CMA_REPOSITION));
     982                 MPVOID, MPFROM2SHORT(0, CMA_ERASE | CMA_REPOSITION));
     983      DbgMsg(pszSrcFile, __LINE__, "TreeObjWndProc PostMsg(UM_RESCAN)"); // 2015-08-04 SHL FIXME debug
    895984      PostMsg(dcd->hwndCnr, UM_RESCAN, MPVOID, MPVOID);
    896985    }
     
    9171006      case IDM_DELETE:
    9181007      case IDM_PERMDELETE:
    919         if (li->type == IDM_DELETE)
    920           ignorereadonly = FALSE;
     1008        if (li->type == IDM_DELETE)
     1009          ignorereadonly = FALSE;
    9211010        if (PostMsg(hwnd, UM_MASSACTION, mp1, mp2))
    9221011          return (MRESULT) TRUE;
     
    10371126  DIRCNRDATA *dcd = INSTDATA(hwnd);
    10381127  PCNRITEM pci;
     1128  APIRET rc;
    10391129
    10401130  switch (msg) {
     
    11241214        WinSetWindowText(hwndStatus2, NullStr);
    11251215    }
    1126     // 13 Jul 09 SHL fixme to make sense
     1216    // 13 Jul 09 SHL FIXME to make sense
    11271217    if (msg == UM_TIMER)
    11281218      return 0;
     
    11381228      FSALLOCATE fsa;
    11391229
    1140       pci = (PCNRITEM) CurrentRecord(hwnd);
    1141       if (pci && (INT) pci != -1) {
     1230      pci = (PCNRITEM)CurrentRecord(hwnd);
     1231      if (pci && (INT)pci != -1) {
    11421232        if (IsRoot(pci->pszFileName) || !DosQueryFSInfo(toupper(*pci->pszFileName) - '@',
    11431233                                                       FSIL_ALLOC, &fsa,
     
    12351325        else
    12361326          WinSetWindowText(WinWindowFromID(dcd->hwndFrame,
    1237                                            MAIN_STATUS), pci->pszFileName);
     1327                                           MAIN_STATUS), pci->pszFileName);
    12381328        if (fMoreButtons && hwndName) {
    12391329          CHAR szDate[DATE_BUF_BYTES];
     
    12481338        }
    12491339      }
     1340      DbgMsg(pszSrcFile, __LINE__, "TreeCnrWndProc UM_RESCAN PostMsg(UM_RESCAN2, %s)", pci->pszFileName); // 2015-08-04 SHL FIXME debug
    12501341      PostMsg(dcd->hwndObject, UM_RESCAN2, MPFROMP(pci), MPVOID);
    12511342      if (hwndStatus2)
     
    15151606            }
    15161607          }
    1517           pDItem = DrgQueryDragitemPtr(pDInfo,          // Access DRAGITEM
    1518                                        0);              // Index to DRAGITEM
    1519           if (DrgVerifyRMF(pDItem,                      // Check valid rendering
     1608          pDItem = DrgQueryDragitemPtr(pDInfo,          // Access DRAGITEM
     1609                                       0);              // Index to DRAGITEM
     1610          if (DrgVerifyRMF(pDItem,                      // Check valid rendering
    15201611                           (CHAR *) DRM_OS2FILE,        // mechanisms and data
    1521                            NULL) || DrgVerifyRMF(pDItem,
    1522                                                 (CHAR *) DRM_FM2ARCMEMBER,
    1523                                                 (CHAR *) DRF_FM2ARCHIVE)) {    // formats
    1524             DrgFreeDraginfo(pDInfo);                    // Free DRAGINFO
     1612                           NULL) || DrgVerifyRMF(pDItem,
     1613                                                (CHAR *) DRM_FM2ARCMEMBER,
     1614                                                (CHAR *) DRF_FM2ARCHIVE)) {    // formats
     1615            DrgFreeDraginfo(pDInfo);                    // Free DRAGINFO
    15251616            if (!pci || (INT) pci == -1)
    15261617              return MRFROM2SHORT(DOR_DROP, DO_MOVE);
     
    15301621            if (toupper(*pci->pszFileName) < 'C')
    15311622              return MRFROM2SHORT(DOR_DROP, DO_COPY);
    1532             return MRFROM2SHORT(DOR_DROP,               // Return okay to drop
     1623            return MRFROM2SHORT(DOR_DROP,               // Return okay to drop
    15331624                                ((fCopyDefault) ? DO_COPY : DO_MOVE));
    15341625          }
    1535           DrgFreeDraginfo(pDInfo);                      // Free DRAGINFO
    1536         }
    1537         return MRFROM2SHORT(DOR_NODROP, 0);             // Drop not valid
     1626          DrgFreeDraginfo(pDInfo);                      // Free DRAGINFO
     1627        }
     1628        return MRFROM2SHORT(DOR_NODROP, 0);             // Drop not valid
    15381629
    15391630      case CN_INITDRAG:
     
    17541845      case CN_CONTEXTMENU:
    17551846        {
    1756           PCNRITEM pci = (PCNRITEM) mp2;
     1847          PCNRITEM pci = (PCNRITEM)mp2;
    17571848          BOOL wasFollowing;
    17581849
    1759           //DosEnterCritSec(); //GKY 11-28-08
    17601850          wasFollowing = fFollowTree;
    17611851          fFollowTree = FALSE;
    1762           //DosExitCritSec();
    1763           if (pci && (INT) pci != -1 && !(pci->flags & RECFLAGS_ENV)) {
    1764             WinSendMsg(hwnd,
    1765                        CM_SETRECORDEMPHASIS,
    1766                        MPFROMP(pci), MPFROM2SHORT(TRUE, CRA_CURSORED));
    1767             MarkAll(hwnd, FALSE, FALSE, TRUE);
    1768             if (!(pci->attrFile & FILE_DIRECTORY))
    1769               dcd->hwndLastMenu = CheckMenu(hwndMainMenu, &FileMenu, FILE_POPUP);
    1770             else if (!IsRoot(pci->pszFileName))
    1771               dcd->hwndLastMenu = CheckMenu(hwndMainMenu, &DirMenu, DIR_POPUP);
    1772             else
    1773               dcd->hwndLastMenu = CheckMenu(hwndMainMenu, &TreeMenu, TREE_POPUP);
     1852          if (pci && (INT)pci != -1 && !(pci->flags & RECFLAGS_ENV)) {
     1853            // 2015-08-09 SHL try to ensure contents stable
     1854            if (!IsFleshWorkListEmpty())
     1855              WinPostMsg(hwnd, msg, mp1, mp2);          // Try again later
     1856            else {
     1857              WinSendMsg(hwnd,
     1858                         CM_SETRECORDEMPHASIS,
     1859                         MPFROMP(pci), MPFROM2SHORT(TRUE, CRA_CURSORED));
     1860              MarkAll(hwnd, FALSE, FALSE, TRUE);
     1861              if (!(pci->attrFile & FILE_DIRECTORY))
     1862                dcd->hwndLastMenu = CheckMenu(hwndMainMenu, &FileMenu, FILE_POPUP);
     1863              else if (!IsRoot(pci->pszFileName))
     1864                dcd->hwndLastMenu = CheckMenu(hwndMainMenu, &DirMenu, DIR_POPUP);
     1865              else
     1866                dcd->hwndLastMenu = CheckMenu(hwndMainMenu, &TreeMenu, TREE_POPUP);
     1867            }
    17741868          }
    17751869          else {
     
    17981892            }
    17991893          }
    1800           //DosEnterCritSec(); //GKY 11-28-08
    18011894          fFollowTree = wasFollowing;
    1802           //DosExitCritSec();
    18031895        }
    18041896        break;
     
    18371929                    driveserial[toupper(*pci->pszFileName) - 'A'] !=
    18381930                    volser.serial)
    1839                   UnFlesh(hwnd, pci);
     1931                {
     1932                  WaitFleshWorkListEmpty();     // 2015-08-13 SHL in case pci still in work list
     1933                  AddFleshWorkRequest(hwnd, pci, eUnFlesh);
     1934                }
    18401935                if (SHORT2FROMMP(mp1) != CN_COLLAPSETREE ||
    18411936                    (!volser.serial ||
    18421937                     driveserial[toupper(*pci->pszFileName) - 'A'] !=
    18431938                     volser.serial)) {
    1844                   if (SHORT2FROMMP(mp1) == CN_EXPANDTREE && Flesh(hwnd, pci)
    1845                       &&!dcd->suspendview  && fTopDir) {
     1939                  if (SHORT2FROMMP(mp1) == CN_EXPANDTREE && AddFleshWorkRequest(hwnd, pci, eFlesh)
     1940                      &&!dcd->suspendview  && fTopDir) {
    18461941                    PostMsg(hwnd, UM_TOPDIR, MPFROMP(pci), MPVOID);
    18471942                    //DbgMsg(pszSrcFile, __LINE__, "UM_TOPDIR %p pci %p", hwnd, pci);
     
    18521947              else {
    18531948                driveserial[toupper(*pci->pszFileName) - 'A'] = -1;
    1854                 UnFlesh(hwnd, pci);
     1949                WaitFleshWorkListEmpty();       // 2015-08-13 SHL in case pci still in work list
     1950                AddFleshWorkRequest(hwnd, pci, eUnFlesh);
    18551951                PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
    18561952                if (!fAlertBeepOff)
     
    18591955            }
    18601956            else if (SHORT2FROMMP(mp1) == CN_EXPANDTREE) {
    1861               if (Flesh(hwnd, pci) && !dcd->suspendview && fTopDir){
     1957              // 2015-08-04 SHL
     1958#if 1
     1959              AddFleshWorkRequest(hwnd, pci, eFlesh);   // forceFlesh
     1960              if (!dcd->suspendview && fTopDir) {
     1961                DbgMsg(pszSrcFile, __LINE__, "TreeCnrWndProc UM_TOPDIR %p pci %p", hwnd, pci);  // 2015-08-04 SHL FIXME debug
    18621962                PostMsg(hwnd, UM_TOPDIR, MPFROMP(pci), MPVOID);
    1863                 //DbgMsg(pszSrcFile, __LINE__, "UM_TOPDIR %p pci %p", hwnd, pci);
    18641963              }
     1964#else
     1965              if (Flesh(hwnd, pci) && !dcd->suspendview && fTopDir) {
     1966                DbgMsg(pszSrcFile, __LINE__, "TreeCnrWndProc UM_TOPDIR %p pci %p", hwnd, pci);  // 2015-08-04 SHL FIXME debug
     1967                PostMsg(hwnd, UM_TOPDIR, MPFROMP(pci), MPVOID);
     1968              }
     1969#endif
    18651970            }
    18661971            if (SHORT2FROMMP(mp1) == CN_EXPANDTREE && !dcd->suspendview){
     1972              DbgMsg(pszSrcFile, __LINE__, "UM_FILTER %p pci %p", hwnd, pci);
    18671973              WinSendMsg(hwnd, UM_FILTER, MPVOID, MPVOID);
    1868               //DbgMsg(pszSrcFile, __LINE__, "UM_FILTER %p pci %p", hwnd, pci);
    18691974            }
    18701975          }
     
    18921997
    18931998      if (dir) {
     1999        DbgMsg(pszSrcFile, __LINE__, "TreeCnrWndProc UM_SHOWME PostMsg(UM_SHOWME, %s)", dir); // 2015-08-13 SHL FIXME debug
    18942000        if (!PostMsg(dcd->hwndObject, UM_SHOWME, MPFROMP(dir), MPVOID))
    18952001          free(dir);
     2002        else
     2003          SetFleshFocusDrive(*dir);
    18962004      }
    18972005    }
     
    19002008  case UM_TOPDIR:
    19012009    if (mp1) {
    1902 
    19032010      PCNRITEM pci = (PCNRITEM) mp1;
    1904 
    19052011      ShowCnrRecord(hwnd, (PMINIRECORDCORE) pci);
    19062012    }
     
    19122018      HDIR hDir = HDIR_CREATE;
    19132019      ULONG nm = 1;
    1914       APIRET status;
     2020      // APIRET status;
    19152021      BOOL IsOk = FALSE;
    19162022      ULONG ulDriveNum, ulDriveMap;
     
    19192025      INT x;
    19202026
    1921       DosRequestMutexSem(hmtxScanning, SEM_INDEFINITE_WAIT);
    1922       DosQueryEventSem(hevTreeCnrScanComplete, &ulScanPostCnt);
     2027#if 0 // 2015-08-04 SHL FIXME to be gone
     2028      rc = DosRequestMutexSem(hmtxScanning, SEM_INDEFINITE_WAIT);
     2029      if (rc)
     2030        Dos_Error(MB_ENTER, rc, HWND_DESKTOP, pszSrcFile, __LINE__, "DosRequestMutexSem");
     2031#endif // 2015-08-04 SHL FIXME to be gone
     2032
     2033#if 0 // 2015-08-04 SHL FIXME to be gone
     2034      rc = DosQueryEventSem(hevTreeCnrScanComplete, &ulScanPostCnt);
     2035      if (rc)
     2036        Dos_Error(MB_ENTER, rc, HWND_DESKTOP, pszSrcFile, __LINE__, "DosQueryEventSem");
    19232037      if (ulScanPostCnt < 1)
    1924         return 0;
    1925       DosResetEventSem(hevTreeCnrScanComplete, &ulScanPostCnt);
     2038        return 0;
     2039      rc = DosResetEventSem(hevTreeCnrScanComplete, &ulScanPostCnt);
     2040      if (rc)
     2041        Dos_Error(MB_ENTER, rc, HWND_DESKTOP, pszSrcFile, __LINE__, "DosResetEventSem");
     2042#endif // 2015-08-04 SHL FIXME to be gone
     2043
    19262044      if (fFollowTree)
    19272045        fl = 0;
     
    19382056          if (hwndStatus)
    19392057            WinSetWindowText(hwndStatus, (CHAR *) GetPString(IDS_RESCANSUGTEXT));
    1940           DosPostEventSem(hevTreeCnrScanComplete);
     2058
     2059#if 0 // 2015-08-04 SHL FIXME to be gone
     2060          rc = DosPostEventSem(hevTreeCnrScanComplete);
     2061          if (rc && rc != ERROR_ALREADY_POSTED)
     2062            Dos_Error(MB_ENTER, rc, HWND_DESKTOP, pszSrcFile, __LINE__, "DosPostEventSem");
     2063#endif // 2015-08-04 SHL FIXME to be gone
     2064
    19412065          return 0;
    19422066        }
     
    19582082            } // for
    19592083            RemoveCnrItems(hwnd, pciP, 1, CMA_FREE | CMA_INVALIDATE);
    1960             DosPostEventSem(hevTreeCnrScanComplete);
     2084
     2085#if 0 // 2015-08-04 SHL FIXME to be gone
     2086            rc = DosPostEventSem(hevTreeCnrScanComplete);
     2087            if (rc && rc != ERROR_ALREADY_POSTED)
     2088              Dos_Error(MB_ENTER, rc, HWND_DESKTOP, pszSrcFile, __LINE__, "DosPostEventSem");
     2089#endif // 2015-08-04 SHL FIXME to be gone
    19612090            return 0;
    19622091          }
     
    19962125          memset(&volser, 0, sizeof(volser));
    19972126          DosError(FERR_DISABLEHARDERR);
    1998           status = DosQueryFSInfo(toupper(*pci->pszFileName) - '@',
    1999                                   FSIL_VOLSER, &volser,
    2000                                   (ULONG) sizeof(volser));
    2001           if (!status) {
     2127          rc = DosQueryFSInfo(toupper(*pci->pszFileName) - '@',
     2128                              FSIL_VOLSER, &volser,
     2129                              (ULONG) sizeof(volser));
     2130          if (!rc) {
    20022131            if (!volser.serial || driveserial[x] != volser.serial) {
     2132#if 1 // 2015-08-04 SHL FIXME to be gone
     2133              AddFleshWorkRequest(hwnd, pciP, eFlesh);  // forceFlesh
     2134#else
    20032135              Flesh(hwnd, pciP);
     2136#endif // 2015-08-04 SHL FIXME to be gone
    20042137              driveserial[x] = volser.serial;
    20052138            }
     
    20082141                              MPFROMP(pciP),
    20092142                              MPFROM2SHORT(CMA_FIRSTCHILD, CMA_ITEMORDER));
    2010             if (!pciL) {
    2011               Flesh(hwnd, pciP);
    2012             }
     2143            if (!pciL) {
     2144#if 1 // 2015-08-04 SHL FIXME to be gone
     2145              AddFleshWorkRequest(hwnd, pciP, eFlesh);  // forceFlesh
     2146#else
     2147              Flesh(hwnd, pciP);
     2148#endif // 2015-08-04 SHL FIXME to be gone
     2149            }
    20132150            if ((fShowFSTypeInTree || fShowDriveLabelInTree) &&
    20142151                strlen(pciP->pszFileName) < 4) {
     
    20272164          else {
    20282165            driveserial[x] = -1;
    2029             UnFlesh(hwnd, pci);
     2166            WaitFleshWorkListEmpty();   // 2015-08-13 SHL in case pci still in work list
     2167            AddFleshWorkRequest(hwnd, pci, eUnFlesh);
    20302168            PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
    2031             PostMsg(hwnd, UM_SETUP2, MPFROMP(pci), MPFROMLONG(status));
    2032             DosPostEventSem(hevTreeCnrScanComplete);
     2169            PostMsg(hwnd, UM_SETUP2, MPFROMP(pci), MPFROMLONG(rc));
     2170
     2171#if 0 // 2015-08-04 SHL FIXME to be gone
     2172            rc = DosPostEventSem(hevTreeCnrScanComplete);
     2173            if (rc && rc != ERROR_ALREADY_POSTED)
     2174              Dos_Error(MB_ENTER, rc, HWND_DESKTOP, pszSrcFile, __LINE__, "DosPostEventSem");
     2175#endif // 2015-08-04 SHL FIXME to be gone
    20332176            return 0;
    20342177          }
    20352178        }
    2036         status = 0;
     2179        rc = 0;
    20372180        IsOk = (IsRoot(pci->pszFileName) &&
    20382181                IsValidDrive(toupper(*pci->pszFileName)));
    20392182        if (!IsOk) {
    20402183          DosError(FERR_DISABLEHARDERR);
    2041           status = DosFindFirst(pci->pszFileName, &hDir,
    2042                                 FILE_NORMAL | FILE_DIRECTORY |
    2043                                 FILE_ARCHIVED | FILE_READONLY |
    2044                                 FILE_HIDDEN | FILE_SYSTEM,
    2045                                 &ffb, sizeof(ffb), &nm, FIL_STANDARD);
     2184          rc = DosFindFirst(pci->pszFileName, &hDir,
     2185                            FILE_NORMAL | FILE_DIRECTORY |
     2186                            FILE_ARCHIVED | FILE_READONLY |
     2187                            FILE_HIDDEN | FILE_SYSTEM,
     2188                            &ffb, sizeof(ffb), &nm, FIL_STANDARD);
    20462189          priority_bumped();
    20472190        }
    2048         if (!status) {
     2191        if (!rc) {
    20492192          if (!IsOk)
    20502193            DosFindClose(hDir);
     
    20532196              PostMsg(hwnd,
    20542197                      WM_COMMAND, MPFROM2SHORT(IDM_SHOWALLFILES, 0), MPVOID);
    2055               DosPostEventSem(hevTreeCnrScanComplete);
     2198
     2199#if 0 // 2015-08-04 SHL FIXME to be gone
     2200              rc = DosPostEventSem(hevTreeCnrScanComplete);
     2201              if (rc && rc != ERROR_ALREADY_POSTED)
     2202                Dos_Error(MB_ENTER, rc, HWND_DESKTOP, pszSrcFile, __LINE__, "DosPostEventSem");
     2203#endif // 2015-08-04 SHL FIXME to be gone
    20562204              return 0;
    20572205            }
    20582206            if ((shiftstate & (KC_CTRL | KC_SHIFT)) == (KC_CTRL | KC_SHIFT)) {
    20592207              OpenObject(pci->pszFileName, Settings, dcd->hwndFrame);
    2060               DosPostEventSem(hevTreeCnrScanComplete);
     2208
     2209#if 0 // 2015-08-04 SHL FIXME to be gone
     2210              rc = DosPostEventSem(hevTreeCnrScanComplete);
     2211              if (rc && rc != ERROR_ALREADY_POSTED)
     2212                Dos_Error(MB_ENTER, rc, HWND_DESKTOP, pszSrcFile, __LINE__, "DosPostEventSem");
     2213#endif // 2015-08-04 SHL FIXME to be gone
    20612214              return 0;
    20622215            }
     
    20642217              if (!ParentIsDesktop(hwnd, dcd->hwndParent)) {
    20652218                if (FindDirCnrByName(pci->pszFileName, TRUE)) {
    2066                   DosPostEventSem(hevTreeCnrScanComplete);
     2219
     2220#if 0 // 2015-08-04 SHL FIXME to be gone
     2221                  rc = DosPostEventSem(hevTreeCnrScanComplete);
     2222                  if (rc && rc != ERROR_ALREADY_POSTED)
     2223                    Dos_Error(MB_ENTER, rc, HWND_DESKTOP, pszSrcFile, __LINE__, "DosPostEventSem");
     2224#endif // 2015-08-04 SHL FIXME to be gone
    20672225                  return 0;
    20682226                }
     
    20882246              }
    20892247              OpenObject(pci->pszFileName, s, dcd->hwndFrame);
    2090               DosPostEventSem(hevTreeCnrScanComplete);
     2248
     2249#if 0 // 2015-08-04 SHL FIXME to be gone
     2250              rc = DosPostEventSem(hevTreeCnrScanComplete);
     2251              if (rc && rc != ERROR_ALREADY_POSTED)
     2252                Dos_Error(MB_ENTER, rc, HWND_DESKTOP, pszSrcFile, __LINE__, "DosPostEventSem");
     2253#endif // 2015-08-04 SHL FIXME to be gone
    20912254              return 0;
    20922255            }
     
    21232286        else {
    21242287          if (!IsRoot(pci->pszFileName)) {
    2125             NotifyError(pci->pszFileName, status);
     2288            NotifyError(pci->pszFileName, rc);
    21262289            RemoveCnrItems(hwnd, pci, 1, CMA_FREE | CMA_INVALIDATE);
    21272290          }
     
    21322295      if (fFollowTree)
    21332296        WinSetFocus(HWND_DESKTOP, hwnd);
    2134       DosPostEventSem(hevTreeCnrScanComplete);
     2297
     2298#if 0 // 2015-08-04 SHL FIXME to be gone
     2299      rc = DosPostEventSem(hevTreeCnrScanComplete);
     2300      if (rc && rc != ERROR_ALREADY_POSTED)
     2301        Dos_Error(MB_ENTER, rc, HWND_DESKTOP, pszSrcFile, __LINE__, "DosPostEventSem");
     2302#endif // 2015-08-04 SHL FIXME to be gone
    21352303    }
    21362304    return 0;
     
    22352403            WinEnableMenuItem((HWND) mp2, IDM_PARTITION, fMiniLVM);
    22362404            WinEnableMenuItem((HWND) mp2, IDM_PARTITIONDF, fDFSee);
    2237             WinEnableMenuItem((HWND) mp2, IDM_PARTITIONLVMG, fLVMGui);
    2238             WinEnableMenuItem((HWND) mp2, IDM_PARTITIONLVM, fLVM);
     2405            WinEnableMenuItem((HWND) mp2, IDM_PARTITIONLVMG, fLVMGui);
     2406            WinEnableMenuItem((HWND) mp2, IDM_PARTITIONLVM, fLVM);
    22392407            WinEnableMenuItem((HWND) mp2, IDM_PARTITIONFD, fFDisk);
    22402408
     
    22662434        WinEnableMenuItem((HWND) mp2, IDM_PARTITION, fMiniLVM);
    22672435        WinEnableMenuItem((HWND) mp2, IDM_PARTITIONDF, fDFSee);
    2268         WinEnableMenuItem((HWND) mp2, IDM_PARTITIONLVMG, fLVMGui);
    2269         WinEnableMenuItem((HWND) mp2, IDM_PARTITIONLVM, fLVM);
     2436        WinEnableMenuItem((HWND) mp2, IDM_PARTITIONLVMG, fLVMGui);
     2437        WinEnableMenuItem((HWND) mp2, IDM_PARTITIONLVM, fLVM);
    22702438        WinEnableMenuItem((HWND) mp2, IDM_PARTITIONFD, fFDisk);
    22712439        break;
     
    23502518      dcd->suspendview = (USHORT) tempsusp;
    23512519      PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
    2352       //DbgMsg(pszSrcFile, __LINE__, "UM_RESCAN %p pci %s", hwnd, (CHAR *) mp1);
    23532520    }
    23542521    return 0;
     
    23562523  case UM_DRIVECMD:
    23572524    if (mp1) {
     2525      DbgMsg(pszSrcFile, __LINE__, "TreeCnrWndProc UM_DRIVECMD ShowTreeRec(\"%s\")", mp1);
    23582526      ShowTreeRec(hwnd, (CHAR *)mp1, FALSE, TRUE);
     2527      DbgMsg(pszSrcFile, __LINE__, "TreeCnrWndProc PostMsg(IDM_UPDATE)");
    23592528      PostMsg(hwndTree, WM_COMMAND, MPFROM2SHORT(IDM_UPDATE, 0), MPVOID);
    23602529    }
     
    23862555              RemoveCnrItems(hwnd, pci, 1, CMA_FREE);
    23872556            else
    2388               Flesh(hwnd, pci);
     2557              AddFleshWorkRequest(hwnd, pci, eFlesh);
    23892558          }
    23902559          if (info->prev)
     
    24612630                }
    24622631                apptail = info;
    2463               }
    2464               PostMsg(hwndTree, WM_COMMAND, MPFROM2SHORT(IDM_RESCAN, 0), MPVOID);
     2632              }
     2633              PostMsg(hwndTree, WM_COMMAND, MPFROM2SHORT(IDM_RESCAN, 0), MPVOID);
    24652634            }
    24662635          }
     
    26122781                NULL, NULL,
    26132782                "%s", PCSZ_LVMGUICMD);
    2614         break;
     2783        break;
    26152784
    26162785      case IDM_PARTITIONLVM:
     
    26272796
    26282797      case IDM_REFRESHREMOVABLES:
    2629         {
    2630         PFN Rediscover_PRMs;
    2631         HMODULE hmod = 0;
    2632         APIRET rc;
    2633         CHAR objerr[CCHMAXPATH];
    2634 
    2635         rc = DosLoadModule(objerr, sizeof(objerr), "LVM", &hmod);
    2636         if (!rc) {
    2637           rc = DosQueryProcAddr(hmod, 70, NULL, &Rediscover_PRMs);
    2638           if (!rc)
     2798        {
     2799        PFN Rediscover_PRMs;
     2800        HMODULE hmod = 0;
     2801        CHAR objerr[CCHMAXPATH];
     2802
     2803        rc = DosLoadModule(objerr, sizeof(objerr), "LVM", &hmod);
     2804        if (!rc) {
     2805          rc = DosQueryProcAddr(hmod, 70, NULL, &Rediscover_PRMs);
     2806          if (!rc)
    26392807            Rediscover_PRMs(&rc);
    2640           DosFreeModule(hmod);
    2641         }
    2642         if (!rc)
     2808          DosFreeModule(hmod);
     2809        }
     2810        if (!rc)
    26432811          PostMsg(hwndTree, WM_COMMAND, MPFROM2SHORT(IDM_RESCAN, 0), MPVOID);
    2644         break;
    2645         }
     2812        break;
     2813        }
    26462814
    26472815      case IDM_SORTNAME:
     
    28022970      case IDM_UPDATE:
    28032971        {
    2804           PCNRITEM pci = (PCNRITEM)CurrentRecord(hwnd);
     2972          // 2015-08-07 SHL FIXME select
     2973          PCNRITEM pci;
     2974          if (!IsFleshWorkListEmpty())
     2975            break;                      // 2015-08-07 SHL hold off until stable
     2976          pci = (PCNRITEM)CurrentRecord(hwnd);
    28052977          if (pci && (INT)pci != -1) {
    28062978            struct
     
    28172989            if (pci->attrFile & FILE_DIRECTORY) {
    28182990              if (pci->flags & RECFLAGS_UNDERENV)
    2819                 break;
    2820               DosRequestMutexSem(hmtxScanning, SEM_INDEFINITE_WAIT);
    2821               DosResetEventSem(hevTreeCnrScanComplete, &ulScanPostCnt);
    2822               UnFlesh(hwnd, pci);
     2991                break;
     2992
     2993#if 0 // 2015-08-04 SHL FIXME to be gone
     2994              rc = DosRequestMutexSem(hmtxScanning, SEM_INDEFINITE_WAIT);
     2995              if (rc)
     2996                Dos_Error(MB_ENTER, rc, HWND_DESKTOP, pszSrcFile, __LINE__, "DosRequestMutexSem");
     2997#endif // 2015-08-04 SHL FIXME to be gone
     2998
     2999#if 0 // 2015-08-04 SHL FIXME to be gone
     3000              rc = DosResetEventSem(hevTreeCnrScanComplete, &ulScanPostCnt);
     3001              if (rc)
     3002                Dos_Error(MB_ENTER, rc, HWND_DESKTOP, pszSrcFile, __LINE__, "DosResetEventSem");
     3003#endif // 2015-08-04 SHL FIXME to be gone
     3004
     3005              // Can't wait here
     3006              // WaitFleshWorkListEmpty();      // 2015-08-13 SHL in case pci still in work list
     3007              AddFleshWorkRequest(hwnd, pci, eUnFlesh);
    28233008              // Check if drive type might need update
    28243009              if ((driveflag & (DRIVE_INVALID | DRIVE_NOPRESCAN)) ||
     
    28283013                if (driveflag & DRIVE_INVALID)
    28293014                  pci->rc.hptrIcon = hptrDunno;
    2830                 else  if (strlen(pci->pszFileName) < 4) {
     3015                else if (strlen(pci->pszFileName) < 4) {
    28313016                  SelectDriveIcon(pci);
    2832                   if (fShowFSTypeInTree || fShowDriveLabelInTree) {
    2833                     strcpy(szBuf, pci->pszFileName);
    2834                     strcat(szBuf, " [");
    2835                     strcat(szBuf, fShowFSTypeInTree ? FileSystem : volser.volumelabel);
    2836                     strcat(szBuf, "]");
    2837                     pci->pszDisplayName = xstrdup(szBuf, pszSrcFile, __LINE__);
    2838                     pci->rc.pszIcon = pci->pszDisplayName;
    2839                   }
    2840                 }
     3017                  if (fShowFSTypeInTree || fShowDriveLabelInTree) {
     3018                    strcpy(szBuf, pci->pszFileName);
     3019                    strcat(szBuf, " [");
     3020                    strcat(szBuf, fShowFSTypeInTree ? FileSystem : volser.volumelabel);
     3021                    strcat(szBuf, "]");
     3022                    pci->pszDisplayName = xstrdup(szBuf, pszSrcFile, __LINE__);
     3023                    pci->rc.pszIcon = pci->pszDisplayName;
     3024                  }
     3025                }
    28413026                WinSendMsg(hwnd,
    28423027                           CM_INVALIDATERECORD,
     
    28463031                  PostMsg(hwndMain, UM_BUILDDRIVEBAR, MPVOID, MPVOID);
    28473032              }
     3033              DbgMsg(pszSrcFile, __LINE__, " TreeCnrWndProc IDM_UPDATE %s", pci->pszFileName); // 2015-08-03 SHL FIXME debug
    28483034              if (~driveflag & DRIVE_INVALID)
    2849                 Flesh(hwnd, pci);
    2850               DosPostEventSem(hevTreeCnrScanComplete);
     3035                AddFleshWorkRequest(hwnd, pci, eFlesh);
     3036#if 0 // 2015-08-04 SHL FIXME to be gone
     3037              rc = DosPostEventSem(hevTreeCnrScanComplete);
     3038              if (rc && rc != ERROR_ALREADY_POSTED)
     3039                Dos_Error(MB_ENTER, rc, HWND_DESKTOP, pszSrcFile, __LINE__, "DosPostEventSem");
     3040#endif // 2015-08-04 SHL FIXME to be gone
    28513041            }
    28523042          }
     
    30213211            case IDM_MCIPLAY:
    30223212              action = UM_MASSACTION;
    3023             }
    3024             if (li->type == IDM_DELETE)
    3025               ignorereadonly = FALSE;
     3213            }
     3214            if (li->type == IDM_DELETE)
     3215              ignorereadonly = FALSE;
    30263216            if (SHORT1FROMMP(mp1) == IDM_SHADOW ||
    30273217                SHORT1FROMMP(mp1) == IDM_SHADOW2)
     
    31433333  case WM_DESTROY:
    31443334#   ifdef FORTIFY
    3145     DbgMsg(pszSrcFile, __LINE__, "WM_DESTROY hwnd %p TID %u", hwnd, GetTidForThread()); // 18 Jul 08 SHL fixme
     3335    DbgMsg(pszSrcFile, __LINE__, "WM_DESTROY hwnd %x TID %u", hwnd, GetTidForThread()); // 18 Jul 08 SHL FIXME
    31463336#   endif
    31473337    if (TreeCnrMenu)
  • trunk/dll/update.c

    r1830 r1856  
    77
    88  Copyright (c) 1993-98 M. Kimes
    9   Copyright (c) 2003, 2008 Steven H. Levine
     9  Copyright (c) 2003, 2015 Steven H. Levine
    1010
    1111  12 Feb 03 SHL Standardize EA math
     
    2121  14 Mar 09 GKY Prevent execution of UM_SHOWME while drive scan is occuring
    2222  22 Jul 09 GKY Code changes to use semaphores to serialize drive scanning
     23  07 Aug 15 SHL Sync with Flesh/Stubby mods
     24
    2325
    2426***********************************************************************/
     
    200202            PostMsg(hwndCnr, UM_RESCAN, MPVOID, MPVOID);
    201203            if (pci->attrFile & FILE_DIRECTORY) {
    202               Stubby(hwndCnr, pci);
     204              AddFleshWorkRequest(hwndCnr, pci, eStubby);
    203205            }
    204206          }
     
    243245                if (WinSendMsg(hwndCnr,
    244246                               CM_INSERTRECORD, MPFROMP(pci), MPFROMP(&ri))) {
    245                   Flesh(hwndCnr, pci);
     247                  AddFleshWorkRequest(hwndCnr, pci, eFlesh);
    246248                  *p = temp;
    247249                  pci = FindCnrRecord(hwndCnr,
     
    255257              pciParent = pciT;
    256258              if (!(pciT->rc.flRecordAttr & CRA_EXPANDED)) {
    257                 Flesh(hwndCnr, pciT);
     259                AddFleshWorkRequest(hwndCnr, pciT, eFlesh);
    258260                *p = temp;
    259261                pci = FindCnrRecord(hwndCnr,
     
    294296              dcd->ullTotalBytes += ullTotalBytes;
    295297            }
    296             Stubby(hwndCnr, pci);
     298            AddFleshWorkRequest(hwndCnr, pci, eStubby);
    297299          }
    298300        }
     
    460462                repos = TRUE;
    461463                if (pci->attrFile & FILE_DIRECTORY) {
    462                   Stubby(hwndCnr, pci);
     464                  AddFleshWorkRequest(hwndCnr, pci, eStubby);
    463465                }
    464466              }
     
    559561                  }
    560562                  repos = TRUE;
    561                   Stubby(hwndCnr, pci);
     563                  AddFleshWorkRequest(hwndCnr, pci, eStubby);
    562564                }
    563565                else
Note: See TracChangeset for help on using the changeset viewer.