Changeset 1891 for trunk


Ignore:
Timestamp:
Jan 31, 2020, 3:47:37 AM (6 years ago)
Author:
Steven Levine
Message:

Rework FreeCnrItem to ensure all CNRITEMs deleted.
Use WinSendMsg CMA_NEXT.
Was using preccNextRecord which is not recommended because control does
not maintain linkage after inserts and deletes.
Note: arccnrs.c still needs to be reworked to use common functions from filldir.c.

Location:
trunk/dll
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/dll/comp.c

    r1878 r1891  
    66  Compare directories
    77
    8   Copyright (c) 1993-02 M. Kimes
    9   Copyright (c) 2003, 2013 Steven H. Levine
     8  Copyright (c) 1993-2002 M. Kimes
     9  Copyright (c) 2003-2020 Steven H. Levine
    1010
    1111  16 Oct 02 MK Baseline
     
    8989  09 Mar 13 SHL SetButtonEnables: correct enable support for newish buttons
    9090  10 Mar 13 GKY Improvrd readonly check on delete to allow cancel and don't ask again options
    91                 Added saymsg2 for this purpose
     91                Added saymsg2 for this purpose
    9292  10 Mar 13 GKY Fixes to snapshot file.
    9393  14 Jun 15 GKY Changes to prvenet access violations when cmp is freed
     94  28 Jan 20 SHL ActionCnrThread: report CM_INVALIDATERECORD failures
    9495
    9596***********************************************************************/
     
    150151#include "excputil.h"                   // xbeginthread
    151152#include "info.h"                       // driveflags
    152 #include "worker.h"                     // MOVEIT
    153 #include "rename.h"                     // RenameProc
     153#include "worker.h"                     // MOVEIT
     154#include "rename.h"                     // RenameProc
    154155
    155156typedef struct
     
    177178  HDIR hdir = HDIR_CREATE;
    178179  ULONG ulFindCnt;
    179   //CHAR szDate[DATE_BUF_BYTES];
    180 
    181   // 13 Aug 07 SHL fixme to use FileToGet
     180  // CHAR szDate[DATE_BUF_BYTES];
     181
     182  // 13 Aug 07 SHL FIXME to use FileToGet
    182183  pffb = xmalloc(sizeof(FILEFINDBUF4L), pszSrcFile, __LINE__);
    183184  if (pffb) {
     
    188189      enddir++;
    189190      ulFindCnt = 1;
    190       // 13 Aug 07 SHL fixme to report errors
     191      // 13 Aug 07 SHL FIXME to report errors
    191192      if (!xDosFindFirst(mask,
    192193                         &hdir,
     
    198199          strcpy(enddir, pffb->achName);
    199200          if (!(pffb->attrFile & FILE_DIRECTORY)) {
    200             //FDateFormat(szDate, pffb->fdateLastWrite);
     201            // FDateFormat(szDate, pffb->fdateLastWrite);
    201202            fprintf(fp,
    202                     "\"%s\",%u,%llu,%lu/%lu/%lu,%02u:%02u:%02u,%lu,%lu,N\n",
     203                    "\"%s\",%u,%llu,%lu/%lu/%lu,%02u:%02u:%02u,%lu,%lu,N\n",
    203204                    mask,
    204205                    enddir - mask,
    205                     pffb->cbFile,
    206                     pffb->fdateLastWrite.year + 1980,
    207                     pffb->fdateLastWrite.month,
    208                     pffb->fdateLastWrite.day,
     206                    pffb->cbFile,
     207                    pffb->fdateLastWrite.year + 1980,
     208                    pffb->fdateLastWrite.month,
     209                    pffb->fdateLastWrite.day,
    209210                    pffb->ftimeLastWrite.hours,
    210211                    pffb->ftimeLastWrite.minutes,
     
    572573                       MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER));
    573574      pciD = WinSendMsg(hwndCnrD, CM_QUERYRECORD, MPVOID,
    574                         MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER));
    575       fConfirmAction =  WinQueryButtonCheckstate(cmp->hwnd, COMP_CONFIRMACTION);
     575                        MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER));
     576      fConfirmAction = WinQueryButtonCheckstate(cmp->hwnd, COMP_CONFIRMACTION);
    576577      InitITimer(&itdSleep, 500);       // Sleep every 500 mSec
    577578
     
    595596          case IDM_DELETE:
    596597
    597             if (fConfirmAction && !dontask) {
    598               rc = saymsg2(NULL, 0, cmp->hwnd, GetPString(IDS_CONFIRMDELETE), GetPString(IDS_DOYOUWISHTODELETE),
    599                            pciS->pszFileName);
    600               if (rc == 3 || rc == 4) {       
    601                 if (rc == 4)
    602                   enddelete = TRUE;
    603                 break;
    604               }
    605               else if (rc == 2)
    606                 dontask = TRUE;
    607             }
     598            if (fConfirmAction && !dontask) {
     599              rc = saymsg2(NULL, 0, cmp->hwnd, GetPString(IDS_CONFIRMDELETE), GetPString(IDS_DOYOUWISHTODELETE),
     600                           pciS->pszFileName);
     601              if (rc == 3 || rc == 4) {
     602                if (rc == 4)
     603                  enddelete = TRUE;
     604                break;
     605              }
     606              else if (rc == 2)
     607                dontask = TRUE;
     608            }
     609
    608610            if (!unlinkf(pciS->pszFileName)) {
    609611              WinSendMsg(hwndCnrS, CM_SETRECORDEMPHASIS, MPFROMP(pciS),
     
    612614              if (!*pciD->pszFileName) {
    613615                // Other side is blank - remove from both sides
     616
     617#               ifdef PMPRINTF
     618                PmPrintf_Report(pszSrcFile, __LINE__, "ActionCnrThread RemoveCnrItems pciS %p", pciS);
     619#               endif
     620
    614621                RemoveCnrItems(hwndCnrS, pciS, 1, CMA_FREE | CMA_INVALIDATE);
    615622                if (pciD->rc.flRecordAttr & CRA_SELECTED)
    616623                  WinSendMsg(hwndCnrD, CM_SETRECORDEMPHASIS, MPFROMP(pciD),
    617624                             MPFROM2SHORT(FALSE, CRA_SELECTED));
     625
     626#               ifdef PMPRINTF
     627                PmPrintf_Report(pszSrcFile, __LINE__, "ActionCnrThread RemoveCnrItems pciD %p", pciD);
     628#               endif
     629
    618630                RemoveCnrItems(hwndCnrD, pciD, 1, CMA_FREE | CMA_INVALIDATE);
    619631              }
    620632              else {
    621633                // Other side is not blank - blank just this side
     634
     635#               ifdef PMPRINTF
     636                PmPrintf_Report(pszSrcFile, __LINE__, "ActionCnrThread FreeCnrItemData pciS %p", pciS);
     637#               endif
     638
    622639                FreeCnrItemData(pciS);
    623640                // 29 Aug 08 SHL Point pci fields at NullStr to sync with FreeCnrItemData mods
     
    626643                pciS->rc.pszIcon = pciS->pszFileName;
    627644                pciS->flags = 0;        // Just on one side
    628                 WinSendMsg(hwndCnrS, CM_INVALIDATERECORD, MPFROMP(&pciS),
    629                            MPFROM2SHORT(1, CMA_ERASE | CMA_TEXTCHANGED));
    630                   pciD->flags = 0;      // Just on one side
    631                   if (pciD->pszSubject != NullStr) {
    632                     xfree(pciD->pszSubject, pszSrcFile, __LINE__);
    633                     pciD->pszSubject = NullStr;
    634                   }
    635                 }
     645                if (!WinSendMsg(hwndCnrS, CM_INVALIDATERECORD, MPFROMP(&pciS),
     646                                MPFROM2SHORT(1, CMA_ERASE | CMA_TEXTCHANGED))) {
     647                  Win_Error(hwndCnrS, cmp->hwnd, pszSrcFile, __LINE__, "CM_INVALIDATERECORD");
     648                }
     649
     650                pciD->flags = 0;        // Just on one side
     651                if (pciD->pszSubject != NullStr) {
     652                  xfree(pciD->pszSubject, pszSrcFile, __LINE__);
     653                  pciD->pszSubject = NullStr;
     654                }
     655              }
     656
    636657              if (hwndCnrS == WinWindowFromID(cmp->hwnd, COMP_LEFTDIR))
    637658                cmp->cmp->totalleft--;
     
    639660                cmp->cmp->totalright--;
    640661            }
    641             break;
     662            break; // IDM_DELETE
    642663
    643664          case IDM_MOVE:
     
    702723                pciD->attrFile = pciS->attrFile;
    703724                pciD->pszDispAttr = pciS->pszDispAttr;
    704                 pciD->flags = 0;                // Just on one side
     725                pciD->flags = 0;        // Just on one side
    705726                pciD->date = pciS->date;
    706727                pciD->time = pciS->time;
     
    727748                  pciS->pszSubject = NullStr;
    728749                }
    729                 pciS->flags = 0;                // Just on one side
    730 
    731                 WinSendMsg(hwndCnrS, CM_INVALIDATERECORD, MPFROMP(&pciS),
    732                            MPFROM2SHORT(1, CMA_ERASE | CMA_TEXTCHANGED));
    733 
    734                 WinSendMsg(hwndCnrD, CM_INVALIDATERECORD, MPFROMP(&pciD),
    735                            MPFROM2SHORT(1, CMA_ERASE | CMA_TEXTCHANGED));
     750                pciS->flags = 0;        // Just on one side
     751
     752                if (!WinSendMsg(hwndCnrS, CM_INVALIDATERECORD, MPFROMP(&pciS),
     753                           MPFROM2SHORT(1, CMA_ERASE | CMA_TEXTCHANGED))) {
     754                  Win_Error(hwndCnrS, cmp->hwnd, pszSrcFile, __LINE__, "CM_INVALIDATERECORD");
     755                }
     756
     757                if (!WinSendMsg(hwndCnrD, CM_INVALIDATERECORD, MPFROMP(&pciD),
     758                           MPFROM2SHORT(1, CMA_ERASE | CMA_TEXTCHANGED))) {
     759                  Win_Error(hwndCnrD, cmp->hwnd, pszSrcFile, __LINE__, "CM_INVALIDATERECORD");
     760                }
    736761
    737762                if (hwndCnrS == WinWindowFromID(cmp->hwnd, COMP_LEFTDIR))
     
    868893        SleepIfNeeded(&itdSleep, 0);
    869894      } // while
     895
    870896      WinPostMsg(cmp->hwnd, WM_TIMER, MPFROMLONG(ID_COMP_TIMER), 0);    // Force update
    871897    Abort:
     
    10771103
    10781104  if (numD != x) {
    1079     // Something out of sync - fixme to document why slow logic needed
     1105    // Something out of sync - FIXME to document why slow logic needed
    10801106    if (!slow) {
    10811107      slow = TRUE;
     
    12021228                  else if (memcmp(buf1, buf2, numread1))
    12031229                    break;
    1204                 }       // while
     1230                } // while
    12051231              } // same len
    12061232            } // if open ok
     
    13151341        pciD = pciDa[x];
    13161342        CompSelectSetSelects(pciS,
    1317                              pciD,
    1318                              pciS->flags & CNRITEM_EASDIFFER,
    1319                              pciD->flags & CNRITEM_EASDIFFER,
    1320                              wantAnd);
     1343                             pciD,
     1344                             pciS->flags & CNRITEM_EASDIFFER,
     1345                             pciD->flags & CNRITEM_EASDIFFER,
     1346                             wantAnd);
    13211347      }
    13221348      SleepIfNeeded(&itdSleep, 0);
     
    15961622
    15971623# ifdef FORTIFY
    1598   // 10 May 08 SHL fixme to suppress W111
     1624  // 10 May 08 SHL FIXME to suppress W111
    15991625  Fortify_EnterScope();
    16001626#  endif
     
    16031629    Runtime_Error(pszSrcFile, __LINE__, NULL);
    16041630#   ifdef FORTIFY
    1605     // 10 May 08 SHL fixme to suppress W111
     1631    // 10 May 08 SHL FIXME to suppress W111
    16061632    Fortify_LeaveScope();
    16071633#    endif
     
    16481674        lenr++;
    16491675      priority_normal();
    1650       // Clear containers
     1676      // Clear containers in case restarting
    16511677      RemoveCnrItems(hwndRight, NULL, 0, CMA_FREE | CMA_INVALIDATE);
    16521678      RemoveCnrItems(hwndLeft, NULL, 0, CMA_FREE | CMA_INVALIDATE);
     
    16781704        CHAR str[CCHMAXPATH * 2], *p;
    16791705        CHAR *moder = "r";
    1680         BOOL fFixedSnap = TRUE;
     1706        BOOL fFixedSnap = TRUE;
    16811707
    16821708        memset(&fb4, 0, sizeof(fb4));
     
    17441770                      p = strchr(p, ',');
    17451771                      if (p) {
    1746                         p++;
    1747                         if (((strchr(p, '/') ? strchr(p, '/') : strchr(p, DateSeparator[0])) - strchr(p, ',')) > 5) {
    1748                           CHAR szTemp[30];
    1749                           CHAR *q;
    1750                           int i;
    1751 
    1752                           memset(szTemp, 0, sizeof(szTemp));
    1753                           i = (strchr(p, '/') ? strchr(p, '/') : strchr(p, DateSeparator[0])) - 3 - p;
    1754                           strncpy(&szTemp, p, i);
    1755                           for (q = szTemp; q = strchr(szTemp, ',');) {
    1756                             strcpy(q, q + 1);
    1757                           }
    1758                           fb4.cbFile = atoll(szTemp);
    1759                           fFixedSnap = FALSE;
    1760 
    1761                         }
    1762                         else
    1763                           fb4.cbFile = atoll(p);
    1764                         if (!strchr(p, '/'))
    1765                           fFixedSnap = FALSE;
    1766                         p = (strchr(p, '/') ? strchr(p, '/') : strchr(p, DateSeparator[0])) - 6;
    1767                         p = strchr(p, ',');
    1768                         if (p) {
    1769                           p++;
    1770                           if (ulDateFmt == 2 || ulDateFmt == 3 || fFixedSnap)
    1771                             fb4.fdateLastWrite.year = atol(p) - 1980;
    1772                           else if (ulDateFmt == 1)
    1773                             fb4.fdateLastWrite.day = atol(p);
    1774                           else
    1775                             fb4.fdateLastWrite.month = atol(p);
    1776                           p = strchr(p, '/') ? strchr(p, '/') : strchr(p, DateSeparator[0]);
    1777                           if (p) {
    1778                             p++;
    1779                             if (ulDateFmt == 2 || ulDateFmt == 1 || fFixedSnap)
    1780                               fb4.fdateLastWrite.month = atol(p);
    1781                             else
    1782                               fb4.fdateLastWrite.day = atol(p);
    1783                             p = strchr(p, '/') ?  strchr(p, '/') : strchr(p, DateSeparator[0]);
    1784                             if (p) {
    1785                               p++;
    1786                               if (ulDateFmt == 2 || fFixedSnap)
    1787                                 fb4.fdateLastWrite.day = atol(p);
    1788                               else if (ulDateFmt == 3)
    1789                                 fb4.fdateLastWrite.month = atol(p);
    1790                               else
    1791                                 fb4.fdateLastWrite.year = atol(p) - 1980;
     1772                        p++;
     1773                        if (((strchr(p, '/') ? strchr(p, '/') : strchr(p, DateSeparator[0])) - strchr(p, ',')) > 5) {
     1774                          CHAR szTemp[30];
     1775                          CHAR *q;
     1776                          int i;
     1777
     1778                          memset(szTemp, 0, sizeof(szTemp));
     1779                          i = (strchr(p, '/') ? strchr(p, '/') : strchr(p, DateSeparator[0])) - 3 - p;
     1780                          strncpy(&szTemp, p, i);
     1781                          for (q = szTemp; q = strchr(szTemp, ',');) {
     1782                            strcpy(q, q + 1);
     1783                          }
     1784                          fb4.cbFile = atoll(szTemp);
     1785                          fFixedSnap = FALSE;
     1786
     1787                        }
     1788                        else
     1789                          fb4.cbFile = atoll(p);
     1790                        if (!strchr(p, '/'))
     1791                          fFixedSnap = FALSE;
     1792                        p = (strchr(p, '/') ? strchr(p, '/') : strchr(p, DateSeparator[0])) - 6;
     1793                        p = strchr(p, ',');
     1794                        if (p) {
     1795                          p++;
     1796                          if (ulDateFmt == 2 || ulDateFmt == 3 || fFixedSnap)
     1797                            fb4.fdateLastWrite.year = atol(p) - 1980;
     1798                          else if (ulDateFmt == 1)
     1799                            fb4.fdateLastWrite.day = atol(p);
     1800                          else
     1801                            fb4.fdateLastWrite.month = atol(p);
     1802                          p = strchr(p, '/') ? strchr(p, '/') : strchr(p, DateSeparator[0]);
     1803                          if (p) {
     1804                            p++;
     1805                            if (ulDateFmt == 2 || ulDateFmt == 1 || fFixedSnap)
     1806                              fb4.fdateLastWrite.month = atol(p);
     1807                            else
     1808                              fb4.fdateLastWrite.day = atol(p);
     1809                            p = strchr(p, '/') ? strchr(p, '/') : strchr(p, DateSeparator[0]);
     1810                            if (p) {
     1811                              p++;
     1812                              if (ulDateFmt == 2 || fFixedSnap)
     1813                                fb4.fdateLastWrite.day = atol(p);
     1814                              else if (ulDateFmt == 3)
     1815                                fb4.fdateLastWrite.month = atol(p);
     1816                              else
     1817                                fb4.fdateLastWrite.year = atol(p) - 1980;
    17921818                              p = strchr(p, ',');
    1793                               if (p) {
     1819                              if (p) {
    17941820                                p++;
    17951821                                fb4.ftimeLastWrite.hours = atol(p);
    1796                                 p = strchr(p, ':') ? strchr(p, ':') : strchr(p, TimeSeparator[0]);
    1797                                 if (p) {
     1822                                p = strchr(p, ':') ? strchr(p, ':') : strchr(p, TimeSeparator[0]);
     1823                                if (p) {
    17981824                                  p++;
    17991825                                  fb4.ftimeLastWrite.minutes = atol(p);
    1800                                   p = strchr(p, ':') ? strchr(p, ':') : strchr(p, TimeSeparator[0]);
    1801                                   if (p) {
     1826                                  p = strchr(p, ':') ? strchr(p, ':') : strchr(p, TimeSeparator[0]);
     1827                                  if (p) {
    18021828                                    p++;
    18031829                                    fb4.ftimeLastWrite.twosecs = atol(p);
    18041830                                    p = strchr(p, ',');
    1805                                     if (p) {
     1831                                    if (p) {
    18061832                                      p++;
    18071833                                      fb4.attrFile = atol(p);
    18081834                                      p = strchr(p, ',');
    1809                                       if (p) {
     1835                                      if (p) {
    18101836                                        p++;
    18111837                                        fb4.cbList = atol(p) * 2;
     
    18131839                                          strupr(str + 1);
    18141840                                        else if (fForceLower)
    1815                                           strlwr(str + 1);
     1841                                          strlwr(str + 1);
    18161842                                        if (AddToFileList((str + 1) + lenr,
    18171843                                                          &fb4,
     
    18351861            } // while
    18361862          } // if have rightdir
    1837           fclose(fp);
    1838           if (!filesr)
    1839             saymsg(MB_OK | MB_ICONASTERISK, HWND_DESKTOP,
     1863          fclose(fp);
     1864          if (!filesr)
     1865            saymsg(MB_OK | MB_ICONASTERISK, HWND_DESKTOP,
    18401866                   GetPString(IDS_WARNINGTEXT),
    18411867                   GetPString(IDS_SNAPSHOTFILEBADFORMAT));
    1842         }
    1843         else
    1844           saymsg(MB_OK | MB_ICONASTERISK, HWND_DESKTOP,
    1845                 GetPString(IDS_WARNINGTEXT),
    1846                 GetPString(IDS_SNAPSHOTFILELOADFAILED), cmp->rightlist);
     1868        }
     1869        else
     1870          saymsg(MB_OK | MB_ICONASTERISK, HWND_DESKTOP,
     1871                GetPString(IDS_WARNINGTEXT),
     1872                GetPString(IDS_SNAPSHOTFILELOADFAILED), cmp->rightlist);
    18471873      } // if snapshot file
    18481874
     
    19051931        while ((filesl && filesl[l]) || (filesr && filesr[r])) {
    19061932
    1907           ULONG ulRecsToInsert; // limited to USHRT_MAX
     1933          ULONG ulRecsToInsert;         // limited to USHRT_MAX
    19081934
    19091935          if (cmp->stop)
     
    19711997            pcil->pszDispAttr = FileAttrToString(pcil->attrFile);
    19721998            pcil->cbFile = filesl[l]->cbFile;
    1973             // 12 Jan 08 SHL fixme to use cached size here too
     1999            // 12 Jan 08 SHL FIXME to use cached size here too
    19742000            CommaFmtULL(szBuf, sizeof(szBuf), pcil->cbFile, ' ');
    19752001            pcil->pszFmtFileSize = xstrdup(szBuf, pszSrcFile, __LINE__);
     
    19922018            pcil->crtime.seconds = filesl[l]->crtime.twosecs * 2;
    19932019            pcil->crtime.minutes = filesl[l]->crtime.minutes;
    1994             pcil->crtime.hours = filesl[l]->crtime.hours;
    1995             DosRequestMutexSem(hmtxFiltering, SEM_INDEFINITE_WAIT);
     2020            pcil->crtime.hours = filesl[l]->crtime.hours;
     2021            DosRequestMutexSem(hmtxFiltering, SEM_INDEFINITE_WAIT);
    19962022            if (cmp && *cmp->dcd.mask.szMask) {
    19972023              if (!Filter((PMINIRECORDCORE)pcil, (PVOID)&cmp->dcd.mask)) {
    19982024                pcil->rc.flRecordAttr |= CRA_FILTERED;
    19992025                pcir->rc.flRecordAttr |= CRA_FILTERED;
    2000               }
    2001             }
    2002             DosReleaseMutexSem(hmtxFiltering);
     2026              }
     2027            }
     2028            DosReleaseMutexSem(hmtxFiltering);
    20032029          } // if on left
    20042030
     
    20132039            pcir->pszDispAttr = FileAttrToString(pcir->attrFile);
    20142040            pcir->cbFile = filesr[r]->cbFile;
    2015             // 12 Jan 08 SHL fixme to used cached size here too
     2041            // 12 Jan 08 SHL FIXME to used cached size here too
    20162042            CommaFmtULL(szBuf, sizeof(szBuf), pcir->cbFile, ' ');
    20172043            pcir->pszFmtFileSize = xstrdup(szBuf, pszSrcFile, __LINE__);
     
    20352061            pcir->crtime.minutes = filesr[r]->crtime.minutes;
    20362062            pcir->crtime.hours = filesr[r]->crtime.hours;
    2037             // Bypass check if already filtered on left side
    2038             DosRequestMutexSem(hmtxFiltering, SEM_INDEFINITE_WAIT);
     2063            // Bypass check if already filtered on left side
     2064            DosRequestMutexSem(hmtxFiltering, SEM_INDEFINITE_WAIT);
    20392065            if (cmp && ~pcir->rc.flRecordAttr & CRA_FILTERED &&
    20402066                *cmp->dcd.mask.szMask) {
     
    20422068                pcil->rc.flRecordAttr |= CRA_FILTERED;
    20432069                pcir->rc.flRecordAttr |= CRA_FILTERED;
    2044               }
    2045             }
    2046             DosReleaseMutexSem(hmtxFiltering);
     2070              }
     2071            }
     2072            DosReleaseMutexSem(hmtxFiltering);
    20472073          } // if on right
    20482074
     
    21812207                            MPFROMP(pcirFirst), MPFROMP(&ri))) {
    21822208              Win_Error(hwndRight, cmp->hwnd, pszSrcFile, __LINE__, "CM_INSERTRECORD");
    2183               // 2011-05-29 SHL fixme?
     2209              // 2011-05-29 SHL FIXME?
    21842210              RemoveCnrItems(hwndLeft, NULL, 0, CMA_FREE | CMA_INVALIDATE);
    21852211              FreeCnrItemList(hwndRight, pcirFirst);
     
    23182344  WinEnableWindow(WinWindowFromID(hwnd, IDM_SELECTONE), fEnable);
    23192345  WinEnableWindow(WinWindowFromID(hwnd, IDM_SELECTNEWER), fEnable);
    2320   WinEnableWindow(WinWindowFromID(hwnd, IDM_SELECTEAS), fEnable);  // 2013-03-09 SHL
     2346  WinEnableWindow(WinWindowFromID(hwnd, IDM_SELECTEAS), fEnable);       // 2013-03-09 SHL
    23212347  WinEnableWindow(WinWindowFromID(hwnd, IDM_SELECTOLDER), fEnable);
    23222348  WinEnableWindow(WinWindowFromID(hwnd, IDM_SELECTBIGGER), fEnable);
     
    23252351  WinEnableWindow(WinWindowFromID(hwnd, IDM_DESELECTONE), fEnable);
    23262352  WinEnableWindow(WinWindowFromID(hwnd, IDM_DESELECTNEWER), fEnable);
    2327   WinEnableWindow(WinWindowFromID(hwnd, IDM_DESELECTEAS), fEnable); // 2013-03-09 SHL
     2353  WinEnableWindow(WinWindowFromID(hwnd, IDM_DESELECTEAS), fEnable);     // 2013-03-09 SHL
    23282354  WinEnableWindow(WinWindowFromID(hwnd, IDM_DESELECTOLDER), fEnable);
    23292355  WinEnableWindow(WinWindowFromID(hwnd, IDM_DESELECTBIGGER), fEnable);
     
    23462372  WinEnableWindow(WinWindowFromID(hwnd, COMP_INCLUDESUBDIRS), fEnable);
    23472373  WinEnableWindow(WinWindowFromID(hwnd, COMP_HIDENOTSELECTED), fEnable);
    2348   WinEnableWindow(WinWindowFromID(hwnd, COMP_CONFIRMACTION), fEnable); // 2013-03-09 SHL
     2374  WinEnableWindow(WinWindowFromID(hwnd, COMP_CONFIRMACTION), fEnable);  // 2013-03-09 SHL
    23492375}
    23502376
     
    24042430      {
    24052431        USHORT ids[] = {COMP_FRAME, COMP_LEFTDIR, COMP_RIGHTDIR, COMP_COLLECT,
    2406                         COMP_VIEW, COMP_NOTE, COMP_TOTALLEFT, COMP_SELLEFT, COMP_TOTALRIGHT,
    2407                         COMP_SELRIGHT, COMP_CNRMENU, COMP_DIRMENU, COMP_MENU,
    2408                         COMP_INCLUDESUBDIRS, COMP_SETDIRS, COMP_COPYLEFT, COMP_MOVELEFT,
    2409                         COMP_DELETELEFT, COMP_COPYRIGHT, COMP_MOVERIGHT, COMP_DELETERIGHT,
    2410                         COMP_TOTALLEFTHDR, COMP_SELLEFTHDR, COMP_TOTALRIGHTHDR,
    2411                         COMP_SELRIGHTHDR, COMP_FILTER, COMP_HIDENOTSELECTED, 0};
     2432                        COMP_VIEW, COMP_NOTE, COMP_TOTALLEFT, COMP_SELLEFT, COMP_TOTALRIGHT,
     2433                        COMP_SELRIGHT, COMP_CNRMENU, COMP_DIRMENU, COMP_MENU,
     2434                        COMP_INCLUDESUBDIRS, COMP_SETDIRS, COMP_COPYLEFT, COMP_MOVELEFT,
     2435                        COMP_DELETELEFT, COMP_COPYRIGHT, COMP_MOVERIGHT, COMP_DELETERIGHT,
     2436                        COMP_TOTALLEFTHDR, COMP_SELLEFTHDR, COMP_TOTALRIGHTHDR,
     2437                        COMP_SELRIGHTHDR, COMP_FILTER, COMP_HIDENOTSELECTED, 0};
    24122438        UINT x;
    24132439        CHAR s[24];
     
    25692595        pci = (PCNRITEM)pcown->pRecord;
    25702596        // 01 Aug 07 SHL if field null or blank, we draw
    2571         // fixme to document why - probably to optimize and bypass draw?
     2597        // FIXME to document why - probably to optimize and bypass draw?
    25722598        if (pci && (INT)pci != -1 && !*pci->pszFileName && pci->pszFileName != NullStr)
    25732599          return MRFROMLONG(TRUE);
     
    27282754        if (cmp) {
    27292755          PCNRITEM pci = (PCNRITEM)mp2;
    2730           USHORT id = COMP_CNRMENU;             // Assume container menu
     2756          USHORT id = COMP_CNRMENU;     // Assume container menu
    27312757
    27322758          if (cmp->dcd.hwndLastMenu)
     
    27792805      case CN_BEGINEDIT:
    27802806      case CN_REALLOCPSZ:
    2781         // fixme to be gone - field edits not allowed?
     2807        // FIXME to be gone - field edits not allowed?
    27822808        Runtime_Error(pszSrcFile, __LINE__,
    27832809                      "CN_BEGINEDIT/CN_REALLOCPSZ unexpected");
     
    28712897                          CA_DETAILSVIEWTITLES | CA_OWNERDRAW;
    28722898      WinSendDlgItemMsg(hwnd, COMP_LEFTDIR, CM_SETCNRINFO, MPFROMP(&cnri),
    2873                         MPFROMLONG(CMA_CNRTITLE | CMA_FLWINDOWATTR));
     2899                        MPFROMLONG(CMA_CNRTITLE | CMA_FLWINDOWATTR));
    28742900      WinSetDlgItemText(hwnd, COMP_LISTLOADED, "");
    28752901      cnri.pszCnrTitle = cmp->rightdir;
     
    29993025
    30003026  case WM_COMMAND:
    3001     // 29 Apr 09 SHL fixme to support more context menu items - IDM_VIEW, IDM_EDIT etc.
     3027    // 29 Apr 09 SHL FIXME to support more context menu items - IDM_VIEW, IDM_EDIT etc.
    30023028    switch (SHORT1FROMMP(mp1)) {
    30033029    case IDM_COMPARE:
     
    33253351        ULONG size = sizeof(SWP);
    33263352        USHORT ids[] = {COMP_FRAME, COMP_LEFTDIR, COMP_RIGHTDIR, COMP_COLLECT,
    3327                         COMP_VIEW, COMP_NOTE, COMP_TOTALLEFT, COMP_SELLEFT, COMP_TOTALRIGHT,
    3328                         COMP_SELRIGHT, COMP_CNRMENU, COMP_DIRMENU, COMP_MENU,
    3329                         COMP_INCLUDESUBDIRS, COMP_SETDIRS, COMP_COPYLEFT, COMP_MOVELEFT,
    3330                         COMP_DELETELEFT, COMP_COPYRIGHT, COMP_MOVERIGHT, COMP_DELETERIGHT,
    3331                         COMP_TOTALLEFTHDR, COMP_SELLEFTHDR, COMP_TOTALRIGHTHDR,
    3332                         COMP_SELRIGHTHDR, COMP_FILTER, COMP_HIDENOTSELECTED, 0};
     3353                        COMP_VIEW, COMP_NOTE, COMP_TOTALLEFT, COMP_SELLEFT, COMP_TOTALRIGHT,
     3354                        COMP_SELRIGHT, COMP_CNRMENU, COMP_DIRMENU, COMP_MENU,
     3355                        COMP_INCLUDESUBDIRS, COMP_SETDIRS, COMP_COPYLEFT, COMP_MOVELEFT,
     3356                        COMP_DELETELEFT, COMP_COPYRIGHT, COMP_MOVERIGHT, COMP_DELETERIGHT,
     3357                        COMP_TOTALLEFTHDR, COMP_SELLEFTHDR, COMP_TOTALRIGHTHDR,
     3358                        COMP_SELRIGHTHDR, COMP_FILTER, COMP_HIDENOTSELECTED, 0};
    33333359        UINT x;
    33343360        CHAR s[24];
    33353361        WinQueryWindowPos(hwnd, &swp);
    33363362        PrfWriteProfileData(fmprof, FM3Str, "CompDir.Position", (PVOID) &swp,
    3337                             size);
     3363                            size);
    33383364        for (x = 0; ids[x]; x++) {
    33393365          sprintf(s, "CompDir%i", ids[x]);
     
    33483374        Runtime_Error(pszSrcFile, __LINE__, NULL);
    33493375      else {
    3350         cmp->stop = TRUE;                       // In case thread running
     3376        cmp->stop = TRUE;               // In case thread running
    33513377        if (cmp->filling)
    3352           break;                                // UM_CONTAINER_FILLED will dismiss
     3378          break;                        // UM_CONTAINER_FILLED will dismiss
    33533379      }
    33543380      {
     
    33873413    case IDM_SELECTSAME:                // Name and size
    33883414    case IDM_INVERT:
    3389 
    3390 
    33913415      cmp = INSTDATA(hwnd);
    33923416      if (!cmp)
     
    35333557    cmp = INSTDATA(hwnd);
    35343558    if (cmp) {
    3535       // 17 Jan 08 SHL fixme to know if stop really needed?
     3559      // 17 Jan 08 SHL FIXME to know if stop really needed?
    35363560      WinStopTimer(WinQueryAnchorBlock(hwnd), hwnd, ID_COMP_TIMER);
    35373561      if (cmp->dcd.hwndLastMenu)
     
    35473571      DosReleaseMutexSem(hmtxFiltering);
    35483572    }
     3573
     3574#   ifdef PMPRINTF
     3575    PmPrintf_Report(pszSrcFile, __LINE__, "CompareDlgProc EmptyCnr Left");
     3576#   endif
    35493577    EmptyCnr(GetHwndLeft(hwnd));
     3578
     3579#   ifdef PMPRINTF
     3580    PmPrintf_Report(pszSrcFile, __LINE__, "CompareDlgProc EmptyCnr Right");
     3581#   endif
    35503582    EmptyCnr(GetHwndRight(hwnd));
     3583
    35513584    DosPostEventSem(CompactSem);
    35523585    break;
  • trunk/dll/dircnrs.h

    r1871 r1891  
    66  dircnrs common definitions
    77
    8   Copyright (c) 1993-98 M. Kimes
    9   Copyright (c) 2001, 2015 Steven H. Levine
     8  Copyright (c) 1993-1998 M. Kimes
     9  Copyright (c) 2001-2020 Steven H. Levine
    1010
    1111  05 Jan 08 SHL Move dircnrs.c definitions here
     
    1717  20 Sep 15 GKY Add a flag to indicate when a directory needed to be Fleshed and a PCNRITEM
    1818                previous to try to keep the pci chain intact on renames, delete etc to PCNRITEM
     19  29 Jan 20 SHL Get rid of unused pciPrevious
    1920
    2021***********************************************************************/
     
    6263  ULONG flags;
    6364  BOOL fleshed;
    64   struct _CNRITEM *pciPrevious;    // Address of pci we are linked to
    6565}
    6666CNRITEM, *PCNRITEM;
     
    168168MRESULT EXPENTRY SearchContainer(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2);
    169169
    170 // 05 Jan 08 SHL fixme for dircnrs.c globals to be here
     170// 05 Jan 08 SHL FIXME for dircnrs.c globals to be here
    171171
    172172#ifdef DEFINE_GLOBALS
  • trunk/dll/errutil.c

    r1880 r1891  
    66  Error reporting
    77
    8   Copyright (c) 1993-98 M. Kimes
    9   Copyright (c) 2004, 2015 Steven H. Levine
     8  Copyright (c) 1993-1998 M. Kimes
     9  Copyright (c) 2004-2020 Steven H. Levine
    1010
    1111  12 Aug 04 SHL Comments
     
    4141  15 Feb 14 GKY Improvements to saymsg2 some code cleanup
    4242  16 Feb 14 GKY Rework readonly check on delete code so it actually works in a logical way
    43                 and so it works with move to trashcan inabled.
     43                and so it works with move to trashcan inabled.
    4444  09 Nov 13 SHL Use GetTidForThread in DbgMsg and tweak for for editors that understand file:line
     45  28 Jan 20 SHL Add PmPrintf_Report
    4546
    4647***********************************************************************/
     
    6667#include "fm3dll2.h"
    6768
     69#ifdef PMPRINTF
     70#define _PMPRINTF_                      // Enable debug macros
     71#include "PMPRINTF.H"
     72#endif
     73
    6874#pragma data_seg(DATA1)
    6975
     
    8692  va_list va;
    8793
    88 #if 1 // fixme to be selectable
     94#if 1 // FIXME to be selectable
    8995
    9096  static ULONG ul1stMSec;
     
    94100
    95101  if (!ul1stMSec) {
    96     ul1stMSec = msec;      // Avoid big delta 1st time
     102    ul1stMSec = msec;                   // Avoid big delta 1st time
    97103  }
    98104
     
    124130 */
    125131
    126 // 2010-12-01 SHL fixme for ULONG to be APIRET
     132// 2010-12-01 SHL FIXME for ULONG to be APIRET
    127133
    128134INT Dos_Error(ULONG mb_type, ULONG apiret, HWND hwndOwner,
     
    240246  if (pszBuf[cBufBytes - 1]) {
    241247    fprintf(stderr, "Buffer overflow in formatWinError - need %u bytes\n",
    242             strlen(pszBuf) + 1);
     248            strlen(pszBuf) + 1);
    243249    fflush(stderr);
    244250  }
     
    263269    if (!hwndOwner)
    264270      hwndOwner = HWND_DESKTOP;
    265     // Find message offset in array of message offsets Assume 1 message - fixme?
     271    // Find message offset in array of message offsets Assume 1 message - FIXME?
    266272    pszOffset = ((PSZ) pErrInfoBlk) + pErrInfoBlk->offaoffszMsg;
    267273    // Address error message in array of messages and append error message to source code linenumber
     
    303309}
    304310
     311#ifdef PMPRINTF
     312
     313/**
     314 * Format runtime error message and output using PmPrintf
     315 * @note: Local errors written directly to stderr
     316 * @note: If pszFmt is NULL a No Data error message is returned GKY 20 Feb 09 (Replaces Runtime_Error2)
     317 */
     318
     319VOID PmPrintf_Report(PCSZ pszSrcFile, UINT uSrcLineNo, PCSZ pszFmt, ...)
     320{
     321  CHAR szMsg[4096];
     322  va_list va;
     323
     324  // Format caller's message
     325  if (!pszFmt)
     326    pszFmt = PCSZ_NODATA;
     327  va_start(va, pszFmt);
     328  szMsg[sizeof(szMsg) - 1] = 0;
     329  vsprintf(szMsg, pszFmt, va);
     330  va_end(va);
     331
     332  if (szMsg[sizeof(szMsg) - 1]) {
     333    fprintf(stderr, "Buffer overflow in PmPrintf_Report - need %u bytes\n", strlen(szMsg) + 1);
     334    fflush(stderr);
     335  }
     336
     337  if (strchr(szMsg, ' ') == NULL) {
     338    strcat(szMsg, " ");
     339    strcat(szMsg, GetPString(IDS_FAILEDTEXT));  // Assume simple function name
     340  }
     341
     342  // Avoid leading \n in IDS_GENERR1TEXT
     343  strcat(szMsg, " ");
     344  sprintf(szMsg + strlen(szMsg),
     345          GetPString(IDS_GENERR1TEXT) + 1, pszSrcFile, uSrcLineNo);
     346
     347  PmPrintfString(szMsg);
     348
     349} // PmPrintf_Report
     350
     351#endif
     352
    305353/**
    306354 * Format runtime error message and output using showMsg
     
    369417
    370418APIRET saymsg2(PCSZ pszButtonNames, int DefaultButton, HWND hwnd,
    371                PCSZ pszTitle, PCSZ pszFmt, ...)
     419               PCSZ pszTitle, PCSZ pszFmt, ...)
    372420{
    373421  ULONG i;
     
    412460    rc = WinMessageBox2(HWND_DESKTOP, hwnd,
    413461                        szMsg, pszTitle, SM2_DIALOG,
    414                         pmbInfo);
     462                        pmbInfo);
    415463    WinSetFocus(HWND_DESKTOP, SM2_DIALOG);
    416464    free(pmbInfo);
     
    460508  va_start(va, pszFmt);
    461509  formatWinError(szMsg, sizeof(szMsg), hwndErr, hwndOwner, pszSrcFile,
    462                  uSrcLineNo, pszFmt, va);
     510                 uSrcLineNo, pszFmt, va);
    463511  va_end(va);
    464512
     
    484532  va_start(va, pszFmt);
    485533  formatWinError(szMsg, sizeof(szMsg), hwndErr, hwndOwner, pszSrcFile, uSrcLineNo,
    486                  pszFmt, va);
     534                 pszFmt, va);
    487535  va_end(va);
    488536
  • trunk/dll/errutil.h

    r1686 r1891  
    66  Error reporting utilities interface
    77
    8   Copyright (c) 1993-98 M. Kimes
    9   Copyright (c) 2008, 2010 Steven H. Levine
     8  Copyright (c) 1993-1998 M. Kimes
     9  Copyright (c) 2008-2020 Steven H. Levine
    1010
    1111  05 Jan 08 SHL Move from fm3dll.h to here
     
    1313  08 Mar 09 GKY Remove Dos_Error2 (unused) and Runtime_Error2 (no advantage over using Runtime_Error)
    1414  10 Mar 13 GKY Improvrd readonly check on delete to allow cancel and don't ask again options
    15                 Added saymsg2 for this purpose
     15                Added saymsg2 for this purpose
     16  28 Jan 20 SHL Add PmPrintfReport
    1617
    1718***********************************************************************/
     
    3738                        PCSZ pszSrcFile, UINT uSrcLineNo, PCSZ pszFmt, ...);
    3839
     40#ifdef PMPRINTF
     41VOID PmPrintf_Report(PCSZ pszSrcFile, UINT uSrcLineNo, PCSZ pszFmt, ...);
     42#endif
     43
    3944#endif // ERRUTIL_H
  • trunk/dll/filldir.c

    r1890 r1891  
    66  Fill Directory Tree Containers
    77
    8   Copyright (c) 1993-98 M. Kimes
    9   Copyright (c) 2001, 2015 Steven H. Levine
     8  Copyright (c) 1993-1998 M. Kimes
     9  Copyright (c) 2001-2020 Steven H. Levine
    1010
    1111  10 Jan 04 SHL ProcessDirectory: avoid most large drive failures
     
    121121  24 Aug 15 GKY Remove fDummy code
    122122  20 Sep 15 GKY Add code for Flesh to skip the directory entry added by Stubby (eliminate
    123                 use of NULL/Nullstr pszFileNames by Stubby). Add code to relink pci chain
    124                 following rename, delete, etc. Add "Expanding" window text.
     123                use of NULL/Nullstr pszFileNames by Stubby). Add code to relink pci chain
     124                following rename, delete, etc. Add "Expanding" window text.
    125125  26 Sep 15 GKY Remove fInitialDriveScan code
     126  28 Jan 20 SHL EmptyCnr: report more errors
     127  29 Jan 20 SHL RemoveCnrItems: rework removal from prev/next chain
    126128
    127129***********************************************************************/
     
    168170#include "pathutil.h"                   // AddBackslashToPath
    169171#include "tmrsvcs.h"                    // ITIMER_DESC
    170 
    171 #ifdef PMPRINTF
    172 #define  _PMPRINTF_                     // Enable debug macros
    173 #include "PMPRINTF.H"
    174 #endif
    175172
    176173// Data definitions
     
    370367  ULONG flags = driveflags[toupper(*pci->pszFileName) - 'A'];
    371368  BOOL fLoadSubjectForDrive = fLoadSubject && ~flags & DRIVE_NOLOADSUBJS;
    372   BOOL fLoadLongNameForDrive = fLoadLongnames &&  //~flags & DRIVE_NOLONGNAMES &&
     369  BOOL fLoadLongNameForDrive = fLoadLongnames &&        // ~flags & DRIVE_NOLONGNAMES &&
    373370                               ~flags & DRIVE_NOLOADLONGS;
    374371  if (fLoadSubjectForDrive || fLoadLongNameForDrive) {
     
    626623  pci->rc.hptrIcon = hptr;
    627624
    628 
    629625  // check to see if record should be visible
    630626  DosRequestMutexSem(hmtxFiltering, SEM_INDEFINITE_WAIT);
     
    821817                      const BOOL recurse,
    822818                      const BOOL partial,
    823                       CHAR *stopflag,
     819                      CHAR *stopflag,
    824820                      DIRCNRDATA *dcd,                  // Optional
    825821                      ULONG *pulTotalFiles,             // Optional
    826                       PULONGLONG pullTotalBytes,        // Optional
    827                       CHAR *LoadedFirstChild)           // Optional
     822                      PULONGLONG pullTotalBytes,        // Optional
     823                      CHAR *LoadedFirstChild)           // Optional
    828824{
    829825  /**
     
    899895      do {
    900896        /**
    901         * remove . and .. and directories already added
    902         * by Stubby from list if present
     897        * remove . and .. and directories already added
     898        * by Stubby from list if present
    903899         * also counter file system bugs that sometimes
    904900         * allows normal files to slip through when
     
    911907        pffbFile = paffbFound;
    912908        ulSelCnt = 0;
    913         for (;;) {
     909        for (;;) {
    914910          if (!*pffbFile->achName ||
    915911              (!filestoo && ~pffbFile->attrFile & FILE_DIRECTORY) ||
     
    917913               !pffbFile->achName[0] || pffbFile->achName[0] == '.' &&
    918914               (!pffbFile->achName[1] ||
    919                 (pffbFile->achName[1] == '.' && !pffbFile->achName[2])) ||
    920                (LoadedFirstChild && !stricmp(LoadedFirstChild, pffbFile->achName)))) {
    921                         // Got . or .. or file to be skipped
     915                (pffbFile->achName[1] == '.' && !pffbFile->achName[2])) ||
     916               (LoadedFirstChild && !stricmp(LoadedFirstChild, pffbFile->achName)))) {
     917                        // Got . or .. or file to be skipped
    922918          }
    923919          else
     
    957953                ullBytes = FillInRecordFromFFB(hwndCnr, pci, pszFileSpec,
    958954                                               pffbFile, partial, dcd);
    959                 pciNext = pci;
    960                 pci = (PCNRITEM) pci->rc.preccNextRecord;
    961                 if (pci && (INT) pci != -1)
    962                   pci->pciPrevious = pciNext;
     955                pciNext = pci;
     956                pci = (PCNRITEM) pci->rc.preccNextRecord;
    963957                ullTotalBytes += ullBytes;
    964958              } // for
     
    10581052              break;
    10591053            }
    1060             ulRecsToInsert = cAffbTotal - x <  USHRT_MAX ? cAffbTotal - x : USHRT_MAX;
     1054            ulRecsToInsert = cAffbTotal - x < USHRT_MAX ? cAffbTotal - x : USHRT_MAX;
    10611055            pciFirst = WinSendMsg(hwndCnr, CM_ALLOCRECORD,
    10621056                                  MPFROMLONG(EXTRA_RECORD_BYTES), MPFROMLONG(ulRecsToInsert));
     
    10711065            else {
    10721066              // 04 Jan 08 SHL FIXME like comp.c to handle less than ulSelCnt records
    1073               if (hwndStatus && dcd && dcd->hwndFrame ==
    1074                   WinQueryActiveWindow(dcd->hwndParent)) {
    1075                 WinSetWindowText(hwndStatus, (CHAR *) GetPString(LoadedFirstChild ?
    1076                                                                 IDS_PLEASEWAITEXPANDINGTEXT :
    1077                                                                 IDS_PLEASEWAITCOUNTINGTEXT));
     1067              if (hwndStatus && dcd && dcd->hwndFrame ==
     1068                  WinQueryActiveWindow(dcd->hwndParent)) {
     1069                WinSetWindowText(hwndStatus, (CHAR *) GetPString(LoadedFirstChild ?
     1070                                                                IDS_PLEASEWAITEXPANDINGTEXT :
     1071                                                                IDS_PLEASEWAITCOUNTINGTEXT));
    10781072              }
    10791073              pci = pciFirst;
     
    10811075          }
    10821076          ullBytes = FillInRecordFromFFB(hwndCnr, pci, pszFileSpec,
    1083                                          pffbFile, partial, dcd);
    1084           pciNext = pci;
    1085           pci = (PCNRITEM) pci->rc.preccNextRecord;
    1086           if (pci && (INT) pci != -1)
    1087             pci->pciPrevious = pciNext;
     1077                                         pffbFile, partial, dcd);
     1078          pciNext = pci;
     1079          pci = (PCNRITEM)pci->rc.preccNextRecord;
    10881080          ullTotalBytes += ullBytes;
    10891081          // 15 Sep 09 SHL allow timed updates to see
     
    11961188      }
    11971189      if ((pci->attrFile & FILE_DIRECTORY))
    1198         AddFleshWorkRequest(hwndCnr, pci, eStubby);
     1190        AddFleshWorkRequest(hwndCnr, pci, eStubby);
    11991191      pci = WinSendMsg(hwndCnr, CM_QUERYRECORD, MPFROMP(pci),
    12001192                       MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER));
     
    12251217                   dcd,
    12261218                   NULL,                // total files
    1227                    pullTotalBytes,
    1228                    0);
     1219                   pullTotalBytes,
     1220                   0);
    12291221  DosPostEventSem(CompactSem);
    12301222
     
    12531245  ULONG ulDriveType;
    12541246  PCNRITEM pci, pciFirst = NULL;
    1255   PCNRITEM  pciNext;
    1256   PCNRITEM  pciParent = NULL;
     1247  PCNRITEM pciNext;
     1248  PCNRITEM pciParent = NULL;
    12571249  UINT iDrvNum;
    12581250  ULONG ulDriveMapMask;
     
    17491741} // FillTreeCnr
    17501742
    1751 
    17521743/**
    17531744 * Empty all records from a container and free associated storage and
     
    17591750  PFIELDINFO pfi;
    17601751
    1761 #if 0 // fixme to be gone or to be configurable
     1752#if 0 // FIXME to be gone or to be configurable
    17621753  {
    17631754    int state = _heapchk();
     
    17681759
    17691760  // Remove all records
    1770   RemoveCnrItems(hwnd, NULL, 0, CMA_FREE);
     1761  if (RemoveCnrItems(hwnd, NULL, 0, CMA_FREE))
     1762    Win_Error(hwnd, HWND_DESKTOP, pszSrcFile, __LINE__,"RemoveCnrItems");
    17711763
    17721764  // Remove field info descriptors
     
    17861778VOID FreeCnrItemData(PCNRITEM pci)
    17871779{
    1788 
    17891780  // 2015-08-23 SHL FIXME debug
    17901781  if ((pci->pszSubject && (ULONG)pci->pszSubject < 0x10000) ||
     
    17981789  }
    17991790
     1791# ifdef PMPRINTF
     1792  {
     1793    PSZ psz = pci->pszFileName;
     1794    if (!psz)
     1795      psz = "(NULL)";
     1796    else if (psz == NullStr)
     1797      psz = "NullStr";
     1798    PmPrintf_Report(pszSrcFile, __LINE__, "FreeCnrItemData freeing pci %p data for fileName \"%.260s\"",
     1799                    pci, psz);
     1800  }
     1801# endif
     1802
    18001803  if (pci->pszSubject) {
    18011804    if (pci->pszSubject != NullStr)
     
    18231826  }
    18241827
    1825 #if 1 // 2009-09-26 SHL FIXME debug dup free complaints
     1828#if 0 // 2009-09-26 SHL FIXME debug dup free complaints
    18261829  if (!pci->pszFileName)
    18271830    Runtime_Error(pszSrcFile, __LINE__, "FreeCnrItemData attempting to free %p data twice", pci);
     
    18321835  }
    18331836#else
     1837# if 0                  // FIXME to be gone
    18341838  {
    1835     // 2015-08-23 SHL FIXME to work again now that Flesh/Stubby on thread
    1836     #define HIST_COUNT 50
     1839    static BOOL first;
     1840    if (!first) {
     1841      first=1;
     1842      DebugHereIAm();
     1843    }
     1844  }
     1845# endif
     1846  {
     1847    // Add CNRITEM to history list
     1848    // 2015-08-23 SHL FIXME to verify OK now that Flesh/Stubby on thread
     1849    #define HIST_CNT 5000
     1850    static INT volatile iHistLock;              // Cheap spin lock
    18371851    static struct {
    18381852      PCNRITEM pci;
    18391853      PSZ pszFileName;
    1840     } history[HIST_COUNT];
    1841     static volatile UINT iHistNdx;
    1842     UINT i;
     1854    } histList[HIST_CNT];
     1855    static volatile UINT iHistNdx;              // Last used
     1856    UINT iCurNdx;
    18431857
    18441858    if (!pci->pszFileName) {
    18451859      // Looks like pci was already freed
    1846       // Try to locate original file name in history buffer
    1847       for (i = 0; i < HIST_COUNT && pci != history[i].pci; i++) { }     // Scan
    1848       if (i < HIST_COUNT) {
    1849         Runtime_Error(pszSrcFile, __LINE__, "FreeCnrItemData attempting to free %p data twice, fileName was %.260s",
    1850                       pci, history[i].pszFileName);
     1860      // Try to locate original file name in history list
     1861      for (iCurNdx = 0; iCurNdx < HIST_CNT && pci != histList[iCurNdx].pci; iCurNdx++) { }      // Scan
     1862      if (iCurNdx < HIST_CNT) {
     1863        PSZ psz = histList[iCurNdx].pszFileName;
     1864#       ifdef PMPRINTF
     1865        PmPrintf_Report(pszSrcFile, __LINE__, "FreeCnrItemData attempting to free %p data twice, fileName was \"%.260s\"",
     1866                       pci, psz == NullStr ? "NullStr" : psz);
     1867#       endif
     1868        Runtime_Error(pszSrcFile, __LINE__, "FreeCnrItemData attempting to free %p data twice, fileName was \"%.260s\"",
     1869                      pci, psz == NullStr ? "NullStr" : psz);
    18511870      } else {
     1871
     1872#       ifdef PMPRINTF
     1873        PmPrintf_Report(pszSrcFile, __LINE__, "FreeCnrItemData attempting to free %p data twice", pci);
     1874#       endif
    18521875        Runtime_Error(pszSrcFile, __LINE__, "FreeCnrItemData attempting to free %p data twice", pci);
    18531876      }
    18541877    }
    18551878    else {
     1879      // Add to history list
    18561880      PSZ psz;
    18571881      PSZ *ppsz;
    1858       // Grab a history slot
     1882      static PSZ pszNull = "(NULL)";
    18591883      // This should work well enoungh to prevent MT/SMP conflicts
    1860       for (;;) {
    1861         i = iHistNdx;
    1862         if (++i >= HIST_COUNT)
    1863           i = 0;
    1864         if (++iHistNdx >= HIST_COUNT)
    1865           iHistNdx = 0;
    1866         if (i == iHistNdx) break;
    1867       }
    1868       ppsz = &history[iHistNdx].pszFileName;
     1884      for (; ++iHistLock > 1; iHistLock--)
     1885        DosSleep(0);                    // Spin if list locked
     1886      if (++iHistNdx >= HIST_CNT)
     1887        iHistNdx = 0;
     1888      ppsz = &histList[iHistNdx].pszFileName;
    18691889      psz = *ppsz;
    1870       if (psz)
     1890      if (psz && psz != NullStr && psz != pszNull)
    18711891        free(psz);
    1872       if (pci->pszFileName && pci->pszFileName != NullStr)
    1873         *ppsz = strdup(pci->pszFileName);
     1892      if (pci->pszFileName) {
     1893         if (pci->pszFileName != NullStr)
     1894           *ppsz = strdup(pci->pszFileName);
     1895        else
     1896           *ppsz = NullStr;
     1897      }
    18741898      else
    1875         *ppsz = NULL;
    1876       history[iHistNdx].pci = pci;
     1899        *ppsz = pszNull;
     1900      histList[iHistNdx].pci = pci;
     1901      iHistLock--;
     1902
    18771903      if (pci->pszFileName != NullStr)
    18781904        free(pci->pszFileName);
     
    19021928VOID FreeCnrItem(HWND hwnd, PCNRITEM pci)
    19031929{
     1930# ifdef PMPRINTF
     1931  PmPrintf_Report(pszSrcFile, __LINE__, "FreeCnrItem freeing pci %p");
     1932# endif
     1933
    19041934  FreeCnrItemData(pci);
    19051935
     
    19491979 * Remove item(s) from container and free associated storage if requested
    19501980 * @param pciFirst points to first item to remove or NULL to remove all
    1951  * @param usCnt is remove count or 0 to remove all
    1952  * @returns count of items remaining in container or -1 if error
     1981 * @param usCnt is 0 to remove all or 1 to remove specific record
     1982 * @param usFlags for CM_REMOVERECORD
     1983 * @returns count of items remaining to delete or -1 if error
    19531984 */
    19541985
     
    19571988  INT remaining = usCnt;
    19581989  BOOL bIdlePrioritySet = FALSE;
    1959   // #define RCI_ITEMS_PER_TIMER_CHECK (10)
    1960   // 10 seems a very conservative number
    1961   //  USHORT usTimerCheckCountdown      = RCI_ITEMS_PER_TIMER_CHECK;
    19621990  PCNRITEM pci;
    1963   PCNRITEM pciPrevious;
    19641991  ITIMER_DESC itdSleep = { 0 };         // 30 May 11 GKY
    19651992
    1966   if ((usCnt && !pciFirst) || (!usCnt && pciFirst)) {
    1967       Runtime_Error(pszSrcFile, __LINE__, "pciFirst %p usCnt %u mismatch", pciFirst, usCnt);
     1993  // Counted remove requires pciFirst and can only remove 1 record
     1994  // Remove all does not allow pciFirst
     1995  if ((usCnt && !pciFirst) || (usCnt != 1 && pciFirst)) {
     1996    Runtime_Error(pszSrcFile, __LINE__, "pciFirst %p usCnt %u mismatch", pciFirst, usCnt);
     1997    remaining = -1;
     1998  }
     1999  else if (!usFlags & CMA_FREE) {
     2000    Runtime_Error(pszSrcFile, __LINE__, "usFlags must have CMA_FREE set");
     2001    remaining = -1;
     2002  }
     2003  else if (!pciFirst) {
     2004    // Removing all - query first
     2005    pciFirst = (PCNRITEM)WinSendMsg(hwnd, CM_QUERYRECORD, MPVOID,
     2006                                    MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER));
     2007    if ((INT)pciFirst == -1) {
     2008      Win_Error(hwnd, HWND_DESKTOP, pszSrcFile, __LINE__,"CM_QUERYRECORD");
    19682009      remaining = -1;
    1969   }
    1970   else {
    1971     // Free our buffers if free requested
    1972     if (usFlags & CMA_FREE) {
    1973       if (pciFirst)
    1974         pci = pciFirst;
    1975       else {
    1976         pci = (PCNRITEM)WinSendMsg(hwnd, CM_QUERYRECORD, MPVOID,
    1977                                    MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER));
    1978         if ((INT)pci == -1) {
    1979           Win_Error(hwnd, HWND_DESKTOP, pszSrcFile, __LINE__,"CM_QUERYRECORD");
    1980           remaining = -1;
    1981           pci = NULL;
    1982         }
    1983       }
    1984       InitITimer(&itdSleep, 500);
    1985       while (pci) {
    1986         FreeCnrItemData(pci);
    1987         if (usCnt > 0)
    1988           pciPrevious = pci;
    1989         pci = (PCNRITEM)pci->rc.preccNextRecord;
    1990         if (!pci)
    1991           break;
    1992         if (usCnt > 0 && pciPrevious && pciPrevious->pciPrevious) {
    1993           pciPrevious->pciPrevious->rc.preccNextRecord = (MINIRECORDCORE *) pci;
    1994           pci->pciPrevious = pciPrevious->pciPrevious;
    1995           pciPrevious->pciPrevious = NULL;
    1996           pciPrevious->rc.preccNextRecord = NULL;
    1997         }
    1998         if (remaining && --remaining == 0)
    1999           break;
    2000         if (!bIdlePrioritySet) {
    2001           bIdlePrioritySet = !IdleIfNeeded(&itdSleep, 30);
    2002         }
    2003       } // while
    2004       if (bIdlePrioritySet)
    2005         priority_normal();
    2006 
    2007       DosPostEventSem(CompactSem);
    2008     }
    2009   }
    2010   if (remaining != - 1) {
     2010    }
     2011  }
     2012
     2013  InitITimer(&itdSleep, 500);
     2014
     2015# ifdef PMPRINTF
     2016  PmPrintf_Report(pszSrcFile, __LINE__, "RemoveCnrItems freeing data pciFirst %p usCnt %d remaining %d",
     2017                  pciFirst, usCnt, remaining);
     2018# endif
     2019
     2020  // Free data
     2021  // 2020-01-28 SHL Rework to use CMA_NEXT - preccNextRecord method was never reliable
     2022  pci = pciFirst;
     2023  while (pci && (INT)pci != -1) {
     2024    FreeCnrItemData(pci);
     2025    if (remaining && --remaining == 0)
     2026      break;                    // pci point to last CNRITEM to be deleted
     2027    pci = WinSendMsg(hwnd, CM_QUERYRECORD, MPFROMP(pci),
     2028                     MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER));
     2029    if (!bIdlePrioritySet)
     2030      bIdlePrioritySet = !IdleIfNeeded(&itdSleep, 30);
     2031  } // while
     2032
     2033  if (bIdlePrioritySet)
     2034    priority_normal();
     2035
     2036  DosPostEventSem(CompactSem);
     2037
     2038  // Free CNRITEM record(s) if OK so far
     2039  if (remaining != -1 && pciFirst && (INT)pciFirst != -1) {
     2040#   ifdef PMPRINTF
     2041    PmPrintf_Report(pszSrcFile, __LINE__, "RemoveCnrItems CM_REMOVERECORD pciFirst %p usCnt %d", pciFirst, usCnt);
     2042#   endif
    20112043    remaining = (INT)WinSendMsg(hwnd, CM_REMOVERECORD, MPFROMP(&pciFirst), MPFROM2SHORT(usCnt, usFlags));
    2012     if (remaining == -1) {
     2044    if (remaining == -1)
    20132045      Win_Error(hwnd, HWND_DESKTOP, pszSrcFile, __LINE__,"CM_REMOVERECORD hwnd %x pci %p cnt %u", hwnd, pciFirst, usCnt);
    2014     }
     2046    else if (usCnt == 0 && remaining != 0)
     2047      Runtime_Error(pszSrcFile, __LINE__, "%u records remain after CM_REMOVERECORD", remaining);
    20152048  }
    20162049
  • trunk/dll/flesh.c

    r1890 r1891  
    66  Drive tree container management
    77
    8   Copyright (c) 1993-98 M. Kimes
    9   Copyright (c) 2005, 2015 Steven H. Levine
     8  Copyright (c) 1993-1998 M. Kimes
     9  Copyright (c) 2005-2020 Steven H. Levine
    1010
    1111  24 May 05 SHL Rework Win_Error usage
     
    3838  23 Aug 15 GKY Fixed code to notify on drive with no subdirectories in first 64 entries
    3939  20 Sep 15 GKY Add code for Flesh to skip the directory entry added by Stubby (eliminate
    40                 use of NULL/Nullstr pszFileNames by Stubby). Add code in Stubby to insert a
    41                 complete container item. Add a flag to indicate when a directory needed to be
    42                 Fleshed
     40                use of NULL/Nullstr pszFileNames by Stubby). Add code in Stubby to insert a
     41                complete container item. Add a flag to indicate when a directory needed to be
     42                Fleshed
    4343  26 Sep 15 GKY Changes to speed up ExpandAll
    4444  26 Sep 15 GKY WaitFleshWorkListEmpty now gives error message and returns if semaphore request
    45                 fails more than 5 consecutive times.
     45                fails more than 5 consecutive times.
    4646  27 Sep 15 GKY DosSleep times in WaitFleshWorkListEmpty set by caller
    4747  10 Oct 15 GKY Don't use Flesh thread for floppy drive scans fix them getting mistakenly identified
    48                 as directories and add nonexistent subdirectories.
     48                as directories and add nonexistent subdirectories.
     49  25 Jan 20 SHL Complain if AddFleshWorkRequest returns empty string
     50  27 Jan 20 SHL Avoid more traps if passed bogus pciParent
    4951
    5052***********************************************************************/
     
    8183
    8284#ifdef PMPRINTF
    83 #define  _PMPRINTF_                     // Enable debug macros
     85#define _PMPRINTF_                      // Enable debug macros
    8486#include "PMPRINTF.H"
    8587#endif
     
    9294static INT tidFleshWorkListThread = -1; // 2015-08-08 SHL
    9395
    94 static PCSZ pszFleshFocusPath;  // 2015-08-20 SHL
     96static PCSZ pszFleshFocusPath;          // 2015-08-20 SHL
    9597
    9698#pragma data_seg(GLOBAL1)
     
    193195                ri.cRecordsInsert = 1;
    194196                ri.fInvalidateRecord = FALSE;
    195                 if (!WinSendMsg(hwndCnr,
     197                if (!WinSendMsg(hwndCnr,
    196198                                CM_INSERTRECORD, MPFROMP(pciL), MPFROMP(&ri)))
    197199                  FreeCnrItem(hwndCnr, pciL);
     
    223225 * @param hwnCnr is container to receive CNRITEMs
    224226 * @param pciParent is CNRITEM to have children inserted
    225  * @return TRUE if OK, FALSE is error detected
     227 * @return TRUE if OK, FALSE if error detected
    226228 */
    227229
     
    241243  if (!pciParent->fleshed) {
    242244    pciL = (PCNRITEM)WinSendMsg(hwndCnr,
    243                                 CM_QUERYRECORD,
    244                                 MPFROMP(pciParent),
    245                                 MPFROM2SHORT(CMA_FIRSTCHILD, CMA_ITEMORDER));
     245                                CM_QUERYRECORD,
     246                                MPFROMP(pciParent),
     247                                MPFROM2SHORT(CMA_FIRSTCHILD, CMA_ITEMORDER));
    246248    // Added by Stubby to create plus sign run Stubby on it here and skip it in ProcessDirectory
    247249    if (pciL && (INT)pciL != -1) {
    248250      AddFleshWorkRequest(hwndCnr, pciL, eStubby);
    249       // 2015-08-06 SHL FIXME to ensure this can not happen
    250       if (!*pciL->pszFileName || !strcmp(pciL->pszFileName, NullStr))
    251         Runtime_Error(pszSrcFile, __LINE__, "Flesh called with pci %p pszFileName (null)",
    252                       pciL);
     251      /* Under some condtions AddFleshWorkRequest will return before pciL is populated
     252         2015-08-06 SHL FIXME to ensure pciL->szFileName not empty string
     253         2020-01-25 SHL FIXME to ensure pciL->szFileName not null
     254      */
     255      if (!pciL->pszFileName || !*pciL->pszFileName || !strcmp(pciL->pszFileName, NullStr))
     256        DosSleep(250);
     257      if (!pciL->pszFileName || !*pciL->pszFileName || !strcmp(pciL->pszFileName, NullStr)) {
     258        Runtime_Error(pszSrcFile, __LINE__, "Flesh called with pci %p pszFileName %p = %s",
     259                      pciL,
     260                      pciL ? pciL->pszFileName : 0,
     261                      pciL ? pciL->pszFileName ? pciL->pszFileName : "(null)" : "(null)");
     262        return FALSE;
     263      }
     264
    253265    }
    254266    dcd = INSTDATA(hwndCnr);
     
    269281                     dcd,
    270282                     NULL,              // total files
    271                      NULL,               // total bytes
    272                      (pciL && (INT)pciL != -1) ? pciL->pszDisplayName : 0);
     283                     NULL,              // total bytes
     284                     (pciL && (INT)pciL != -1) ? pciL->pszDisplayName : 0);
    273285    pciParent->fleshed = TRUE;
    274286    return TRUE;
     
    296308                                MPFROM2SHORT(CMA_FIRSTCHILD, CMA_ITEMORDER));
    297309    if (!pciL || (INT)pciL == -1)
    298       break;   
     310      break;
    299311    RemoveCnrItems(hwndCnr, pciL, 1, CMA_FREE);
    300312    removed = TRUE;
     
    305317               CM_INVALIDATERECORD,
    306318               MPFROMP(&pciParent),
    307                MPFROM2SHORT(1, CMA_ERASE | CMA_REPOSITION));
     319               MPFROM2SHORT(1, CMA_ERASE | CMA_REPOSITION));
    308320    pciParent->fleshed = FALSE;
    309321    DosSleep(1); // Let container items go away
     
    347359  static BOOL brokenlan = FALSE, isbroken = FALSE;
    348360
    349   if (!pciParent || (INT)pciParent == -1 || !*pciParent->pszFileName
    350       || pciParent->pszFileName == NullStr || !hwndCnr)
     361  // 2020-01-27 SHL FIXME to doc how can get here with unitialized pciParent
     362  if (!pciParent || (INT)pciParent == -1||
     363      !pciParent->pszFileName ||
     364      !*pciParent->pszFileName ||
     365      pciParent->pszFileName == NullStr ||
     366      !hwndCnr) {
    351367    return FALSE;
     368  }
     369
    352370  // Build wildcard
    353371  len = strlen(pciParent->pszFileName);
     
    507525              (pffb->achName[1] != '.' || pffb->achName[2]))))
    508526        {
    509           // Got directory other than . or .. (or a file)
     527          // Got directory other than . or .. (or a file)
    510528          isadir = TRUE;
    511529          break;
     
    530548          }
    531549          else {
    532             RECORDINSERT ri;
    533             CHAR szBuffer[CCHMAXPATH + 14];
    534             CHAR *p;
    535             HPOINTER hptr;
    536 
    537             p = strchr(wildcard, '*');
    538             *p = 0;;
    539             BldFullPathName(szBuffer, wildcard, pffb->achName);
    540             pci->pszFileName =  xstrdup(szBuffer, pszSrcFile, __LINE__);
    541             p = strrchr(pci->pszFileName, '\\');
    542             p++;
    543             pci->pszDisplayName = p;
    544             pci->rc.pszIcon = pci->pszDisplayName;
    545             if (fForceUpper)
    546               strupr(pci->pszFileName);
    547             else if (fForceLower)
    548               strlwr(pci->pszFileName);
    549          
    550             flags = driveflags[toupper(*pci->pszFileName) - 'A'];
    551          
    552             // get an icon to use with it
    553             if (pffb->attrFile & FILE_DIRECTORY) {
    554               // is directory
    555               if (fNoIconsDirs ||
    556                   (flags & DRIVE_NOLOADICONS) ||
    557                   !isalpha(*pci->pszFileName)) {
    558                 hptr = (HPOINTER) 0;
    559               }
    560               else
    561                 hptr = WinLoadFileIcon(pci->pszFileName, FALSE);
    562             }
    563             else {
    564               // is file
    565               if (fNoIconsFiles ||
    566                   (flags & DRIVE_NOLOADICONS) ||
    567                   !isalpha(*pci->pszFileName)) {
    568                 hptr = (HPOINTER) 0;
    569               }
    570               else
    571                 hptr = WinLoadFileIcon(pci->pszFileName, FALSE);
    572          
    573               if (!hptr || IsDefaultIcon(hptr))
    574                 hptr = IDFile(pci->pszFileName);
    575             }
    576          
    577             if (!hptr) {
    578               hptr = pffb->attrFile & FILE_DIRECTORY ?
    579                      hptrDir : pffb->attrFile & FILE_SYSTEM ?
    580                      hptrSystem : pffb->attrFile & FILE_HIDDEN ?
    581                      hptrHidden : pffb->attrFile & FILE_READONLY ?
    582                      hptrReadonly : hptrFile;
    583             }
    584             pci->rc.hptrIcon = hptr;
     550            RECORDINSERT ri;
     551            CHAR szBuffer[CCHMAXPATH + 14];
     552            CHAR *p;
     553            HPOINTER hptr;
     554
     555            p = strchr(wildcard, '*');
     556            *p = 0;;
     557            BldFullPathName(szBuffer, wildcard, pffb->achName);
     558            pci->pszFileName = xstrdup(szBuffer, pszSrcFile, __LINE__);
     559            p = strrchr(pci->pszFileName, '\\');
     560            p++;
     561            pci->pszDisplayName = p;
     562            pci->rc.pszIcon = pci->pszDisplayName;
     563            if (fForceUpper)
     564              strupr(pci->pszFileName);
     565            else if (fForceLower)
     566              strlwr(pci->pszFileName);
     567
     568            flags = driveflags[toupper(*pci->pszFileName) - 'A'];
     569
     570            // get an icon to use with it
     571            if (pffb->attrFile & FILE_DIRECTORY) {
     572              // is directory
     573              if (fNoIconsDirs ||
     574                  (flags & DRIVE_NOLOADICONS) ||
     575                  !isalpha(*pci->pszFileName)) {
     576                hptr = (HPOINTER) 0;
     577              }
     578              else
     579                hptr = WinLoadFileIcon(pci->pszFileName, FALSE);
     580            }
     581            else {
     582              // is file
     583              if (fNoIconsFiles ||
     584                  (flags & DRIVE_NOLOADICONS) ||
     585                  !isalpha(*pci->pszFileName)) {
     586                hptr = (HPOINTER) 0;
     587              }
     588              else
     589                hptr = WinLoadFileIcon(pci->pszFileName, FALSE);
     590
     591              if (!hptr || IsDefaultIcon(hptr))
     592                hptr = IDFile(pci->pszFileName);
     593            }
     594
     595            if (!hptr) {
     596              hptr = pffb->attrFile & FILE_DIRECTORY ?
     597                     hptrDir : pffb->attrFile & FILE_SYSTEM ?
     598                     hptrSystem : pffb->attrFile & FILE_HIDDEN ?
     599                     hptrHidden : pffb->attrFile & FILE_READONLY ?
     600                     hptrReadonly : hptrFile;
     601            }
     602            pci->rc.hptrIcon = hptr;
    585603            memset(&ri, 0, sizeof(RECORDINSERT));
    586604            ri.cb = sizeof(RECORDINSERT);
     
    590608            ri.cRecordsInsert = 1;
    591609            ri.fInvalidateRecord = TRUE;
    592             if (!WinSendMsg(hwndCnr,
     610            if (!WinSendMsg(hwndCnr,
    593611                            CM_INSERTRECORD, MPFROMP(pci), MPFROMP(&ri))) {
    594612              // Assume busy and try again
    595               DosSleep(50); 
     613              DosSleep(50);
    596614              WinSetFocus(HWND_DESKTOP, hwndCnr);
    597               if (WinIsWindow((HAB)0, hwndCnr)) {
     615              if (WinIsWindow((HAB)0, hwndCnr)) {
    598616                if (!WinSendMsg(hwndCnr,
    599617                                CM_INSERTRECORD, MPFROMP(pci), MPFROMP(&ri))) {
     
    602620                  FreeCnrItem(hwndCnr, pci);
    603621                }
    604                 else
    605                   ok = TRUE;
     622                else
     623                  ok = TRUE;
    606624              }
    607625            }
     
    652670
    653671HMTX hmtxFleshWork;
    654 HEV  hevFleshWorkListChanged;
     672HEV hevFleshWorkListChanged;
    655673
    656674/**
     
    691709 */
    692710
    693 
    694711BOOL AddFleshWorkRequest(HWND hwndCnr, PCNRITEM pci, FLESHWORKACTION action)
    695712{
     
    702719    return FALSE;
    703720
    704 
    705721  xDosRequestMutexSem(hmtxFleshWork, SEM_INDEFINITE_WAIT);
    706722
     
    749765 * @parse pszFileName is dependent pathName
    750766 */
    751 
    752767
    753768VOID WaitFleshWorkListEmpty(PCSZ pszDirName, ULONG ulSleep)
     
    761776  INT rcCount = 0;
    762777
    763   if (tid == 1 || tid == tidFleshWorkListThread) { // 11 Oct 15 GKY Fixme did we intend to keep this
     778  // 11 Oct 15 GKY FIXME did we intend to keep this
     779  if (tid == 1 || tid == tidFleshWorkListThread) {
    764780    Runtime_Error(pszSrcFile, __LINE__, "WaitFleshWorkListEmpty called by tid %u", tid);
    765     return;             // Avoid hang
     781    return;                             // Avoid hang
    766782  }
    767783  // Can not wait if call from thread 1 or FleshWorkListThread
     
    775791      rc = xDosRequestMutexSem(hmtxFleshWork, SEM_INDEFINITE_WAIT);
    776792      if (rc) {
    777         rcCount++;
    778         if (rcCount < 6)
    779           continue;                     // Maybe should return ???
    780         else {
    781           Dos_Error(MB_CANCEL, rc, HWND_DESKTOP, pszSrcFile, __LINE__,
    782                     PCSZ_DOSREQUESTMUTEXSEM);
    783           return;
    784         }
     793        rcCount++;
     794        if (rcCount < 6)
     795          continue;                     // Maybe should return ???
     796        else {
     797          Dos_Error(MB_CANCEL, rc, HWND_DESKTOP, pszSrcFile, __LINE__,
     798                    PCSZ_DOSREQUESTMUTEXSEM);
     799          return;
     800        }
    785801
    786802      }
     
    800816      if (!item) {
    801817        if (waited)
    802           DosSleep(ulSleep);            // Let PM do some work
     818          DosSleep(ulSleep);            // Let PM do some work
    803819        break;                          // Dependents gone from work list
    804820      }
     
    871887          if (!item) {
    872888            xfree((PSZ)pszFleshFocusPath, pszSrcFile, __LINE__);
    873             pszFleshFocusPath = NULL;           // Revert to normal
     889            pszFleshFocusPath = NULL;   // Revert to normal
    874890          }
    875891          else
     
    886902        // Wait for new items to be added to list
    887903        if (!item) {
    888           ULONG ul;
    889           xDosWaitEventSem(hevFleshWorkListChanged, SEM_INDEFINITE_WAIT);
    890           xDosResetEventSem(hevFleshWorkListChanged, &ul);
    891           continue;
     904          ULONG ul;
     905          xDosWaitEventSem(hevFleshWorkListChanged, SEM_INDEFINITE_WAIT);
     906          xDosResetEventSem(hevFleshWorkListChanged, &ul);
     907          continue;
    892908        }
    893909
    894         if (WinIsWindow((HAB)0, item->hwndCnr)) {
     910        if (WinIsWindow((HAB)0, item->hwndCnr)) {
    895911
    896912          switch (item->action) {
    897           case eUnFlesh:
    898             UnFlesh(item->hwndCnr, item->pci);
     913          case eUnFlesh:
     914            UnFlesh(item->hwndCnr, item->pci);
    899915            break;
    900916          case eFleshEnv:
     
    902918            break;
    903919          case eStubby:
    904             priority_bumped();
    905             Stubby(item->hwndCnr, item->pci);
    906             priority_normal();
     920            priority_bumped();
     921            Stubby(item->hwndCnr, item->pci);
     922            priority_normal();
    907923            break;
    908924          case eFlesh:
     
    915931          } // switch
    916932
    917 
    918933        } // if window
    919934
  • trunk/dll/init.c

    r1877 r1891  
    218218#include "systemf.h"                    // runemf2
    219219
    220 #if 0
    221 #define  __PMPRINTF__
     220#ifdef PMPRINTF
     221#define  _PMPRINTF_                     // Enable debug macros
    222222#include "PMPRINTF.H"
    223223#endif
     
    748748  }
    749749
    750 #if 0
     750#ifdef PMPRINTF
    751751  PmPrintfDisplayInterfaceVersionInfo();
    752752  PmPrintfQueueNameThisProcess(NULL);
     
    940940        strcpy(inipath, profile);
    941941      }
    942     } //fixme the DosCopies probably fail if the INI isn't in the FM2 directory GKY 06 Aug 11
     942    } // FIXME the DosCopies probably fail if the INI isn't in the FM2 directory GKY 06 Aug 11
    943943    if (!*inipath)
    944944      strcpy(inipath, profile);
     
    953953        fWantFirstTimeInit = TRUE;
    954954    }
    955     if (!fWantFirstTimeInit) { //Check the ini file header and restore from backup if corupted
     955    if (!fWantFirstTimeInit) {
     956      // Check the ini file header and restore from backup if corupted
    956957      if (!CheckFileHeader(inipath, "\xff\xff\xff\xff\x14\x00\x00\x00", 0L)) {
    957958        saymsg(MB_ENTER,HWND_DESKTOP, GetPString(IDS_DEBUG_STRING),
     
    984985    }
    985986
    986     // 10 Jan 08 SHL fixme to do first time if new ini
     987    // 10 Jan 08 SHL FIXME to do first time if new ini
    987988    // 10 Jan 08 SHL post UM_FIRSTTIME to main window
    988989    if (!fmprof) {
     
    12251226  prntabspaces = 8;
    12261227  CollectorsortFlags = sortFlags = SORT_FILENAME | SORT_DIRSFIRST;
    1227   //Get default Country info
     1228  // Get default Country info
    12281229  {
    12291230    COUNTRYCODE Country    = {0};
     
    12611262      fLVM = TRUE;
    12621263
    1263     //Check for unlock.exe
     1264    // Check for unlock.exe
    12641265    if (!xDosQueryAppType(PCSZ_UNLOCKEXE, &ulAppType))
    12651266      fUnlock = TRUE;
     
    13241325  editor = xmallocz(MaxComLineStrg, pszSrcFile, __LINE__);
    13251326  if (!editor)
    1326     return 0; //already complained
     1327    return 0; // already complained
    13271328  viewer = xmallocz(MaxComLineStrg, pszSrcFile, __LINE__);
    13281329  if (!viewer)
    1329     return 0; //already complained
     1330    return 0; // already complained
    13301331  virus = xmallocz(MaxComLineStrg, pszSrcFile, __LINE__);
    13311332  if (!virus)
    1332     return 0; //already complained
     1333    return 0; // already complained
    13331334  compare = xmallocz(MaxComLineStrg, pszSrcFile, __LINE__);
    13341335  if (!compare)
    1335     return 0; //already complained
     1336    return 0; // already complained
    13361337  binview = xmallocz(MaxComLineStrg, pszSrcFile, __LINE__);
    13371338  if (!binview)
    1338     return 0; //already complained
     1339    return 0; // already complained
    13391340  bined = xmallocz(MaxComLineStrg, pszSrcFile, __LINE__);
    13401341  if (!bined)
    1341     return 0; //already complained
     1342    return 0; // already complained
    13421343  dircompare = xmallocz(MaxComLineStrg, pszSrcFile, __LINE__);
    13431344  if (!dircompare)
    1344     return 0; //already complained
     1345    return 0; // already complained
    13451346  ftprun = xmallocz(MaxComLineStrg, pszSrcFile, __LINE__);
    13461347  if (!ftprun)
    1347     return 0; //already complained
     1348    return 0; // already complained
    13481349  httprun = xmallocz(MaxComLineStrg, pszSrcFile, __LINE__);
    13491350  if (!httprun)
    1350     return 0; //already complained
     1351    return 0; // already complained
    13511352  mailrun = xmallocz(MaxComLineStrg, pszSrcFile, __LINE__);
    13521353  if (!mailrun)
    1353     return 0; //already complained
     1354    return 0; // already complained
    13541355  pszTreeEnvVarList = xmallocz(MaxComLineStrg, pszSrcFile, __LINE__);
    13551356  if (!pszTreeEnvVarList)
    1356     return 0; //already complained
     1357    return 0; // already complained
    13571358  size = sizeof(BOOL);
    13581359  PrfQueryProfileData(fmprof, FM3Str, "DontSuggestAgain", &fDontSuggestAgain, &size);
     
    18031804  int ok = 0;
    18041805
    1805   // fixme to do useful check - was missing in base source
     1806  // FIXME to do useful check - was missing in base source
    18061807
    18071808#if 0
Note: See TracChangeset for help on using the changeset viewer.