Changeset 743


Ignore:
Timestamp:
Jul 30, 2007, 12:42:56 AM (13 years ago)
Author:
Steven Levine
Message:

Baseline code for ticket 24 CNRITEM remove/free

Location:
trunk/dll
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/dll/filldir.c

    r739 r743  
    5454#pragma alloc_text(FILLDIR,FillInRecordFromFFB,FillInRecordFromFSA,IDFile)
    5555#pragma alloc_text(FILLDIR1,ProcessDirectory,FillDirCnr,FillTreeCnr)
     56#pragma alloc_text(EMPTYCNR,EmptyCnr)
    5657
    5758static HPOINTER IDFile(PSZ p)
     
    14671468
    14681469} // FillTreeCnr
     1470
     1471
     1472/**
     1473 * Empty all records from a container and free associated storage and
     1474 * Free up field infos
     1475 */
     1476
     1477VOID EmptyCnr(HWND hwnd)
     1478{
     1479  PFIELDINFO pfi;
     1480
     1481  // Remove all records
     1482  RemoveCnrItems(hwnd, NULL, 0, CMA_FREE);
     1483
     1484  // Remove field info descriptors
     1485  pfi = (PFIELDINFO) WinSendMsg(hwnd, CM_QUERYDETAILFIELDINFO, MPVOID,
     1486                                MPFROMSHORT(CMA_FIRST));
     1487  if (pfi)
     1488    WinSendMsg(hwnd, CM_REMOVEDETAILFIELDINFO, MPVOID,
     1489               MPFROM2SHORT(0, CMA_FREE));
     1490}
     1491
     1492
     1493/**
     1494 * Free storage associated with container item
     1495 */
     1496
     1497static VOID FreeCnrItemData(PCNRITEM pci)
     1498{
     1499  if (pci->pszSubject && pci->pszSubject != NullStr)
     1500    xfree(pci->pszSubject);
     1501
     1502  if (pci->pszLongname && pci->pszLongname != NullStr &&
     1503      pci->pszLongname != pci->pszFileName && pci->pszLongname != pci->pszDisplayName)
     1504    xfree(pci->pszLongname);
     1505
     1506  if (pci->pszFileName && pci->pszFileName != NullStr)
     1507    xfree(pci->pszFileName);
     1508}
     1509
     1510/**
     1511 * Free container item and associated storage
     1512 */
     1513
     1514VOID FreeCnrItem(HWND hwnd, PCNRITEM pci)
     1515{
     1516  FreeCnrItemData(pci);
     1517
     1518  if (!WinSendMsg(hwnd, CM_FREERECORD, MPFROMP(&pci), MPFROMSHORT(1))) {
     1519    // Win_Error2(hwnd, hwnd, pszSrcFile, __LINE__,IDS_CMFREEERRTEXT);
     1520    Win_Error(hwnd, hwnd, pszSrcFile, __LINE__,"CM_FREERECORD");
     1521  }
     1522}
     1523
     1524/**
     1525 * Remove item from container and free associated storage
     1526 */
     1527
     1528VOID RemoveCnrItems(HWND hwnd, PCNRITEM pci, USHORT usCnt, USHORT usFlags)
     1529{
     1530  if (usCnt == 0) {
     1531    if (pci != NULL)
     1532      Runtime_Error(pszSrcFile, __LINE__, "pci not NULL");
     1533    else {
     1534      for (;;) {
     1535        pci = (PCNRITEM)WinSendMsg(hwnd, CM_QUERYRECORD, MPVOID,
     1536                                  MPFROMSHORT(CMA_FIRST));
     1537        if (!pci)
     1538          break;
     1539        else if ((INT)pci == -1)
     1540          Win_Error(hwnd, hwnd, pszSrcFile, __LINE__,"CM_QUERYRECORD");
     1541        else
     1542          RemoveCnrItems(hwnd, pci, 1, usFlags);
     1543      }
     1544    }
     1545  }
     1546  else if (usCnt != 1)
     1547    Runtime_Error(pszSrcFile, __LINE__, "count not 1");
     1548  else {
     1549    FreeCnrItemData(pci);
     1550
     1551    if (!WinSendMsg(hwnd, CM_REMOVERECORD, MPFROMP(&pci), MPFROM2SHORT(usCnt, CMA_FREE))) {
     1552      // Win_Error2(hwnd, hwnd, pszSrcFile, __LINE__,IDS_CMREMOVEERRTEXT);
     1553      Win_Error(hwnd, hwnd, pszSrcFile, __LINE__,"CM_REMOVERECORD");
     1554    }
     1555  }
     1556}
     1557
  • trunk/dll/fm3dll.h

    r739 r743  
    625625
    626626/* filldir.c */
    627 VOID FillDirCnr(HWND hwndCnr, CHAR * pszDirectory, DIRCNRDATA * pdcd,
     627VOID EmptyCnr(HWND hwnd);
     628VOID FillDirCnr(HWND hwndCnr, CHAR *pszDirectory, DIRCNRDATA *pdcd,
    628629                PULONGLONG pullBytes);
    629630VOID FillTreeCnr(HWND hwndCnr, HWND hwndParent);
    630631VOID ProcessDirectory(const HWND hwndCnr, const PCNRITEM pciParent,
    631                       const CHAR * szDirBase, const BOOL filestoo,
     632                      const CHAR *szDirBase, const BOOL filestoo,
    632633                      const BOOL recurse, const BOOL partial,
    633                       CHAR * stopflag, DIRCNRDATA * pdcd,
     634                      CHAR *stopflag, DIRCNRDATA *pdcd,
    634635                      PULONG pullTotalFiles, PULONGLONG pullTotalBytes);
    635636ULONGLONG FillInRecordFromFFB(HWND hwndCnr, PCNRITEM pci,
    636637                              const PSZ pszDirectory,
    637638                              const PFILEFINDBUF4 pffb, const BOOL partial,
    638                               DIRCNRDATA * pdcd);
     639                              DIRCNRDATA *pdcd);
    639640ULONGLONG FillInRecordFromFSA(HWND hwndCnr, PCNRITEM pci,
    640641                              const PSZ pszFileName, const PFILESTATUS4 pfsa4,
    641                               const BOOL partial, DIRCNRDATA * pdcd);
     642                              const BOOL partial, DIRCNRDATA *pdcd);
     643VOID FreeCnrItem(HWND hwnd, PCNRITEM pci);
     644VOID RemoveCnrItems(HWND hwnd, PCNRITEM pci, USHORT usCnt, USHORT usFlags);
    642645
    643646/* flesh.c */
     
    710713VOID CloseHelp(VOID);
    711714INT ExecFile(HWND hwnd, CHAR * filename);
    712 VOID EmptyCnr(HWND hwnd);
    713715VOID SetDetailsSwitches(HWND hwnd, DIRCNRDATA * dcd);
    714716VOID AdjustDetailsSwitches(HWND hwnd, HWND hwndMenu, USHORT cmd,
  • trunk/dll/misc.c

    r737 r743  
    5555#pragma alloc_text(CNR_MISC1,AdjustCnrColVis,AdjustCnrColsForFSType)
    5656#pragma alloc_text(CNR_MISC1,AdjustCnrColsForPref,SetCnrCols)
    57 #pragma alloc_text(CNR_MISC2,CnrDirectEdit,EmptyCnr,OpenEdit)
     57#pragma alloc_text(CNR_MISC2,CnrDirectEdit,OpenEdit)
    5858#pragma alloc_text(MISC2,SetMenuCheck,disable_menuitem,SetSortChecks)
    5959#pragma alloc_text(MISC2,SetDetailsSwitches,SetViewMenu)
     
    926926    return -1;
    927927  return 0;
    928 }
    929 
    930 VOID EmptyCnr(HWND hwnd)
    931 {
    932   /* Empty out a container in preparation to it dying */
    933   PCNRITEM pci;
    934   PFIELDINFO pfi;
    935 
    936   pci = (PCNRITEM) WinSendMsg(hwnd, CM_QUERYRECORD, MPVOID,
    937                               MPFROMSHORT(CMA_FIRST));
    938   if (pci && (INT) pci != -1)
    939     WinSendMsg(hwnd, CM_REMOVERECORD, MPVOID, MPFROM2SHORT(0, CMA_FREE));
    940   pfi = (PFIELDINFO) WinSendMsg(hwnd, CM_QUERYDETAILFIELDINFO, MPVOID,
    941                                 MPFROMSHORT(CMA_FIRST));
    942   if (pfi)
    943     WinSendMsg(hwnd, CM_REMOVEDETAILFIELDINFO, MPVOID,
    944                MPFROM2SHORT(0, CMA_FREE));
    945928}
    946929
Note: See TracChangeset for help on using the changeset viewer.