mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-23 15:11:37 +00:00
* Source/NSImage.m: Remove duplicate #import
* Source/NSImage.m: Correct _clearFileTypeCaches notification method to take a NSNotification* parameter. * Soure/NSImage.m (themeDidActivate:): Move to a class method, and move the GSThemeDidActivateNotification subscription to +[NSImage initialize]. Now the +_themeDidActivate: updates all images by looking at all the values in nameDict. This should function exactly the same as before, but seems to be quite a bit faster due to fewer notifications being sent (?) * Source/NSImage.m (+imageNamed:): Remove redundant fetch from nameDict pointed out by Fred git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@34482 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
378ca9230e
commit
53ac9ad559
2 changed files with 46 additions and 28 deletions
14
ChangeLog
14
ChangeLog
|
@ -1,3 +1,17 @@
|
|||
2012-01-10 Eric Wasylishen <ewasylishen@gmail.com>
|
||||
|
||||
* Source/NSImage.m: Remove duplicate #import
|
||||
* Source/NSImage.m: Correct _clearFileTypeCaches notification
|
||||
method to take a NSNotification* parameter.
|
||||
* Soure/NSImage.m (themeDidActivate:): Move to a class method,
|
||||
and move the GSThemeDidActivateNotification subscription
|
||||
to +[NSImage initialize]. Now the +_themeDidActivate: updates
|
||||
all images by looking at all the values in nameDict. This should
|
||||
function exactly the same as before, but seems to be quite a bit
|
||||
faster due to fewer notifications being sent (?)
|
||||
* Source/NSImage.m (+imageNamed:): Remove redundant fetch from
|
||||
nameDict pointed out by Fred
|
||||
|
||||
2012-01-10 Eric Wasylishen <ewasylishen@gmail.com>
|
||||
|
||||
* Source/NSImage.m (+pathForImageNamed:): Add underscore and
|
||||
|
|
|
@ -37,7 +37,6 @@
|
|||
#import <Foundation/NSKeyedArchiver.h>
|
||||
#import <Foundation/NSLock.h>
|
||||
#import <Foundation/NSNotification.h>
|
||||
#import <Foundation/NSNotification.h>
|
||||
#import <Foundation/NSString.h>
|
||||
#import <Foundation/NSValue.h>
|
||||
|
||||
|
@ -154,7 +153,8 @@ repd_for_rep(NSArray *_reps, NSImageRep *rep)
|
|||
}
|
||||
|
||||
@interface NSImage (Private)
|
||||
+ (void) _clearFileTypeCaches;
|
||||
+ (void) _clearFileTypeCaches: (NSNotification*)notif;
|
||||
+ (void) _themeDidActivate: (NSNotification*)notif;
|
||||
+ (NSString *) _pathForImageNamed: (NSString *)aName;
|
||||
- (BOOL) _useFromFile: (NSString *)fileName;
|
||||
- (BOOL) _loadFromData: (NSData *)data;
|
||||
|
@ -162,7 +162,6 @@ repd_for_rep(NSArray *_reps, NSImageRep *rep)
|
|||
- (BOOL) _resetAndUseFromFile: (NSString *)fileName;
|
||||
- (GSRepData*) _cacheForRep: (NSImageRep*)rep;
|
||||
- (NSCachedImageRep*) _doImageCache: (NSImageRep *)rep;
|
||||
- (void) themeDidActivate: (NSNotification*)notif;
|
||||
@end
|
||||
|
||||
@implementation NSImage
|
||||
|
@ -192,9 +191,15 @@ repd_for_rep(NSArray *_reps, NSImageRep *rep)
|
|||
bitmapClass = [NSBitmapImageRep class];
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
addObserver: self
|
||||
selector: @selector(_clearFileTypeCaches)
|
||||
name: NSImageRepRegistryChangedNotification
|
||||
object: [NSImageRep class]];
|
||||
selector: @selector(_clearFileTypeCaches:)
|
||||
name: NSImageRepRegistryChangedNotification
|
||||
object: [NSImageRep class]];
|
||||
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
addObserver: self
|
||||
selector: @selector(_themeDidActivate:)
|
||||
name: GSThemeDidActivateNotification
|
||||
object: nil];
|
||||
[imageLock unlock];
|
||||
}
|
||||
}
|
||||
|
@ -224,7 +229,6 @@ repd_for_rep(NSArray *_reps, NSImageRep *rep)
|
|||
AUTORELEASE(image);
|
||||
image->_flags.archiveByName = YES;
|
||||
}
|
||||
image = (NSImage*)[nameDict objectForKey: aName];
|
||||
}
|
||||
}
|
||||
IF_NO_GC([[image retain] autorelease]);
|
||||
|
@ -482,11 +486,7 @@ repd_for_rep(NSArray *_reps, NSImageRep *rep)
|
|||
{
|
||||
/* We retain self in case removing from the dictionary releases us */
|
||||
IF_NO_GC([[self retain] autorelease]);
|
||||
[nameDict removeObjectForKey: _name];
|
||||
|
||||
[[NSNotificationCenter defaultCenter] removeObserver: self
|
||||
name: GSThemeDidActivateNotification
|
||||
object: nil];
|
||||
[nameDict removeObjectForKey: _name];
|
||||
DESTROY(_name);
|
||||
}
|
||||
|
||||
|
@ -501,11 +501,6 @@ repd_for_rep(NSArray *_reps, NSImageRep *rep)
|
|||
ASSIGN(_name, aName);
|
||||
|
||||
[nameDict setObject: self forKey: _name];
|
||||
|
||||
[[NSNotificationCenter defaultCenter] addObserver: self
|
||||
selector: @selector(themeDidActivate:)
|
||||
name: GSThemeDidActivateNotification
|
||||
object: nil];
|
||||
|
||||
[imageLock unlock];
|
||||
return YES;
|
||||
|
@ -1815,7 +1810,7 @@ iterate_reps_for_types(NSArray* imageReps, SEL method)
|
|||
|
||||
@implementation NSImage (Private)
|
||||
|
||||
+ (void) _clearFileTypeCaches
|
||||
+ (void) _clearFileTypeCaches: (NSNotification*)notif
|
||||
{
|
||||
RELEASE(imageUnfilteredFileTypes);
|
||||
RELEASE(imageFileTypes);
|
||||
|
@ -1823,6 +1818,25 @@ iterate_reps_for_types(NSArray* imageReps, SEL method)
|
|||
RELEASE(imagePasteboardTypes);
|
||||
}
|
||||
|
||||
+ (void) _themeDidActivate: (NSNotification *)notif
|
||||
{
|
||||
[imageLock lock];
|
||||
|
||||
NSImage *o;
|
||||
NSEnumerator *e = [[nameDict allValues] objectEnumerator];
|
||||
while ((o = (NSImage*)[e nextObject]) != nil)
|
||||
{
|
||||
NSString *newPath = [self _pathForImageNamed: o->_name];
|
||||
if (newPath != nil &&
|
||||
![newPath isEqual: o->_fileName])
|
||||
{
|
||||
[o _resetAndUseFromFile: newPath];
|
||||
}
|
||||
}
|
||||
|
||||
[imageLock unlock];
|
||||
}
|
||||
|
||||
+ (NSString *) _pathForImageNamed: (NSString *)aName
|
||||
{
|
||||
NSString *realName = [nsmapping objectForKey: aName];
|
||||
|
@ -2182,14 +2196,4 @@ iterate_reps_for_types(NSArray* imageReps, SEL method)
|
|||
}
|
||||
}
|
||||
|
||||
- (void) themeDidActivate: (NSNotification *)notif
|
||||
{
|
||||
NSString *newPath = [[self class] _pathForImageNamed: _name];
|
||||
if (newPath != nil &&
|
||||
![newPath isEqual: _fileName])
|
||||
{
|
||||
[self _resetAndUseFromFile: newPath];
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
Loading…
Reference in a new issue