Added some debug code to trace get/set of data.

Tidied setData:forType:isFile:oldCount: for the case where we are setting
file content.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@2414 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
richard 1997-09-11 13:42:03 +00:00
parent c9078c4536
commit 0cf014e36e

View file

@ -113,6 +113,9 @@ NSMutableDictionary* pasteboards = nil;
- (NSData*) data - (NSData*) data
{ {
if (verbose) {
printf("get data for %x\n", (unsigned)self);
}
return data; return data;
} }
@ -120,13 +123,13 @@ NSMutableDictionary* pasteboards = nil;
{ {
if (data == nil && (owner && pboard)) { if (data == nil && (owner && pboard)) {
if (hasGNUDataForType) { if (hasGNUDataForType) {
[owner pasteboard: pboard provideDataForType: type andVersion: version]; [pboard askOwner:owner toProvideDataForType: type andVersion: version];
} }
else if (hasStdDataForType) { else if (hasStdDataForType) {
[owner pasteboard: pboard provideDataForType: type]; [pboard askOwner:owner toProvideDataForType: type];
} }
} }
return data; return [self data];
} }
- (id) owner - (id) owner
@ -141,6 +144,9 @@ NSMutableDictionary* pasteboards = nil;
- (void) setData: (NSData*)d - (void) setData: (NSData*)d
{ {
if (verbose) {
printf("set data for %x\n", (unsigned)self);
}
[d retain]; [d retain];
[data release]; [data release];
data = d; data = d;
@ -208,7 +214,7 @@ NSMutableDictionary* pasteboards = nil;
e->hasStdDataForType = YES; e->hasStdDataForType = YES;
} }
if (anOwner && [anOwner respondsToSelector: if (anOwner && [anOwner respondsToSelector:
@selector(pasteboard:provideDataForType:version:)]) { @selector(pasteboard:provideDataForType:andVersion:)]) {
e->hasGNUDataForType = YES; e->hasGNUDataForType = YES;
} }
@ -247,7 +253,7 @@ NSMutableDictionary* pasteboards = nil;
StdData = YES; StdData = YES;
} }
if (owner && [owner respondsToSelector: if (owner && [owner respondsToSelector:
@selector(pasteboard:provideDataForType:version:)]) { @selector(pasteboard:provideDataForType:andVersion:)]) {
GNUData = YES; GNUData = YES;
} }
@ -296,7 +302,7 @@ NSMutableDictionary* pasteboards = nil;
[d checkConnection: c]; [d checkConnection: c];
if ([d data] == nil && [d owner] == nil) { if ([d data] == nil && [d owner] == nil) {
[items removeObjectAtIndex:i]; [items removeObjectAtIndex:i-1];
} }
} }
} }
@ -535,6 +541,10 @@ NSMutableDictionary* pasteboards = nil;
else { else {
e = [self entryByCount:count]; e = [self entryByCount:count];
} }
if (verbose) {
printf("get data for type '%s' version %d\n",
[type cStringNoCopy], e ? [e refNum] : -1);
}
if (e) { if (e) {
PasteboardData* d = [e itemForType: type]; PasteboardData* d = [e itemForType: type];
@ -612,8 +622,13 @@ NSMutableDictionary* pasteboards = nil;
isFile: (BOOL)flag isFile: (BOOL)flag
oldCount: (int)count oldCount: (int)count
{ {
PasteboardEntry* e = [self entryByCount: count]; PasteboardEntry* e;
if (verbose) {
printf("set data for type '%s' version %d\n",
[type cStringNoCopy], count);
}
e = [self entryByCount: count];
if (e) { if (e) {
PasteboardData* d; PasteboardData* d;
@ -625,17 +640,30 @@ NSMutableDictionary* pasteboards = nil;
else { else {
return NO; return NO;
} }
if (type && [type isEqual: NSFileContentsPboardType] == NO) {
d = [e itemForType: type];
if (d) {
[d setData: data];
}
else {
return NO;
}
}
return YES;
} }
if (type && ![type isEqual: NSFileContentsPboardType]) { else if (type) {
d = [e itemForType: type]; d = [e itemForType: type];
if (d) { if (d) {
[d setData: data]; [d setData: data];
return YES;
} }
else { else {
return NO; return NO;
} }
} }
return YES; else {
return NO;
}
} }
else { else {
return NO; return NO;