From e55bc9a4ff29ef6fcaff066cd861d8b8d1c41c51 Mon Sep 17 00:00:00 2001 From: Stefan Csomor Date: Sat, 15 Feb 2003 08:38:04 +0000 Subject: [PATCH] Files from a Drop were only added but the fileslist never cleared git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_4_BRANCH@19226 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/mac/carbon/dnd.cpp | 15 +++++++++++++-- src/mac/dnd.cpp | 15 +++++++++++++-- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/src/mac/carbon/dnd.cpp b/src/mac/carbon/dnd.cpp index 5369a1cf34..c4c44bdfd4 100644 --- a/src/mac/carbon/dnd.cpp +++ b/src/mac/carbon/dnd.cpp @@ -173,6 +173,7 @@ bool wxDropTarget::GetData() { UInt16 items ; OSErr result; + bool firstFileAdded = false ; CountDragItems((DragReference)m_currentDrag, &items); for (UInt16 index = 1; index <= items; ++index) { @@ -195,7 +196,11 @@ bool wxDropTarget::GetData() Ptr theData ; GetFlavorDataSize((DragReference)m_currentDrag, theItem, theType, &dataSize); if ( theType == 'TEXT' ) + { + // this increment is only valid for allocating, on the next GetFlavorData + // call it is reset again to the original value dataSize++ ; + } theData = new char[dataSize]; GetFlavorData((DragReference)m_currentDrag, theItem, theType, (void*) theData, &dataSize, 0L); if( theType == 'TEXT' ) @@ -203,7 +208,7 @@ bool wxDropTarget::GetData() theData[dataSize]=0 ; if ( wxApp::s_macDefaultEncodingIsPC ) { - wxMacConvertToPC((char*)theData) ; + wxMacConvertToPC((char*)theData,(char*)theData,dataSize) ; } m_dataObject->SetData( format, dataSize, theData ); } @@ -211,7 +216,13 @@ bool wxDropTarget::GetData() { HFSFlavor* theFile = (HFSFlavor*) theData ; wxString name = wxMacFSSpec2MacFilename( &theFile->fileSpec ) ; - ((wxFileDataObject*)m_dataObject)->AddFile( name ) ; + if ( firstFileAdded ) + ((wxFileDataObject*)m_dataObject)->AddFile( name ) ; + else + { + ((wxFileDataObject*)m_dataObject)->SetData( 0 , name.c_str() ) ; + firstFileAdded = true ; + } } else { diff --git a/src/mac/dnd.cpp b/src/mac/dnd.cpp index 5369a1cf34..c4c44bdfd4 100644 --- a/src/mac/dnd.cpp +++ b/src/mac/dnd.cpp @@ -173,6 +173,7 @@ bool wxDropTarget::GetData() { UInt16 items ; OSErr result; + bool firstFileAdded = false ; CountDragItems((DragReference)m_currentDrag, &items); for (UInt16 index = 1; index <= items; ++index) { @@ -195,7 +196,11 @@ bool wxDropTarget::GetData() Ptr theData ; GetFlavorDataSize((DragReference)m_currentDrag, theItem, theType, &dataSize); if ( theType == 'TEXT' ) + { + // this increment is only valid for allocating, on the next GetFlavorData + // call it is reset again to the original value dataSize++ ; + } theData = new char[dataSize]; GetFlavorData((DragReference)m_currentDrag, theItem, theType, (void*) theData, &dataSize, 0L); if( theType == 'TEXT' ) @@ -203,7 +208,7 @@ bool wxDropTarget::GetData() theData[dataSize]=0 ; if ( wxApp::s_macDefaultEncodingIsPC ) { - wxMacConvertToPC((char*)theData) ; + wxMacConvertToPC((char*)theData,(char*)theData,dataSize) ; } m_dataObject->SetData( format, dataSize, theData ); } @@ -211,7 +216,13 @@ bool wxDropTarget::GetData() { HFSFlavor* theFile = (HFSFlavor*) theData ; wxString name = wxMacFSSpec2MacFilename( &theFile->fileSpec ) ; - ((wxFileDataObject*)m_dataObject)->AddFile( name ) ; + if ( firstFileAdded ) + ((wxFileDataObject*)m_dataObject)->AddFile( name ) ; + else + { + ((wxFileDataObject*)m_dataObject)->SetData( 0 , name.c_str() ) ; + firstFileAdded = true ; + } } else {