Changeset 618 for trunk/dll/inis.c


Ignore:
Timestamp:
Apr 20, 2007, 9:19:03 PM (18 years ago)
Author:
Steven Levine
Message:

Add more drag/drop error checking
Use FreeDragInfoData
Sync with NumItemsToUnhilite AcceptOneDrop GetOneDrop mods

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/dll/inis.c

    r603 r618  
    1818  06 Apr 07 GKY Work around PM DragInfo and DrgFreeDISH limits
    1919  06 Apr 07 GKY Add some error checking in drag/drop
     20  19 Apr 07 SHL Use FreeDragInfoData.  Add more drag/drop error checks.
    2021
    2122***********************************************************************/
     
    15721573      DrgSetDragitem(pDInfo, &DItem, sizeof(DRAGITEM), 0L);
    15731574      hDrop = DrgDrag(hwnd, pDInfo, &DIcon, 1L, VK_ENDDRAG, (PVOID) NULL);
    1574       DeleteDragitemStrHandles(pDInfo); //
    1575       DrgDeleteDraginfoStrHandles (pDInfo);
    1576       DrgFreeDraginfo(pDInfo);
     1575      if (hDrop == NULLHANDLE)
     1576        FreeDragInfoData(hwnd, pDInfo);
    15771577      WinDestroyPointer(hptrINI);
    15781578    }
     
    15821582    {
    15831583      PDRAGINFO pDInfo = (PDRAGINFO) mp1;
    1584       PDRAGITEM pDItem;         /* Pointer to DRAGITEM   */
    1585 
    1586       DrgAccessDraginfo(pDInfo);        /* Access DRAGINFO       */
    1587       pDItem = DrgQueryDragitemPtr(pDInfo,      /* Access DRAGITEM       */
    1588                                    0);  /* Index to DRAGITEM     */
    1589       if (DrgVerifyRMF(pDItem,          /* Check valid rendering */
    1590                        DRM_OS2FILE,     /* mechanisms and data   */
    1591                        NULL)) {
    1592         DrgFreeDraginfo(pDInfo);        /* Free DRAGINFO         */
    1593         return (MRFROM2SHORT(DOR_DROP,  /* Return okay to drop   */
    1594                              DO_LINK));
    1595       }
    1596       else if (DrgVerifyRMF(pDItem, DRM_FM2INIRECORD, DRF_FM2INI)) {
    1597         if (WinQueryWindow(pDInfo->hwndSource, QW_PARENT) ==
    1598             WinQueryWindow(hwnd, QW_PARENT)) {
     1584      PDRAGITEM pDItem;
     1585
     1586      if (!DrgAccessDraginfo(pDInfo)) {
     1587        Win_Error(HWND_DESKTOP, HWND_DESKTOP, pszSrcFile, __LINE__,
     1588                  "DrgAccessDraginfo");
     1589      }
     1590      else {
     1591        pDItem = DrgQueryDragitemPtr(pDInfo,0);
     1592        /* Check valid rendering mechanisms and data */
     1593        if (DrgVerifyRMF(pDItem, DRM_OS2FILE, NULL)) {
    15991594          DrgFreeDraginfo(pDInfo);
    1600           return MRFROM2SHORT(DOR_NEVERDROP, 0);
    1601         }
    1602         DrgFreeDraginfo(pDInfo);        /* Free DRAGINFO         */
    1603         return (MRFROM2SHORT(DOR_DROP, ((fCopyDefault) ? DO_COPY : DO_MOVE)));
    1604       }
    1605       DrgFreeDraginfo(pDInfo);          /* Free DRAGINFO         */
    1606       return MRFROM2SHORT(DOR_NEVERDROP, 0);
    1607     }
     1595          return (MRFROM2SHORT(DOR_DROP, DO_LINK));     /* OK to drop */
     1596        }
     1597        else if (DrgVerifyRMF(pDItem, DRM_FM2INIRECORD, DRF_FM2INI)) {
     1598          if (WinQueryWindow(pDInfo->hwndSource, QW_PARENT) !=
     1599              WinQueryWindow(hwnd, QW_PARENT))
     1600          {
     1601            DrgFreeDraginfo(pDInfo);
     1602            return (MRFROM2SHORT(DOR_DROP, ((fCopyDefault) ? DO_COPY : DO_MOVE)));
     1603          }
     1604        }
     1605        DrgFreeDraginfo(pDInfo);
     1606      }
     1607    }
     1608    return MRFROM2SHORT(DOR_NEVERDROP, 0);
    16081609
    16091610  case DM_DRAGLEAVE:
     
    16151616      PDRAGINFO pDInfo = (PDRAGINFO) mp1;
    16161617      PDRAGITEM pDItem;         /* Pointer to DRAGITEM   */
    1617       ULONG numitems, curitem = 0L, len;
     1618      ULONG numitems, curitem, len;
    16181619      USHORT action;
    16191620      CHAR szFrom[CCHMAXPATH + 2], szDir[CCHMAXPATH + 1],
     
    16221623      INIREC inirec;
    16231624
    1624       DrgAccessDraginfo(pDInfo);        /* Access DRAGINFO       */
     1625      if (!DrgAccessDraginfo(pDInfo)) {
     1626        Win_Error(HWND_DESKTOP, HWND_DESKTOP, pszSrcFile, __LINE__,
     1627                  "DrgAccessDraginfo");
     1628        return 0;
     1629      }
    16251630      numitems = DrgQueryDragitemCount(pDInfo);
    1626       while (curitem < numitems) {
     1631      for (curitem = 0; curitem < numitems; curitem++) {
    16271632        pDItem = DrgQueryDragitemPtr(pDInfo, curitem);
    16281633        if (DrgVerifyRMF(pDItem, DRM_OS2FILE, NULL)) {
     
    16771682                             MPFROMLONG(DMFL_TARGETFAIL));
    16781683        }
    1679         curitem++;
    1680       }
    1681       rc = DeleteDragitemStrHandles(pDInfo); //
    1682 
    1683       if(!rc)
    1684           Win_Error(HWND_DESKTOP, HWND_DESKTOP, pszSrcFile, __LINE__,
    1685                     "DrgDeleteDraginfoStrHandles");
    1686       DrgDeleteDraginfoStrHandles(pDInfo);
    1687       rc = DrgFreeDraginfo(pDInfo);
    1688       if(!rc)
    1689           Win_Error(HWND_DESKTOP, HWND_DESKTOP, pszSrcFile, __LINE__,
    1690                  "DrgFreeDraginfo");
     1684      } // for
     1685      FreeDragInfoData(hwnd, pDInfo);
    16911686    }
    16921687    return 0;
     
    16971692    hwndPopup = (HWND) 0;
    16981693    break;
    1699   }
     1694  } // switch
    17001695  if (oldproc)
    17011696    return oldproc(hwnd, msg, mp1, mp2);
Note: See TracChangeset for help on using the changeset viewer.