@@ -1774,46 +1774,55 @@ void NSBeginInformationalAlertSheet(NSString *title,
17741774// NSRunAlertPanel which shows a modal alert. Otherwise display a sheet
17751775// attached to docWindow and run a modal loop until it completes.
17761776NSInteger
1777- NSRunAlertPanelRelativeToWindow (NSWindow *docWindow ,
1778- NSString *title ,
1779- NSString *msg ,
1780- NSString *defaultButton ,
1781- NSString *alternateButton ,
1782- NSString *otherButton , ...)
1777+ NSRunAlertPanelRelativeToWindow (NSString *title ,
1778+ NSString *msg ,
1779+ NSString *defaultButton ,
1780+ NSString *alternateButton ,
1781+ NSString *otherButton ,
1782+ NSWindow *docWindow , ...)
17831783{
17841784 va_list ap;
1785- NSString *message;
1786- GSAlertPanel *panel;
1787- NSInteger result;
1785+ NSString *message = nil ;
1786+ GSAlertPanel *panel = nil ;
1787+ NSInteger result = 0 ;
17881788
1789- va_start (ap, otherButton );
1789+ va_start (ap, docWindow );
17901790 message = [NSString stringWithFormat: msg arguments: ap];
17911791 va_end (ap);
17921792
1793+ // Set the default button...
1794+ if (defaultButton == nil )
1795+ {
1796+ defaultButton = @" OK" ;
1797+ }
1798+
1799+ // Show a panel or a sheet depending on if we have a window...
17931800 if (docWindow == nil )
17941801 {
1795- if (defaultButton == nil )
1796- defaultButton = @" OK" ;
1797- panel = getSomePanel (&standardAlertPanel, defaultTitle, title, message,
1802+ panel = getSomePanel (&standardAlertPanel,
1803+ defaultTitle,
1804+ title,
1805+ message,
17981806 defaultButton, alternateButton, otherButton);
1807+
17991808 result = [panel runModal ];
1800- NSReleaseAlertPanel (panel);
1801- return result;
18021809 }
1810+ else
1811+ {
1812+ panel = getSomeSheet (&standardAlertPanel,
1813+ defaultTitle,
1814+ title,
1815+ message,
1816+ defaultButton, alternateButton, otherButton);
18031817
1804- if (defaultButton == nil )
1805- defaultButton = @" OK" ;
1806-
1807- panel = getSomeSheet (&standardAlertPanel, defaultTitle, title, message,
1808- defaultButton, alternateButton, otherButton);
1809-
1810- [panel makeKeyAndOrderFront: nil ];
1811- [NSApp beginSheet: panel
1812- modalForWindow: docWindow
1813- modalDelegate: nil
1814- didEndSelector: NULL
1815- contextInfo: NULL ];
1816- result = [panel result ];
1818+ [NSApp beginSheet: panel
1819+ modalForWindow: docWindow
1820+ modalDelegate: nil
1821+ didEndSelector: NULL
1822+ contextInfo: NULL ];
1823+
1824+ result = [panel result ];
1825+ }
18171826
18181827 NSReleaseAlertPanel (panel);
18191828 return result;
0 commit comments