macOS fixing potential crash in PasteboardWriter
using a pasteboard peeker tool lead to a crash when the drag pasteboard was accessed after our session has long finished. Make sure the writer is working correctly event after the data object is not valid anymore
This commit is contained in:
@@ -451,20 +451,29 @@ typedef NSString* NSPasteboardType;
|
|||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void) clearDataObject
|
||||||
|
{
|
||||||
|
m_data = NULL;
|
||||||
|
}
|
||||||
- (nullable id)pasteboardPropertyListForType:(nonnull NSPasteboardType)type
|
- (nullable id)pasteboardPropertyListForType:(nonnull NSPasteboardType)type
|
||||||
{
|
{
|
||||||
wxDataFormat format((wxDataFormat::NativeFormat) type);
|
if ( m_data )
|
||||||
size_t size = m_data->GetDataSize(format);
|
{
|
||||||
CFMutableDataRef data = CFDataCreateMutable(kCFAllocatorDefault,size );
|
wxDataFormat format((wxDataFormat::NativeFormat) type);
|
||||||
m_data->GetDataHere(format, CFDataGetMutableBytePtr(data));
|
size_t size = m_data->GetDataSize(format);
|
||||||
CFDataSetLength(data, size);
|
CFMutableDataRef data = CFDataCreateMutable(kCFAllocatorDefault,size );
|
||||||
return (id) data;
|
m_data->GetDataHere(format, CFDataGetMutableBytePtr(data));
|
||||||
|
CFDataSetLength(data, size);
|
||||||
|
return (id) data;
|
||||||
|
}
|
||||||
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (nonnull NSArray<NSPasteboardType> *)writableTypesForPasteboard:(nonnull NSPasteboard *)pasteboard
|
- (nonnull NSArray<NSPasteboardType> *)writableTypesForPasteboard:(nonnull NSPasteboard *)pasteboard
|
||||||
{
|
{
|
||||||
wxCFMutableArrayRef<CFStringRef> typesarray;
|
wxCFMutableArrayRef<CFStringRef> typesarray;
|
||||||
m_data->AddSupportedTypes(typesarray, wxDataObjectBase::Direction::Get);
|
if ( m_data )
|
||||||
|
m_data->AddSupportedTypes(typesarray, wxDataObjectBase::Direction::Get);
|
||||||
return (NSArray<NSPasteboardType>*) typesarray.autorelease();
|
return (NSArray<NSPasteboardType>*) typesarray.autorelease();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -521,6 +530,8 @@ wxDragResult wxDropSource::DoDragDrop(int flags)
|
|||||||
result = NSDragOperationToWxDragResult([delegate code]);
|
result = NSDragOperationToWxDragResult([delegate code]);
|
||||||
[delegate release];
|
[delegate release];
|
||||||
[image release];
|
[image release];
|
||||||
|
[writer clearDataObject];
|
||||||
|
[writer release];
|
||||||
|
|
||||||
wxWindow* mouseUpTarget = wxWindow::GetCapture();
|
wxWindow* mouseUpTarget = wxWindow::GetCapture();
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user