mirror of
https://github.com/fltk/fltk.git
synced 2026-09-28 15:55:22 +08:00
STR#2121: added a break in the flavortypes main loop just in case one day we have more than one to choose from so that the order of the one choosed is guaranteed, also fixed potential memory leaks by releasing flavorTypeArray when exiting the main loop prematurely.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@6635 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
+8
-4
@@ -2499,7 +2499,7 @@ void Fl_X::q_end_image() {
|
||||
// Copy & Paste fltk implementation.
|
||||
////////////////////////////////////////////////////////////////
|
||||
|
||||
// fltk 1.3 clipboard constant support definitions:
|
||||
// fltk 1.3 clipboard support constant definitions:
|
||||
const CFStringRef flavorNames[] = {
|
||||
CFSTR("public.utf16-plain-text"),
|
||||
CFSTR("public.utf8-plain-text"),
|
||||
@@ -2597,9 +2597,12 @@ void Fl::paste(Fl_Widget &receiver, int clipboard) {
|
||||
err = PasteboardGetItemIdentifier(myPasteboard, i, &itemID);
|
||||
if (err!=noErr) continue;
|
||||
err = PasteboardCopyItemFlavors(myPasteboard, itemID, &flavorTypeArray);
|
||||
if (err!=noErr) continue;
|
||||
if (err!=noErr) {
|
||||
if (flavorTypeArray) {CFRelease (flavorTypeArray); flavorTypeArray = NULL;}
|
||||
continue;
|
||||
}
|
||||
flavorCount = CFArrayGetCount(flavorTypeArray);
|
||||
for(j = 0; j < handledFlavorsCount; j++) {
|
||||
for (j = 0; j < handledFlavorsCount; j++) {
|
||||
for (CFIndex flavorIndex=0; flavorIndex<flavorCount; flavorIndex++) {
|
||||
CFStringRef flavorType;
|
||||
flavorType = (CFStringRef)CFArrayGetValueAtIndex(flavorTypeArray, flavorIndex);
|
||||
@@ -2613,7 +2616,8 @@ void Fl::paste(Fl_Widget &receiver, int clipboard) {
|
||||
}
|
||||
if(found) break;
|
||||
}
|
||||
CFRelease (flavorTypeArray);
|
||||
if (flavorTypeArray) {CFRelease (flavorTypeArray); flavorTypeArray = NULL;}
|
||||
if (found) break;
|
||||
}
|
||||
if(found) {
|
||||
CFIndex len;
|
||||
|
||||
Reference in New Issue
Block a user