Changeset 751 for trunk/dll/misc.c


Ignore:
Timestamp:
Aug 2, 2007, 11:05:48 PM (13 years ago)
Author:
Steven Levine
Message:

Sync rest of code with CNRITEM mods
Sync code with ARCITEM mods
Get compare dialog working
Still some issues with status display
Still some issues with directory sizes tree display
Heap check diagnostic code mostly enabled

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/dll/misc.c

    r747 r751  
    2626  05 Jul 07 GKY Fix menu removals for WORKPLACE_PROCESS=YES
    2727  23 Jul 07 SHL Sync with CNRITEM updates (ticket#24)
     28  31 Jul 07 SHL Clean up and report errors (ticket#24)
    2829
    2930***********************************************************************/
     
    8384    PIB *ppib;
    8485    TIB *ptib;
    85     APIRET rc;
    86 
    87     rc = DosGetInfoBlocks(&ptib, &ppib);
     86    BOOL yes;
     87    APIRET rc = DosGetInfoBlocks(&ptib, &ppib);
     88
    8889    if (rc) {
    8990      Dos_Error(MB_CANCEL, rc, HWND_DESKTOP, pszSrcFile, __LINE__,
    9091                "DosGetInfoBlocks");
     92      yes = FALSE;
    9193    }
    9294    else {
     
    9496      TID tid;
    9597
    96       if (WinQueryWindowProcess(hwnd, &pid, &tid)) {
    97         if (chkTid) {
    98           // Is window owned by FM2 process on same thread?
    99           if (pid == ppib->pib_ulpid && tid == ptib->tib_ptib2->tib2_ultid)
    100             return TRUE;
    101         }
    102         // Is window owned by some FM2 thread
    103         else if (pid == ppib->pib_ulpid)
    104           return TRUE;
    105       }
    106     }
    107     return FALSE;
     98      // Check window owned by FM2 process
     99      // Check say same thread too, if requested
     100      // OK for window to be dead - just return FALSE
     101      yes = WinQueryWindowProcess(hwnd, &pid, &tid) &&
     102            pid == ppib->pib_ulpid &&
     103            (!chkTid || tid == ptib->tib_ptib2->tib2_ultid);
     104    }
     105    return yes;
    108106}
    109107
     
    381379        !stricmp(FileSystem, JFS) ||
    382380        !stricmp(FileSystem, FAT32) ||
    383         !stricmp(FileSystem, RAMFS) ||
    384         !stricmp(FileSystem, NDFS32) ||
    385         !stricmp(FileSystem, NTFS) ||
    386         !stricmp(FileSystem, HPFS386)) {
     381        !stricmp(FileSystem, RAMFS) ||
     382        !stricmp(FileSystem, NDFS32) ||
     383        !stricmp(FileSystem, NTFS) ||
     384        !stricmp(FileSystem, HPFS386)) {
    387385      hasCreateDT = TRUE;
    388386      hasAccessDT = TRUE;
     
    430428  BOOL *bool;
    431429
    432   bool = (dcd) ? &dcd->detailssubject : &detailssubject;
    433   AdjustCnrColVis(hwndCnr, ((compare) ? GetPString(IDS_STATUS) :
    434                             GetPString(IDS_SUBJ)), *bool, FALSE);
    435   bool = (dcd) ? &dcd->detailsattr : &detailsattr;
     430  bool = dcd ? &dcd->detailssubject : &detailssubject;
     431  AdjustCnrColVis(hwndCnr,
     432                  compare ? GetPString(IDS_STATUS) : GetPString(IDS_SUBJ),
     433                  *bool,
     434                  FALSE);
     435
     436  bool = dcd ? &dcd->detailsattr : &detailsattr;
    436437  AdjustCnrColVis(hwndCnr, GetPString(IDS_ATTR), *bool, FALSE);
    437   bool = (dcd) ? &dcd->detailsicon : &detailsicon;
     438  bool = dcd ? &dcd->detailsicon : &detailsicon;
    438439  AdjustCnrColVis(hwndCnr, GetPString(IDS_ICON), *bool, FALSE);
    439   bool = (dcd) ? &dcd->detailslwdate : &detailslwdate;
     440  bool = dcd ? &dcd->detailslwdate : &detailslwdate;
    440441  AdjustCnrColVis(hwndCnr, GetPString(IDS_LWDATE), *bool, FALSE);
    441   bool = (dcd) ? &dcd->detailslwtime : &detailslwtime;
     442  bool = dcd ? &dcd->detailslwtime : &detailslwtime;
    442443  AdjustCnrColVis(hwndCnr, GetPString(IDS_LWTIME), *bool, FALSE);
    443   bool = (dcd) ? &dcd->detailsea : &detailsea;
     444  bool = dcd ? &dcd->detailsea : &detailsea;
    444445  AdjustCnrColVis(hwndCnr, GetPString(IDS_EA), *bool, FALSE);
    445   bool = (dcd) ? &dcd->detailssize : &detailssize;
     446  bool = dcd ? &dcd->detailssize : &detailssize;
    446447  AdjustCnrColVis(hwndCnr, GetPString(IDS_SIZE), *bool, FALSE);
     448
    447449  if (!directory) {
    448     bool = (dcd) ? &dcd->detailsladate : &detailsladate;
     450    bool = dcd ? &dcd->detailsladate : &detailsladate;
    449451    AdjustCnrColVis(hwndCnr, GetPString(IDS_LADATE), *bool, FALSE);
    450     bool = (dcd) ? &dcd->detailslatime : &detailslatime;
     452    bool = dcd ? &dcd->detailslatime : &detailslatime;
    451453    AdjustCnrColVis(hwndCnr, GetPString(IDS_LATIME), *bool, FALSE);
    452     bool = (dcd) ? &dcd->detailscrdate : &detailscrdate;
     454    bool = dcd ? &dcd->detailscrdate : &detailscrdate;
    453455    AdjustCnrColVis(hwndCnr, GetPString(IDS_CRDATE), *bool, FALSE);
    454     bool = (dcd) ? &dcd->detailscrtime : &detailscrtime;
     456    bool = dcd ? &dcd->detailscrtime : &detailscrtime;
    455457    AdjustCnrColVis(hwndCnr, GetPString(IDS_CRTIME), *bool, FALSE);
    456     bool = (dcd) ? &dcd->detailslongname : &detailslongname;
     458    bool = dcd ? &dcd->detailslongname : &detailslongname;
    457459    AdjustCnrColVis(hwndCnr, GetPString(IDS_LNAME), *bool, FALSE);
    458460    WinSendMsg(hwndCnr, CM_INVALIDATEDETAILFIELDINFO, MPVOID, MPVOID);
     
    462464}
    463465
    464 BOOL SetCnrCols(HWND hwndCnr, BOOL compare)
     466BOOL SetCnrCols(HWND hwndCnr, BOOL isCompCnr)
    465467{
    466468  BOOL fSuccess = TRUE;
     
    472474                   MPFROMLONG(CONTAINER_COLUMNS), NULL);
    473475
    474   if (pfi) {
     476  if (!pfi) {
     477    Win_Error(hwndCnr, HWND_DESKTOP, pszSrcFile, __LINE__, "CM_ALLOCDETAILFIELDINFO");
     478    fSuccess = FALSE;
     479  }
     480  else {
    475481
    476482    PFIELDINFO pfiFirst;
     
    518524    pfi = pfi->pNextFieldInfo;
    519525    pfi->flData = CFA_STRING | CFA_LEFT | CFA_SEPARATOR;
    520     if (compare)
     526    if (isCompCnr)
    521527      pfi->flData |= CFA_FIREADONLY;
    522528    pfi->flTitle = CFA_CENTER | CFA_FITITLEREADONLY;
    523     pfi->pTitleData = (compare) ? GetPString(IDS_STATUS) :
     529    pfi->pTitleData = (isCompCnr) ? GetPString(IDS_STATUS) :
    524530      GetPString(IDS_SUBJ);
    525531    pfi->offStruct = FIELDOFFSET(CNRITEM, pszSubject);
     
    610616
    611617    if (!WinSendMsg(hwndCnr, CM_INSERTDETAILFIELDINFO, MPFROMP(pfiFirst),
    612                     MPFROMP(&fii)))
     618                    MPFROMP(&fii))) {
     619      Win_Error(hwndCnr, HWND_DESKTOP, pszSrcFile, __LINE__, "CM_INSERTDETAILFIELDINFO");
    613620      fSuccess = FALSE;
    614   }
    615   else
    616     fSuccess = FALSE;
     621    }
     622  }
    617623
    618624  if (fSuccess) {
     
    634640    if (!WinSendMsg(hwndCnr, CM_SETCNRINFO, MPFROMP(&cnri),
    635641                    MPFROMLONG(CMA_PFIELDINFOLAST | CMA_PFIELDINFOOBJECT |
    636                                CMA_XVERTSPLITBAR)))
     642                               CMA_XVERTSPLITBAR))) {
     643      Win_Error(hwndCnr, HWND_DESKTOP, pszSrcFile, __LINE__, "CM_SETCNRINFO");
    637644      fSuccess = FALSE;
     645    }
    638646  }
    639647
     
    682690          ULONG ealen;
    683691          USHORT len;
    684           CHAR *eaval;
    685           LONG retlen;
     692          CHAR *eaval;
     693          LONG retlen;
    686694
    687695          retlen = WinQueryWindowText(hwndMLE, sizeof(szSubject), szSubject);
     
    733741
    734742          CHAR longname[CCHMAXPATHCOMP];
    735         LONG retlen;
     743        LONG retlen;
    736744
    737745          *longname = 0;
     
    739747          longname[retlen + 1] = 0;
    740748          chop_at_crnl(longname);
    741           WinSetWindowText(hwndMLE, longname);
    742           pci->pszFileName = xrealloc(pci->pszFileName, sizeof(longname), pszSrcFile, __LINE__);
     749          WinSetWindowText(hwndMLE, longname);
     750          pci->pszFileName = xrealloc(pci->pszFileName, sizeof(longname), pszSrcFile, __LINE__);
    743751          return (MRESULT) WriteLongName(pci->pszFileName, longname);
    744752        }
    745         else {
    746           pci->pszFileName = pci->pszDisplayName;
    747           WinQueryWindowText(hwndMLE, sizeof(szData), szData);
    748           pci->pszFileName = xrealloc(pci->pszFileName, sizeof(szData), pszSrcFile, __LINE__);
     753        else {
     754          pci->pszFileName = pci->pszDisplayName;
     755          WinQueryWindowText(hwndMLE, sizeof(szData), szData);
     756          pci->pszFileName = xrealloc(pci->pszFileName, sizeof(szData), pszSrcFile, __LINE__);
    749757          if (strchr(szData, '?') ||
    750758              strchr(szData, '*') || IsRoot(pci->pszFileName))
    751759            return (MRESULT) FALSE;
    752           /* If the text changed, rename the file system object. */
     760          /* If the text changed, rename the file system object. */
    753761          chop_at_crnl(szData);
    754           bstrip(szData);
     762          bstrip(szData);
    755763          if (!IsFullName(szData))
    756764            Runtime_Error(pszSrcFile, __LINE__, "bad name");
     
    759767                                 FIL_QUERYFULLNAME,
    760768                                 testname, sizeof(testname)))
    761                 return FALSE;
     769                return FALSE;
    762770            if (DosQueryPathInfo(pci->pszFileName,
    763771                                 FIL_QUERYFULLNAME, szData, sizeof(szData)))
     
    936944{
    937945  WinCheckMenuItem(hwnd, IDM_SHOWLNAMES,
    938                    (dcd) ? dcd->detailslongname : detailslongname);
     946                   dcd ? dcd->detailslongname : detailslongname);
    939947  WinCheckMenuItem(hwnd, IDM_SHOWSUBJECT,
    940                    (dcd) ? dcd->detailssubject : detailssubject);
    941   WinCheckMenuItem(hwnd, IDM_SHOWEAS, (dcd) ? dcd->detailsea : detailsea);
     948                   dcd ? dcd->detailssubject : detailssubject);
     949  WinCheckMenuItem(hwnd, IDM_SHOWEAS, dcd ? dcd->detailsea : detailsea);
    942950  WinCheckMenuItem(hwnd, IDM_SHOWSIZE,
    943                    (dcd) ? dcd->detailssize : detailssize);
     951                   dcd ? dcd->detailssize : detailssize);
    944952  WinCheckMenuItem(hwnd, IDM_SHOWICON,
    945                    (dcd) ? dcd->detailsicon : detailsicon);
     953                   dcd ? dcd->detailsicon : detailsicon);
    946954  WinCheckMenuItem(hwnd, IDM_SHOWLWDATE,
    947                    (dcd) ? dcd->detailslwdate : detailslwdate);
     955                   dcd ? dcd->detailslwdate : detailslwdate);
    948956  WinCheckMenuItem(hwnd, IDM_SHOWLWTIME,
    949                    (dcd) ? dcd->detailslwtime : detailslwtime);
     957                   dcd ? dcd->detailslwtime : detailslwtime);
    950958  WinCheckMenuItem(hwnd, IDM_SHOWLADATE,
    951                    (dcd) ? dcd->detailsladate : detailsladate);
     959                   dcd ? dcd->detailsladate : detailsladate);
    952960  WinCheckMenuItem(hwnd, IDM_SHOWLATIME,
    953                    (dcd) ? dcd->detailslatime : detailslatime);
     961                   dcd ? dcd->detailslatime : detailslatime);
    954962  WinCheckMenuItem(hwnd, IDM_SHOWCRDATE,
    955                    (dcd) ? dcd->detailscrdate : detailscrdate);
     963                   dcd ? dcd->detailscrdate : detailscrdate);
    956964  WinCheckMenuItem(hwnd, IDM_SHOWCRTIME,
    957                    (dcd) ? dcd->detailscrtime : detailscrtime);
     965                   dcd ? dcd->detailscrtime : detailscrtime);
    958966  WinCheckMenuItem(hwnd, IDM_SHOWATTR,
    959                    (dcd) ? dcd->detailsattr : detailsattr);
     967                   dcd ? dcd->detailsattr : detailsattr);
    960968}
    961969
     
    975983  switch (cmd) {
    976984  case IDM_SHOWLNAMES:
    977     bool = (dcd) ? &dcd->detailslongname : &detailslongname;
     985    bool = dcd ? &dcd->detailslongname : &detailslongname;
    978986    strcpy(eos, "DetailsLongname");
    979987    break;
    980988  case IDM_SHOWSUBJECT:
    981     bool = (dcd) ? &dcd->detailssubject : &detailssubject;
     989    bool = dcd ? &dcd->detailssubject : &detailssubject;
    982990    strcpy(eos, "DetailsSubject");
    983991    break;
    984992  case IDM_SHOWEAS:
    985     bool = (dcd) ? &dcd->detailsea : &detailsea;
     993    bool = dcd ? &dcd->detailsea : &detailsea;
    986994    strcpy(eos, "DetailsEA");
    987995    break;
    988996  case IDM_SHOWSIZE:
    989     bool = (dcd) ? &dcd->detailssize : &detailssize;
     997    bool = dcd ? &dcd->detailssize : &detailssize;
    990998    strcpy(eos, "DetailsSize");
    991999    break;
    9921000  case IDM_SHOWICON:
    993     bool = (dcd) ? &dcd->detailsicon : &detailsicon;
     1001    bool = dcd ? &dcd->detailsicon : &detailsicon;
    9941002    strcpy(eos, "DetailsIcon");
    9951003    break;
    9961004  case IDM_SHOWLWDATE:
    997     bool = (dcd) ? &dcd->detailslwdate : &detailslwdate;
     1005    bool = dcd ? &dcd->detailslwdate : &detailslwdate;
    9981006    strcpy(eos, "DetailsLWDate");
    9991007    break;
    10001008  case IDM_SHOWLWTIME:
    1001     bool = (dcd) ? &dcd->detailslwtime : &detailslwtime;
     1009    bool = dcd ? &dcd->detailslwtime : &detailslwtime;
    10021010    strcpy(eos, "DetailsLWTime");
    10031011    break;
    10041012  case IDM_SHOWLADATE:
    1005     bool = (dcd) ? &dcd->detailsladate : &detailsladate;
     1013    bool = dcd ? &dcd->detailsladate : &detailsladate;
    10061014    strcpy(eos, "DetailsLADate");
    10071015    break;
    10081016  case IDM_SHOWLATIME:
    1009     bool = (dcd) ? &dcd->detailslatime : &detailslatime;
     1017    bool = dcd ? &dcd->detailslatime : &detailslatime;
    10101018    strcpy(eos, "DetailsLATime");
    10111019    break;
    10121020  case IDM_SHOWCRDATE:
    1013     bool = (dcd) ? &dcd->detailscrdate : &detailscrdate;
     1021    bool = dcd ? &dcd->detailscrdate : &detailscrdate;
    10141022    strcpy(eos, "DetailsCRDate");
    10151023    break;
    10161024  case IDM_SHOWCRTIME:
    1017     bool = (dcd) ? &dcd->detailscrtime : &detailscrtime;
     1025    bool = dcd ? &dcd->detailscrtime : &detailscrtime;
    10181026    strcpy(eos, "DetailsCRTime");
    10191027    break;
    10201028  case IDM_SHOWATTR:
    1021     bool = (dcd) ? &dcd->detailsattr : &detailsattr;
     1029    bool = dcd ? &dcd->detailsattr : &detailsattr;
    10221030    strcpy(eos, "DetailsAttr");
    10231031    break;
     
    13841392      // If window owned by some other process or some other thread?
    13851393      if (!IsFm2Window(h, 1)) {
    1386           QMSG qmsg;
     1394          QMSG qmsg;
    13871395          for (;;) {
    13881396            DosSleep(1);
Note: See TracChangeset for help on using the changeset viewer.