Changeset 1856 for trunk/dll/dircnrs.c


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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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        }
Note: See TracChangeset for help on using the changeset viewer.