Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 15f1c08

Browse files
committed
- Raise console window on input. Fixes Carbon hang.
- Better handling of menu bar save/restore. - Override abort() so it honours the "keep console window" flag.
1 parent ee67791 commit 15f1c08

3 files changed

Lines changed: 32 additions & 4 deletions

File tree

Mac/Python/macglue.c

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -685,11 +685,13 @@ PyMac_DoYield(int maxsleep, int maycallpython)
685685
*/
686686
if( in_here > 1 || !schedparams.process_events ||
687687
(python_event_handler && !maycallpython) ) {
688-
#if !TARGET_API_MAC_CARBON
689688
if ( maxsleep >= 0 ) {
689+
#if !TARGET_API_MAC_CARBON
690690
SystemTask();
691-
}
691+
#else
692+
int xxx = 0;
692693
#endif
694+
}
693695
} else {
694696
latest_time_ready = LMGetTicks() + maxsleep;
695697
do {
@@ -768,6 +770,7 @@ PyMac_InitMenuBar()
768770
{
769771
MenuHandle applemenu;
770772

773+
if ( sioux_mbar ) return;
771774
if ( (sioux_mbar=GetMenuBar()) == NULL ) {
772775
/* Sioux menu not installed yet. Do so */
773776
SIOUXSetupMenus();
@@ -784,7 +787,7 @@ PyMac_InitMenuBar()
784787
void
785788
PyMac_RestoreMenuBar()
786789
{
787-
#if 0
790+
#if 1
788791
/* This doesn't seem to work anymore? Or only for Carbon? */
789792
MenuBarHandle curmenubar;
790793

@@ -799,6 +802,19 @@ PyMac_RestoreMenuBar()
799802
#endif
800803
}
801804

805+
void
806+
PyMac_RaiseConsoleWindow()
807+
{
808+
/* Note: this is a hack. SIOUXTextWindow is SIOUX's internal structure
809+
** and we happen to know that the first entry is the window pointer.
810+
*/
811+
extern WindowRef *SIOUXTextWindow;
812+
813+
if ( SIOUXTextWindow == NULL || *SIOUXTextWindow == NULL )
814+
return;
815+
if ( FrontWindow() != *SIOUXTextWindow )
816+
BringToFront(*SIOUXTextWindow);
817+
}
802818

803819
/*
804820
** Our replacement about box

Mac/Python/macmain.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,16 @@ PyMac_OutputNotSeen()
567567
PyMac_InitMenuBar();
568568
console_output_state = STATE_LASTWRITE;
569569
}
570-
570+
571+
/*
572+
** Override abort() - The default one is not what we want.
573+
*/
574+
void
575+
abort()
576+
{
577+
console_output_state = STATE_LASTWRITE;
578+
PyMac_Exit(1);
579+
}
571580

572581
/*
573582
** Terminate application
@@ -605,6 +614,7 @@ PyMac_Exit(status)
605614
SIOUXSettings.standalone = 1;
606615
SIOUXSettings.autocloseonquit = 0;
607616
SIOUXSetTitle("\p\307terminated\310");
617+
PyMac_RaiseConsoleWindow();
608618
PyMac_RestoreMenuBar();
609619
#ifdef USE_MSL
610620
/*

Mac/Python/pyGUSISIOUX.cp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ GUSISIOUXSocket::Initialize()
102102
GUSISetHook(GUSI_EventHook+diskEvt, (GUSIHook)SIOUXHandleOneEvent);
103103
GUSISetHook(GUSI_EventHook+activateEvt, (GUSIHook)SIOUXHandleOneEvent);
104104
GUSISetHook(GUSI_EventHook+osEvt, (GUSIHook)SIOUXHandleOneEvent);
105+
PyMac_InitMenuBar();
105106
}
106107
GUSISIOUXSocket::~GUSISIOUXSocket()
107108
{
@@ -113,6 +114,7 @@ ssize_t GUSISIOUXSocket::read(const GUSIScatterer & buffer)
113114
if ( !initialized ) Initialize();
114115
GUSIStdioFlush();
115116
PyMac_OutputSeen();
117+
PyMac_RaiseConsoleWindow();
116118
return buffer.SetLength(
117119
ReadCharsFromConsole((char *) buffer.Buffer(), (int)buffer.Length()));
118120
GUSIContext::Yield(kGUSIPoll);

0 commit comments

Comments
 (0)