Changeset 1778


Ignore:
Timestamp:
Jun 27, 2014, 12:30:54 AM (11 years ago)
Author:
Steven Levine
Message:

Rework dircnrs.c DirObjWndProc UM_RESCAN to avoid hanging FM/2 Lite when
drive tree hidden. Also speeds up startup if Switch Tree on directory change
not enabled.

Location:
trunk/dll
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/dll/dircnrs.c

    r1777 r1778  
    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
    8788
    8889***********************************************************************/
     
    761762      dcd->hwndObject = hwnd;
    762763      if (ParentIsDesktop(hwnd, dcd->hwndParent))
    763         DosSleep(100); 
     764        DosSleep(100);
    764765    }
    765766    else
     
    878879          WinSendMsg(hwndMain, UM_LOADFILE, MPVOID, MPVOID);
    879880      }
    880       while (fInitialDriveScan) {
    881         DosSleep(100);                  // Allow to complete
    882       }
    883       if (fSwitchTree && hwndTree) {
    884         // Keep drive tree in sync with directory container
    885         PSZ pszTempDir = xstrdup(dcd->directory, pszSrcFile, __LINE__);
    886         if (pszTempDir) {
    887           if (hwndMain) {
    888             if (TopWindow(hwndMain, (HWND) 0) == dcd->hwndFrame)
    889               if (!PostMsg(hwndTree, UM_SHOWME, MPFROMP(pszTempDir), MPVOID))
    890                 free(pszTempDir);
    891           }
    892           else {
    893             if (!PostMsg(hwndTree, UM_SHOWME, MPFROMP(pszTempDir), MPVOID))
    894               free(pszTempDir);
    895           }
    896         }
    897       }
     881      // 2014-06-26 SHL FM/2 Lite may not have drive tree yet
     882      if (hwndTree) {
     883        if (fSwitchTreeOnDirChg) {
     884          // Keep drive tree in sync with directory container
     885          PSZ pszTempDir;
     886          while (fInitialDriveScan) {
     887            DosSleep(100);                      // Allow to complete
     888          }
     889          pszTempDir = xstrdup(dcd->directory, pszSrcFile, __LINE__);
     890          if (pszTempDir) {
     891            if (hwndMain) {
     892              if (TopWindow(hwndMain, (HWND) 0) == dcd->hwndFrame)
     893                if (!PostMsg(hwndTree, UM_SHOWME, MPFROMP(pszTempDir), MPVOID))
     894                  free(pszTempDir);
     895            }
     896            else {
     897              if (!PostMsg(hwndTree, UM_SHOWME, MPFROMP(pszTempDir), MPVOID))
     898                free(pszTempDir);
     899            }
     900          }
     901        } // fSwitchTreeOnDirChg
     902      } // if hwndTree
    898903      dcd->firsttree = FALSE;
    899904      WinStartTimer(WinQueryAnchorBlock(hwnd), dcd->hwndCnr, ID_DIRCNR_TIMER, 500);
     
    981986      case IDM_MCIPLAY:
    982987      case IDM_UPDATE:
    983         if (li->type == IDM_DELETE)
    984           ignorereadonly = FALSE;
     988        if (li->type == IDM_DELETE)
     989          ignorereadonly = FALSE;
    985990        if (PostMsg(hwnd, UM_MASSACTION, mp1, mp2))
    986991          return (MRESULT) TRUE;
     
    13951400      PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
    13961401      if (fSwitchTreeOnFocus && hwndTree && dcd && *dcd->directory) {
    1397         PSZ pszTempDir = xstrdup(dcd->directory, pszSrcFile, __LINE__);
    1398         if (pszTempDir) {
     1402        PSZ pszTempDir = xstrdup(dcd->directory, pszSrcFile, __LINE__);
     1403        if (pszTempDir) {
    13991404          if (!PostMsg(hwndTree, UM_SHOWME, MPFROMP(pszTempDir), MPVOID))
    14001405            free(pszTempDir);           // Failed
     
    14171422          // DosEnterCritSec(); // GKY 11-27-08
    14181423          dcd->stopflag++;
    1419           // DosExitCritSec();
    1420           // DbgMsg(pszSrcFile, __LINE__, "WM_RESCAN");
     1424          // DosExitCritSec();
     1425          // DbgMsg(pszSrcFile, __LINE__, "WM_RESCAN");
    14211426          if (!PostMsg(dcd->hwndObject, UM_RESCAN, MPVOID, MPFROMLONG(1L))) {
    14221427            strcpy(dcd->directory, dcd->previous);
     
    14741479      WinSetDlgItemText(dcd->hwndClient, DIR_SELECTED, s);
    14751480      if (hwndStatus &&
    1476           dcd->hwndFrame == WinQueryActiveWindow(dcd->hwndParent)) {
     1481          dcd->hwndFrame == WinQueryActiveWindow(dcd->hwndParent)) {
    14771482        PostMsg(dcd->hwndObject, UM_RESCAN2, MPVOID, MPVOID);
    14781483        if ((fSplitStatus && hwndStatus2) || fMoreButtons) {
     
    17271732            WinEnableMenuItem((HWND) mp2, IDM_ATTRS, TRUE);
    17281733          }
    1729         WinEnableMenuItem((HWND) mp2, IDM_UNLOCKFILE, fUnlock);
     1734        WinEnableMenuItem((HWND) mp2, IDM_UNLOCKFILE, fUnlock);
    17301735        }
    17311736        break;
     
    17441749        WinEnableMenuItem((HWND) mp2,
    17451750                          IDM_SELECTCOMPAREMENU,
    1746                           (CountDirCnrs(dcd->hwndParent) > 1));
     1751                          (CountDirCnrs(dcd->hwndParent) > 1));
    17471752        break;
    17481753
     
    18501855              strcpy(newfile, dcd->directory);
    18511856              AddBackslashToPath(newfile);
    1852 #             if 0     
     1857#             if 0
    18531858              if (newfile[strlen(newfile) - 1] != '\\')
    18541859                strcat(newfile, "\\");
    1855 #             endif     
     1860#             endif
    18561861              strcat(newfile, sip.ret);
    18571862              test = IsFile(newfile);
    1858               if (test != 1) {
    1859                 CHAR *modew = "w";
    1860 
    1861                 fp = xfopen(newfile, modew, pszSrcFile, __LINE__, TRUE);
    1862               }
     1863              if (test != 1) {
     1864                CHAR *modew = "w";
     1865
     1866                fp = xfopen(newfile, modew, pszSrcFile, __LINE__, TRUE);
     1867              }
    18631868              if (test != 1 && !fp) {
    18641869                saymsg(MB_ENTER,
     
    18791884                  dummy[1] = NULL;
    18801885                  ExecOnList(hwnd,
    1881                              editor, WINDOWED | SEPARATE, NULL, NULL,
    1882                              dummy, NULL, pszSrcFile, __LINE__);
     1886                             editor, WINDOWED | SEPARATE, NULL, NULL,
     1887                             dummy, NULL, pszSrcFile, __LINE__);
    18831888                }
    18841889                else
     
    23222327        //DosEnterCritSec(); //GKY 11-27-08
    23232328        dcd->stopflag++;
    2324         // DosExitCritSec();
    2325         // DbgMsg(pszSrcFile, __LINE__, "WM_RESCAN");
     2329        // DosExitCritSec();
     2330        // DbgMsg(pszSrcFile, __LINE__, "WM_RESCAN");
    23262331        if (!PostMsg(dcd->hwndObject, UM_RESCAN, MPVOID, MPVOID)) {
    23272332          //DosEnterCritSec(); //GKY 11-27-08
     
    24612466          //DosEnterCritSec(); // GKY 11-27-08
    24622467          dcd->stopflag++;
    2463           //DosExitCritSec();
    2464           //DbgMsg(pszSrcFile, __LINE__, "WM_RESCAN");
     2468          //DosExitCritSec();
     2469          //DbgMsg(pszSrcFile, __LINE__, "WM_RESCAN");
    24652470          if (!PostMsg(dcd->hwndObject, UM_RESCAN, MPVOID, MPFROMLONG(1L))) {
    24662471            strcpy(dcd->directory, dcd->previous);
     
    24942499              strcpy(dcd->directory, tempname2);
    24952500              dcd->stopflag++;
    2496               //DbgMsg(pszSrcFile, __LINE__, "WM_RESCAN");
     2501              //DbgMsg(pszSrcFile, __LINE__, "WM_RESCAN");
    24972502              if (!PostMsg(dcd->hwndObject,
    24982503                           UM_RESCAN, MPVOID, MPFROMLONG(1L))) {
     
    25232528            strcpy(dcd->previous, tempname);
    25242529            dcd->stopflag++; ;
    2525             //DbgMsg(pszSrcFile, __LINE__, "WM_RESCAN");
     2530            //DbgMsg(pszSrcFile, __LINE__, "WM_RESCAN");
    25262531            if (!PostMsg(dcd->hwndObject, UM_RESCAN, MPVOID, MPFROMLONG(1L))) {
    25272532              strcpy(dcd->directory, dcd->previous);
     
    25572562            strcpy(dcd->directory, newdir);
    25582563            dcd->stopflag++;
    2559             //DbgMsg(pszSrcFile, __LINE__, "WM_RESCAN");
     2564            //DbgMsg(pszSrcFile, __LINE__, "WM_RESCAN");
    25602565            if (!PostMsg(dcd->hwndObject, UM_RESCAN, MPVOID, MPFROMLONG(1L))) {
    25612566              strcpy(dcd->directory, dcd->previous);
     
    26402645            li->hwnd = hwnd;
    26412646            li->list = BuildList(hwnd);
    2642             if (li->type == IDM_DELETE)
    2643               ignorereadonly = FALSE;
     2647            if (li->type == IDM_DELETE)
     2648              ignorereadonly = FALSE;
    26442649            switch (SHORT1FROMMP(mp1)) {
    26452650            case IDM_WILDMOVE:
     
    27132718                action = UM_MASSACTION;
    27142719                break;
    2715               }
    2716               if (li->type == IDM_DELETE)
    2717                 ignorereadonly = FALSE;
     2720              }
     2721              if (li->type == IDM_DELETE)
     2722                ignorereadonly = FALSE;
    27182723              if (SHORT1FROMMP(mp1) == IDM_OBJECT ||
    27192724                  SHORT1FROMMP(mp1) == IDM_SHADOW ||
     
    29922997          }
    29932998
    2994           /**
    2995            * Access DRAGITEM index to DRAGITEM
     2999          /**
     3000           * Access DRAGITEM index to DRAGITEM
    29963001           * Check valid rendering mechanisms and data
    29973002           */
     
    34003405                  strcpy(dcd->directory, pci->pszFileName);
    34013406                  dcd->stopflag++;
    3402                   //DbgMsg(pszSrcFile, __LINE__, "WM_RESCAN");
     3407                  //DbgMsg(pszSrcFile, __LINE__, "WM_RESCAN");
    34033408                  if (!PostMsg(dcd->hwndObject,
    34043409                               UM_RESCAN, MPVOID, MPFROMLONG(1))) {
     
    34443449              else {
    34453450                dcd->stopflag++;
    3446                 //DbgMsg(pszSrcFile, __LINE__, "WM_RESCAN");
     3451                //DbgMsg(pszSrcFile, __LINE__, "WM_RESCAN");
    34473452                if (!PostMsg(dcd->hwndObject,
    34483453                             UM_RESCAN, MPVOID, MPFROMLONG(1L))) {
     
    35493554    if ((ULONG)dcd->oldproc == 0xa9a9a9a9)
    35503555      DbgMsg(pszSrcFile, __LINE__, "calling oldproc after dcd free msg %x mp1 %x mp2 %x",
    3551              msg, mp1, mp2);
     3556             msg, mp1, mp2);
    35523557#   endif
    35533558    return dcd->oldproc(hwnd, msg, mp1, mp2);
  • trunk/dll/filldir.c

    r1764 r1778  
    236236  HAB thab;
    237237  HMQ hmq = (HMQ) 0;
    238   //BOOL ok;
    239238  static INT ProcessDirCount = 0;
    240239
     
    283282    DosReleaseMutexSem(hmtxScanning);
    284283    DosPostEventSem(hevTreeCnrScanComplete);
    285     if (fInitialDriveScan && fSwitchTree && hwndTree && fSaveState && pszFocusDir) {
     284    if (fInitialDriveScan && fSwitchTreeOnDirChg && hwndTree && fSaveState && pszFocusDir) {
    286285       // Keep drive tree in sync with directory container
    287286      if (!PostMsg(hwndTree, UM_SHOWME, MPFROMP(pszFocusDir), MPVOID))
     
    290289    ProcessDirCount = 0;
    291290    FixedVolume = 0;
    292     //fInitialDriveScan = FALSE;
    293291  }
    294292# ifdef FORTIFY
     
    15341532
    15351533  // move cursor onto the default drive rather than the first drive
    1536   if (!fSwitchTree) {
     1534  if (!fSwitchTreeOnDirChg) {
    15371535    pci = (PCNRITEM) WinSendMsg(hwndCnr,
    15381536                                CM_QUERYRECORD,
     
    17071705                                MPFROMP(pci),
    17081706                                MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER));
    1709   }
     1707  } // while pci
    17101708
    17111709  if (hwndMain)
  • trunk/dll/fm3dlg.h

    r1711 r1778  
    631631#define CFGT_FRAME                                                                              25050
    632632#define CFGT_SWITCHTREEONFOCUS                                                          25051
    633 #define CFGT_SWITCHTREE                                                                 25052
     633#define CFGT_SWITCHTREEONDIRCHG                                                         25052
    634634#define CFGT_SWITCHTREEEXPAND                                                           25053
    635635#define CFGT_COLLAPSEFIRST                                                              25054
  • trunk/dll/fm3res.dlg

    r1711 r1778  
    20322032        AUTOCHECKBOX    "~Switch on focus change", CFGT_SWITCHTREEONFOCUS, 4,
    20332033                        80, 132, 10
    2034         AUTOCHECKBOX    "Switch on directory ~change", CFGT_SWITCHTREE, 4,
     2034        AUTOCHECKBOX    "Switch on directory ~change", CFGT_SWITCHTREEONDIRCHG, 4,
    20352035                        68, 132, 10
    20362036        AUTOCHECKBOX    "Co~llapse before switch", CFGT_COLLAPSEFIRST, 4, 56,
  • trunk/dll/init.c

    r1777 r1778  
    11761176    fAutoAddDirs = fUseNewViewer = fDataToFore = fDataShowDrives = fDataMin =
    11771177    fSplitStatus = fDragndropDlg = fQuickArcFind = fKeepCmdLine =
    1178     fMoreButtons = fDrivebar = fCollapseFirst = fSwitchTree =
     1178    fMoreButtons = fDrivebar = fCollapseFirst = fSwitchTreeOnDirChg =
    11791179    fSwitchTreeExpand = fNoSearch = fCustomFileDlg = fOtherHelp =
    11801180    fSaveMiniCmds = fUserComboBox = fFM2Deletes = fConfirmTarget =
     
    13831383  PrfQueryProfileData(fmprof, appname, "ErrorBeepOff", &fErrorBeepOff, &size);
    13841384  size = sizeof(BOOL);
    1385   PrfQueryProfileData(fmprof, appname, "SwitchTree", &fSwitchTree, &size);
     1385  PrfQueryProfileData(fmprof, appname, "SwitchTree", &fSwitchTreeOnDirChg, &size);
    13861386  size = sizeof(BOOL);
    13871387  PrfQueryProfileData(fmprof, appname, "SwitchTreeExpand", &fSwitchTreeExpand, &size);
  • trunk/dll/mainwnd.c

    r1777 r1778  
    35533553            continue;
    35543554          }
    3555           if (x == 0 && fSwitchTree)
     3555          if (x == 0 && fSwitchTreeOnDirChg)
    35563556            pszFocusDir = xstrdup(szDir, pszSrcFile, __LINE__);
    35573557          LoadDetailsSwitches(szKeyBase, &localdcd.ds, TRUE);
  • trunk/dll/mainwnd2.c

    r1777 r1778  
    436436{
    437437  PERSON1DATA *pd;
     438  BOOL yes;
    438439
    439440  SetShiftState();
     
    584585    WinSendMsg(hwnd, UM_SETUP2, MPFROMLONG(1), MPVOID);
    585586    if (hwndTree) {
     587      // Hide
    586588      WinShowWindow(hwndTree, FALSE);
    587589      PostMsg(hwndTree, WM_CLOSE, MPVOID, MPVOID);
    588       hwndTree = (HWND) 0;
     590      hwndTree = NULLHANDLE;
    589591    }
    590592    else {
    591 
     593      // Create tree window if needed and make visible
    592594      ULONG size = sizeof(ULONG);
    593 
    594595      hwndTree = StartTreeCnr(hwnd, 3);
    595       PrfQueryProfileData(fmprof,
    596                           realappname,
    597                           "FM/4 TreeWidth", (PVOID) & TreeWidth, &size);
     596      PrfQueryProfileData(fmprof, realappname,
     597                          "FM/4 TreeWidth", (PVOID)&TreeWidth, &size);
    598598      TreeWidth = max(TreeWidth, 80);
    599599    }
    600     {
    601       BOOL dummy = (hwndTree != (HWND) 0);
    602 
    603       PrfWriteProfileData(fmprof,
    604                           realappname,
    605                           "FM/4 TreeUp", (PVOID) & dummy, sizeof(dummy));
    606     }
     600    yes = hwndTree != NULLHANDLE;
     601    PrfWriteProfileData(fmprof, realappname,
     602                        "FM/4 TreeUp", (PVOID)&yes, sizeof(yes));
    607603    PostMsg(hwnd, UM_SIZE, MPVOID, MPVOID);
    608604    break;
     
    793789  ULONG which;
    794790  ULONG size;
     791  BOOL yes;
    795792
    796793  switch (msg) {
     
    861858    if (pd) {
    862859      CHAR s[CCHMAXPATH];
    863       BOOL dummy = TRUE;
    864 
     860      yes = TRUE;
    865861      size = sizeof(BOOL);
    866       PrfQueryProfileData(fmprof, realappname, "FM/4 TreeUp",
    867                           (PVOID) &dummy, &size);
    868       if (dummy) {
    869         size = sizeof(ULONG);
     862      PrfQueryProfileData(fmprof, realappname,
     863                          "FM/4 TreeUp", (PVOID)&yes, &size);
     864      if (yes) {
    870865        hwndTree = StartTreeCnr(hwnd, 3);
     866        size = sizeof(TreeWidth);
    871867        PrfQueryProfileData(fmprof, realappname, "FM/4 TreeWidth",
    872                             (PVOID) &TreeWidth, &size);
     868                            (PVOID)&TreeWidth, &size);
    873869        TreeWidth = max(TreeWidth, 80);
    874870      }
    875871      size = sizeof(BOOL);
    876       if (PrfQueryProfileData(fmprof, appname, "Toolbar", &dummy, &size) &&
    877           size && !dummy)
     872      if (PrfQueryProfileData(fmprof, appname, "Toolbar", &yes, &size) &&
     873          size &&
     874          !yes)
     875      {
    878876        WinSendMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_TOOLBAR, 0), MPVOID);
     877      }
    879878
    880879      size = sizeof(s);
  • trunk/dll/notebook.c

    r1713 r1778  
    178178BOOL fStartMaximized;
    179179BOOL fStartMinimized;
    180 BOOL fSwitchTree;
     180BOOL fSwitchTreeOnDirChg;
    181181BOOL fSwitchTreeExpand;
    182182BOOL fSwitchTreeOnFocus;
     
    13751375    WinCheckButton(hwnd, CFGT_COLLAPSEFIRST, fCollapseFirst);
    13761376    WinCheckButton(hwnd, CFGT_SWITCHTREEONFOCUS, fSwitchTreeOnFocus);
    1377     WinCheckButton(hwnd, CFGT_SWITCHTREE, fSwitchTree);
     1377    WinCheckButton(hwnd, CFGT_SWITCHTREEONDIRCHG, fSwitchTreeOnDirChg);
    13781378    WinCheckButton(hwnd, CFGT_SWITCHTREEEXPAND, fSwitchTreeExpand);
    13791379    WinCheckButton(hwnd, CFGT_SHOWENV, fShowEnv);
     
    14571457      PrfWriteProfileData(fmprof, appname, "SwitchTreeExpand",
    14581458                          &fSwitchTreeExpand, sizeof(BOOL));
    1459       fSwitchTree = WinQueryButtonCheckstate(hwnd, CFGT_SWITCHTREE);
    1460       PrfWriteProfileData(fmprof, appname, "SwitchTree", &fSwitchTree,
     1459      fSwitchTreeOnDirChg = WinQueryButtonCheckstate(hwnd, CFGT_SWITCHTREEONDIRCHG);
     1460      PrfWriteProfileData(fmprof, appname, "SwitchTree", &fSwitchTreeOnDirChg,
    14611461                          sizeof(BOOL));
    14621462      fFollowTree = WinQueryButtonCheckstate(hwnd, CFGT_FOLLOWTREE);
     
    31793179
    31803180    case CFG9_HECTOR:
    3181       fSwitchTree = TRUE;
     3181      fSwitchTreeOnDirChg = TRUE;
    31823182      fSwitchTreeOnFocus = FALSE;
    31833183      fSwitchTreeExpand = TRUE;
     
    32953295
    32963296    case CFG9_DEFAULT:
    3297       fSwitchTree = TRUE;
     3297      fSwitchTreeOnDirChg = TRUE;
    32983298      fSwitchTreeOnFocus = FALSE;
    32993299      fSwitchTreeExpand = TRUE;
     
    34493449      fFollowTree = TRUE;
    34503450      fTopDir = FALSE;
    3451       fSwitchTree = TRUE;
     3451      fSwitchTreeOnDirChg = TRUE;
    34523452      fSwitchTreeOnFocus = FALSE;
    34533453      fSwitchTreeExpand = TRUE;
     
    35133513      fTileBackwards = TRUE;
    35143514      ulCnrType = CCS_MULTIPLESEL;
    3515       fSwitchTree = TRUE;
     3515      fSwitchTreeOnDirChg = TRUE;
    35163516      fSwitchTreeOnFocus = FALSE;
    35173517      fSwitchTreeExpand = TRUE;
     
    35543554        fTileBackwards = FALSE;
    35553555        ulCnrType = CCS_MULTIPLESEL | CCS_EXTENDSEL;
    3556         fSwitchTree = FALSE;
     3556        fSwitchTreeOnDirChg = FALSE;
    35573557        fSwitchTreeOnFocus = FALSE;
    35583558        fSwitchTreeExpand = FALSE;
     
    36113611
    36123612    case CFG9_GREGG:
    3613       fSwitchTree = TRUE;
     3613      fSwitchTreeOnDirChg = TRUE;
    36143614      fSwitchTreeOnFocus = FALSE;
    36153615      fSwitchTreeExpand = TRUE;
  • trunk/dll/notebook.h

    r1711 r1778  
    100100extern BOOL fStartMaximized;
    101101extern BOOL fStartMinimized;
    102 extern BOOL fSwitchTree;
     102extern BOOL fSwitchTreeOnDirChg;
    103103extern BOOL fSwitchTreeExpand;
    104104extern BOOL fSwitchTreeOnFocus;
  • trunk/dll/treecnr.c

    r1771 r1778  
    31643164}
    31653165
     3166/**
     3167 * Start drive tree container
     3168 * @returns tree handle or NULLHANDLE
     3169 */
     3170
    31663171HWND StartTreeCnr(HWND hwndParent, ULONG flags)
    31673172{
     
    32623267      dcd->size = sizeof(DIRCNRDATA);
    32633268      dcd->type = TREE_FRAME;
    3264       dcd->dontclose = ((flags & 1) != 0);
    3265       dcd->hwndParent = (hwndParent) ? hwndParent : HWND_DESKTOP;
     3269      dcd->dontclose = (flags & 1) != 0;
     3270      dcd->hwndParent = hwndParent ? hwndParent : HWND_DESKTOP;
    32663271      dcd->hwndClient = hwndClient;
    32673272      dcd->hwndFrame = hwndFrame;
Note: See TracChangeset for help on using the changeset viewer.