diff options
| author | Fabien Costantini <fabien@onepost.net> | 2009-01-16 14:39:41 +0000 |
|---|---|---|
| committer | Fabien Costantini <fabien@onepost.net> | 2009-01-16 14:39:41 +0000 |
| commit | b7e9f1eb770321a50df266631694b0ac2259daf9 (patch) | |
| tree | cc510b1c524f58ed3ef809d64797ed2a9e07ea15 | |
| parent | b511a4df08a27d4b3b166a9cbf21639b37c84543 (diff) | |
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
| -rw-r--r-- | src/Fl_mac.cxx | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/Fl_mac.cxx b/src/Fl_mac.cxx index 7652de5e0..7c4689250 100644 --- a/src/Fl_mac.cxx +++ b/src/Fl_mac.cxx @@ -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; |
