Changeset 628 for trunk/dll/draglist.c


Ignore:
Timestamp:
Apr 22, 2007, 6:56:32 AM (18 years ago)
Author:
Steven Levine
Message:

Avoid odd first time drag failure

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/dll/draglist.c

    r618 r628  
    1717  19 Apr 07 SHL Add more drag/drop error checking
    1818  19 Apr 07 SHL Optimize DRAGITEM DRAGIMAGE array access
     19  21 Apr 07 SHL Avoid odd first time drag failure
    1920
    2021***********************************************************************/
     
    218219  DRAGIMAGE *paDImgIcons = NULL, *pDImg, dimgFakeIcon;
    219220  BOOL ok;
     221  UINT c;
     222
     223  static BOOL first_drag = TRUE;
    220224
    221225  // fixme to be multi-drag safe - count needs to be in DCD etc. and passed to UnHilite
     
    333337      if (!ok) {
    334338        DbgMsg(pszSrcFile, __LINE__, "DrgAddStrHandle failed at %lu for %s", ulNumfiles, szFile);
    335         // Win_Error(HWND_DESKTOP, HWND_DESKTOP, pszSrcFile, __LINE__,"DrgAddStrHandle");
    336         if (pDItem->hstrType)
    337           DrgDeleteStrHandle(pDItem->hstrType);
    338         if (pDItem->hstrRMF)
    339           DrgDeleteStrHandle(pDItem->hstrRMF);
    340         if (pDItem->hstrContainerName)
    341           DrgDeleteStrHandle(pDItem->hstrContainerName);
    342         if (pDItem->hstrSourceName)
    343           DrgDeleteStrHandle(pDItem->hstrSourceName);
    344         if (pDItem->hstrTargetName)
    345           DrgDeleteStrHandle(pDItem->hstrTargetName);
    346         xfree(pDItem);
    347         // ppDItem[ulNumfiles] = NULL;  // Why bother - we can count - fixme to be gone
    348         NumItemsToUnhilite = ulNumfiles + 1;    // Use +1 to ensure non-zero on any failure
     339        // If we have string handle add overflow, release corrupt DragItem
     340        // We release 3 more to work around 1st time drag failure reported by Gregg
     341        // fixme to know why this happens - PM may need to create a handle?
     342        c = first_drag ? 4 : 1;
     343        first_drag = FALSE;
     344        for (; c > 0 && ulNumfiles > 0; c--) {
     345          if (pDItem->hstrType)
     346            DrgDeleteStrHandle(pDItem->hstrType);
     347          if (pDItem->hstrRMF)
     348            DrgDeleteStrHandle(pDItem->hstrRMF);
     349          if (pDItem->hstrContainerName)
     350            DrgDeleteStrHandle(pDItem->hstrContainerName);
     351          if (pDItem->hstrSourceName)
     352            DrgDeleteStrHandle(pDItem->hstrSourceName);
     353          if (pDItem->hstrTargetName)
     354            DrgDeleteStrHandle(pDItem->hstrTargetName);
     355          xfree(pDItem);
     356          // Last item not yet count so only decrement by one less than loop count
     357          // Unhilite code will adjust this when unhighliting
     358          if (c > 1) {
     359            ulNumfiles--;
     360            pDItem = ppDItem[ulNumfiles];
     361          }
     362        }
     363        // Set count to actual count + 1 to ensure count non-zero on any failure
     364        NumItemsToUnhilite = ulNumfiles + 1;
    349365        break;
    350366      }
     
    364380      ulNumfiles++;
    365381      // ppDItem[ulNumfiles] = NULL;    // Why bother - can't we count - fixme to be gone?
    366     }
     382    } // if filesystem object
    367383    else {
    368384      // Archive object
     
    439455        if (!ok) {
    440456          DbgMsg(pszSrcFile, __LINE__, "DrgAddStrHandle failed at %lu for %s", ulNumfiles, szFile);
    441           if (pDItem->hstrType)
    442             DrgDeleteStrHandle(pDItem->hstrType);
    443           if (pDItem->hstrRMF)
    444             DrgDeleteStrHandle(pDItem->hstrRMF);
    445           if (pDItem->hstrContainerName)
    446             DrgDeleteStrHandle(pDItem->hstrContainerName);
    447           if (pDItem->hstrSourceName)
    448             DrgDeleteStrHandle(pDItem->hstrSourceName);
    449           if (pDItem->hstrTargetName)
    450             DrgDeleteStrHandle(pDItem->hstrTargetName);
    451           xfree(pDItem);
    452           // pDItem = NULL;             // Why bother - fixme to be gone?
     457          // If we have string handle add overflow, release corrupt DragItem
     458          // We release 3 more to work around 1st time drag failure reported by Gregg
     459          // fixme to know why this happens - PM may need to create a handle?
     460          c = first_drag ? 4 : 1;
     461          first_drag = FALSE;
     462          for (; c > 0 && ulNumfiles > 0; c--) {
     463            if (pDItem->hstrType)
     464              DrgDeleteStrHandle(pDItem->hstrType);
     465            if (pDItem->hstrRMF)
     466              DrgDeleteStrHandle(pDItem->hstrRMF);
     467            if (pDItem->hstrContainerName)
     468              DrgDeleteStrHandle(pDItem->hstrContainerName);
     469            if (pDItem->hstrSourceName)
     470              DrgDeleteStrHandle(pDItem->hstrSourceName);
     471            if (pDItem->hstrTargetName)
     472              DrgDeleteStrHandle(pDItem->hstrTargetName);
     473            xfree(pDItem);
     474            // Last item not yet count so only decrement by one less than loop count
     475            if (c > 1) {
     476              ulNumfiles--;
     477              pDItem = ppDItem[ulNumfiles];
     478            }
     479          }
     480          // Set count to actual count + 1 to ensure count non-zero on any failure
     481          // Unhilite code will adjust this when unhighliting
    453482          NumItemsToUnhilite = ulNumfiles + 1;
    454483          break;
     
    462491      }
    463492      // ppDItem[ulNumfiles] = NULL;    // Why bother - fixme to be gone?
    464     }
     493    } // if archive object
    465494    WinSendMsg(hwndCnr, CM_SETRECORDEMPHASIS, MPFROMP(pci),
    466495               MPFROM2SHORT(TRUE, CRA_SOURCE));
Note: See TracChangeset for help on using the changeset viewer.