Changeset 1867 for trunk/dll/treecnr.c


Ignore:
Timestamp:
Aug 24, 2015, 5:43:26 AM (10 years ago)
Author:
Steven Levine
Message:

Rework ShowTreeRec to avoid retry failures
Rework WaitFleshWorkListEmpty to let PM do some work before returning to caller

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/dll/treecnr.c

    r1865 r1867  
    103103  20 Aug 15 SHL Sync with SetFleshFocusPath mods
    104104  22 Aug 15 GKY Improve ability of maketop to get directory position in tree correct on first
    105                 open of states with large and/or deep tree structures
     105                open of states with large and/or deep tree structures
    106106
    107107***********************************************************************/
     
    295295  BOOL quickbail = FALSE;
    296296  PSZ p;
    297   UINT cDirLen;
    298297  BOOL found;
    299298  CHAR szDir[CCHMAXPATH];
    300 
    301   DbgMsg(pszSrcFile, __LINE__, "ShowTreeRec pszDir_ \"%s\"", pszDir_); // 2015-08-04 SHL FIXME debug
     299  CHAR szDirArg[CCHMAXPATH];            // Copy of passed value
     300  CHAR chSaved;
     301
     302  DbgMsg(pszSrcFile, __LINE__, "ShowTreeRec called for pszDir_ \"%s\"", pszDir_); // 2015-08-04 SHL FIXME debug
     303
     304  strcpy(szDirArg, pszDir_);            // Cache here in case arg content changed by some other thread
    302305
    303306  // already positioned to requested record?
     
    305308                   CM_QUERYRECORDEMPHASIS,
    306309                   MPFROMLONG(CMA_FIRST), MPFROMSHORT(CRA_CURSORED));
    307   if (pci && (INT)pci != -1 && !stricmp(pci->pszFileName, pszDir_)) {
     310  if (pci && (INT)pci != -1 && !stricmp(pci->pszFileName, szDirArg)) {
    308311    found = TRUE;
    309312    quickbail = TRUE;                   // Already at requested record - bypass repositioning
    310313    goto MakeTop;
    311314  }
     315
     316  // 2015-08-23 SHL FIXME to be gone - problem must be elsewhere
    312317  // 2015-08-22 GKY Without this FM2 has NULL pci->pszFileName errors and switch failures
    313318  if (fInitialDriveScan)
    314     DosSleep(1500); // 100 still had errors
     319    DosSleep(100); // 100 still had errors
    315320  if (fSwitchTreeOnDirChg)
    316321    DosSleep(200);
     
    321326
    322327    pci = FindCnrRecord(hwndCnr,
    323                         pszDir_,
     328                        szDirArg,
    324329                        NULL,           // pciParent
    325330                        TRUE,           // partial
     
    332337    }
    333338
    334     // Try again expanding as needed
    335     DbgMsg(pszSrcFile, __LINE__, "ShowTreeRec need expand, IsFleshWorkListEmpty %u", IsFleshWorkListEmpty()); // 2015-08-04 SHL FIXME debug
    336 
    337     cDirLen = strlen(pszDir_);
    338 
    339     *szDir = *pszDir_;                  // Drive letter
    340     szDir[1] = ':';
    341     szDir[2] = '\\';
    342     szDir[3] = 0;
     339    // Walk down directory tree, expanding as needed
     340    DbgMsg(pszSrcFile, __LINE__, "ShowTreeRec needs expand, szDirArg \"%s\", IsFleshWorkListEmpty %u", szDirArg, IsFleshWorkListEmpty()); // 2015-08-04 SHL FIXME debug
     341
     342    strcpy(szDir, szDirArg);
    343343    p = szDir + 3;                      // Point after root backslash
     344    chSaved = *p;                       // Remember for restore
     345    *p = 0;                             // Chop after backslash
    344346
    345347    for (;;) {
     
    352354                           TRUE);               // noenv
    353355      if (!pciP || (INT)pciP == -1) {
    354         DbgMsg(pszSrcFile, __LINE__, "ShowTreeRec FindCnrRecord(\"%s\") returned %p", szDir, pciP); // 2015-08-04 SHL FIXME debug
    355         WaitFleshWorkListEmpty(szDir);          // 2015-08-19 SHL
     356        DbgMsg(pszSrcFile, __LINE__, "ShowTreeRec FindCnrRecord(\"%s\") returned pciP %p", szDir, pciP); // 2015-08-04 SHL FIXME debug
     357        WaitFleshWorkListEmpty(szDirArg);       // 2015-08-23 SHL
    356358        break;                                  // No match
    357359      }
    358360
    359       DbgMsg(pszSrcFile, __LINE__, "ShowTreeRec FindCnrRecord returned %p \"%s\"", pciP, pciP->pszFileName); // 2015-08-04 SHL FIXME debug
    360 
    361       if (!stricmp(pszDir_, pciP->pszFileName)) {
     361      DbgMsg(pszSrcFile, __LINE__, "ShowTreeRec FindCnrRecord(\"%s\") returned %p \"%s\"", szDir, pciP, pciP->pszFileName); // 2015-08-04 SHL FIXME debug
     362
     363      if (!stricmp(szDirArg, pciP->pszFileName)) {
    362364        pci = pciP;
    363365        found = TRUE;
     
    365367      }
    366368
     369      // Got partial match
     370
    367371      if (~pciP->rc.flRecordAttr & CRA_EXPANDED) {
    368372        DbgMsg(pszSrcFile, __LINE__, "ShowTreeRec expanding \"%s\"", pciP->pszFileName); // 2015-08-04 SHL FIXME debug
    369373        WinSendMsg(hwndCnr, CM_EXPANDTREE, MPFROMP(pciP), MPVOID);
    370         DosSleep(100);                          // 2015-08-13 SHL Let PM catch up
    371       }
    372 
    373       //WaitFleshWorkListEmpty(szDir);  // 2015-08-19 SHL
    374 
    375       // Add next component to path
    376       if (p - szDir >= cDirLen)
    377         break;                          // Done
    378       strcpy(szDir, pszDir_);           // Reset
    379       p = strchr(p, '\\');              // Find next backslash
    380       if (!p)
    381         break;                          // Give up
    382 
    383       *p++ = 0;                         // Truncate at backslash
     374      }
     375
     376      // Add next component to path unless no more components
     377      if (p) {
     378        *p = chSaved;                   // Restore
     379        if (chSaved) {
     380          if (chSaved == '\\')
     381            p++;                        // Get past last backslash
     382          p = strchr(p, '\\');          // Find next backslash
     383          if (p) {
     384            chSaved = *p;
     385            *p = 0;                     // Truncate at backslash
     386          }
     387        }
     388      }
     389
     390      DosSleep(100);                    // 2015-08-13 SHL Let PM catch up
    384391
    385392    } // while expanding
     
    438445        // 2015-08-23 SHL FIXME debug
    439446        DbgMsg(pszSrcFile, __LINE__, "ShowTreeRec ShowCnrRecord(%p) fTopDir %i maketop %i", pciToSelect, fTopDir, maketop); // 2015-08-04 SHL FIXME debug
    440         ShowCnrRecord(hwndCnr, (PMINIRECORDCORE)pciToSelect);
     447        ShowCnrRecord(hwndCnr, (PMINIRECORDCORE)pciToSelect);
    441448      }
    442449
    443450      if (!quickbail) {
    444         WaitFleshWorkListEmpty(pszDir_);        // 2015-08-19 SHL try to ensure contents stable
    445         DbgMsg(pszSrcFile, __LINE__, "ShowTreeRec WinSendMsg(CM_SETRECORDEMPHASIS, CRA_SELECTED | CRA_CURSORED) pszDir_ \"%s\"", pszDir_); // 2015-08-04 SHL FIXME debug
     451        WaitFleshWorkListEmpty(szDirArg);       // 2015-08-19 SHL try to ensure contents stable
     452        DbgMsg(pszSrcFile, __LINE__, "ShowTreeRec WinSendMsg(CM_SETRECORDEMPHASIS, CRA_SELECTED | CRA_CURSORED) szDirArg \"%s\"", szDirArg); // 2015-08-04 SHL FIXME debug
    446453        WinSendMsg(hwndCnr,
    447454                   CM_SETRECORDEMPHASIS,
Note: See TracChangeset for help on using the changeset viewer.