discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSAlert fix


From: Wolfgang Lux
Subject: NSAlert fix
Date: Sun, 2 Sep 2007 17:53:52 +0200

While I'm at it, here is another patch. It prevents NSAlert's _setupPanel method from
raising an exception if there are less than three buttons on the panel.

--- Source/NSAlert.m    (Revision 25440)
+++ Source/NSAlert.m    (Arbeitskopie)
@@ -1582,6 +1582,7 @@
     {
       GSAlertPanel *panel;
       NSString *title;
+      unsigned nbut;
       panel = [[GSAlertPanel alloc] init];
       _window = panel;
@@ -1599,13 +1600,14 @@
              title = @"Alert";
              break;
        }
+      nbut = [_buttons count];
       [panel setTitleBar: title
                    icon: _icon
                   title: _informative_text
                 message: _message_text
-                    def: [[_buttons objectAtIndex: 0] title]
-                    alt: [[_buttons objectAtIndex: 1] title]
-                  other: [[_buttons objectAtIndex: 2] title]];
+                    def: (nbut > 0) ? [[_buttons objectAtIndex: 0] title] : nil
+                    alt: (nbut > 1) ? [[_buttons objectAtIndex: 1] title] : nil
+                  other: (nbut > 2) ? [[_buttons objectAtIndex: 2] title] : 
nil];
     }
}

Regards
Wolfgang





reply via email to

[Prev in Thread] Current Thread [Next in Thread]