diff --git a/ChangeLog b/ChangeLog index 66c2f035..3f501fda 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2005-02-19 02:29 Gregory John Casamento + + * Defaults.plist: Added new default "AllowUserBundles" to + disable new code which prevents Gorm from running if a + user bundle is present. + * Gorm.m: Added code in [Gorm applicationDidFinishLaunching:] + to warn the user and quit, unless the above default is set, + if there is a user bundle loaded. It will give the user + a few panels explaining what's going on. + 2005-02-15 23:37 Gregory John Casamento * GormPosingView.[hm]: Removed. diff --git a/Defaults.plist b/Defaults.plist index 21037ba1..e9205f2e 100644 --- a/Defaults.plist +++ b/Defaults.plist @@ -1,22 +1,25 @@ { - PreloadHeaders = NO; - ShowPalettes = YES; - ShowInspectors = YES; - HeaderList = (); - CellSizeWidth = 72; - ArchiveType = Typed; - GuideColor = { - alpha = 1; - blue = 0; - green = 0; - red = 1; - }; - BuiltinPalettes = ( - "0Menus.palette", - "1Windows.palette", - "2Controls.palette", - "3Containers.palette", - "4Data.palette" - ); - UserPalettes = (); -} + AllowUserBundles = NO; + ArchiveType = Typed; + BuiltinPalettes = ( + 0Menus.palette, + 1Windows.palette, + 2Controls.palette, + 3Containers.palette, + 4Data.palette + ); + CellSizeWidth = 72; + GuideColor = { + alpha = 1; + blue = 0; + green = 0; + red = 1; + }; + HeaderList = ( + ); + PreloadHeaders = NO; + ShowInspectors = YES; + ShowPalettes = YES; + UserPalettes = ( + ); +} \ No newline at end of file diff --git a/Gorm.m b/Gorm.m index 6cdba583..96455b70 100644 --- a/Gorm.m +++ b/Gorm.m @@ -44,6 +44,9 @@ NSString *GormResizeCellNotification = @"GormResizeCellNotification"; // Define this as "NO" initially. We only want to turn this on while loading or testing. static BOOL _isInInterfaceBuilder = NO; +// Has poseAs: been called? +static BOOL _illegalClassSubstitution = NO; + static NSImage *gormImage = nil; static NSImage *testingImage = nil; @@ -107,8 +110,14 @@ static NSImage *testingImage = nil; @implementation NSObject (GormPrivate) + (void) poseAsClass: (Class)aClassObject { + BOOL allow = [[NSUserDefaults standardUserDefaults] boolForKey: @"AllowUserBundles"]; + // disable poseAs: while in Gorm. - // class_pose_as(self, aClassObject); + class_pose_as(self, aClassObject); + if(!allow) + { + _illegalClassSubstitution = YES; + } } @end @@ -331,12 +340,25 @@ static NSImage *testingImage = nil; { [[[self palettesManager] panel] makeKeyAndOrderFront: self]; } - if((a = [defaults arrayForKey: @"GSAppKitUserBundles"]) != nil) + if((a = [defaults arrayForKey: @"GSAppKitUserBundles"]) != nil || + _illegalClassSubstitution == YES) { if([a count] > 0) { - NSLog(@"WARNING: Gorm has detected that you are using user bundles. Please make certain that these are compatible with Gorm as some bundles can cause issues which may corrupt your .gorm files."); + NSRunAlertPanel(_(@"User Bundle Warning"), + _(@"Gorm has detected that you are using user bundles. Please make certain that these are compatible with Gorm as some bundles can cause issues which may corrupt your .gorm files."), + _(@"OK"), nil, nil); } + + if(_illegalClassSubstitution == YES) + { + NSRunAlertPanel(_(@"Illegal Class Substitution"), + _(@"A bundle has invoked 'poseAsClass:', this could corrupt .gorm files. Quitting."), + _(@"OK"), nil, nil); + NSBeep(); + [self terminate: self]; + } + } if(GSGetMethod([GSNibContainer class],@selector(awakeWithContext:),YES,YES) == NULL) {