Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Panther NavCreateAskSaveChangesDialog Problem



Hello:

I have a problem and would greatly appreciate your help, since I am
apparently too stupid to fix it. :-p

Upon upgrading to 10.3, I noticed a crash bug in my program and have been
able to narrow it down to a problem with the "Nav Ask Save Changes" sheet. After
selecting "Save" or "Don't Save", the parent window closes. If I then click
in the scroll thumb or pageup/pagedown region of another window's scrollbar,
the program crashes with this backtrace into the toolbox:

******
Exception: EXC_BAD_ACCESS (0x0001)
Codes: KERN_PROTECTION_FAILURE (0x0002) at 0x00000000

Thread 0 Crashed:
#0 0x915620a0 in InternalColor2Index (InternalColor2Index + 68)
#1 0x91564378 in SetPortRGBBackColor (SetPortRGBBackColor + 80)
#2 0x915641b4 in RGBBackColor (RGBBackColor + 48)
#3 0x9281c398 in GetPixMapListHitRegion (GetPixMapListHitRegion + 528)
#4 0x92817b70 in LayoutEngine::HitLayout...
#5 0x9286d9cc in DataEngine::HitTestThemeScrollbarArrows...
#6 0x928a72b8 in HIThemeHitTestScrollBarArrows
#7 0x9286d7b0 in HIScrollBar::GetPartHitSelf
#8 0x9283820c in HIView::IsHitByPointSelf
#9 0x927d52f4 in HIView::EventHandler
#10 0x927d1f94 in DispatchEventToHandlers
#11 0x927d2208 in SendEventToEventTargetInternal
#12 0x927d6600 in SendEventToEventTargetWithOptions
#13 0x927f9174 in SendControlDefHitTest
#14 0x9282a9c8 in HIView::WantsMouseEventSelf
#15 0x927d5368 in HIView::EventHandler
#16 0x927d1f94 in DispatchEventToHandlers
#17 0x927d2208 in SendEventToEventTargetInternal
#18 0x927d6600 in SendEventToEventTargetWithOptions
#19 0x9282443c in SendControlDefWantsMouseEvent
#20 0x92833d34 in HIView::GetClickTarget
#21 0x92833db0 in HIView::GetClickTarget
#22 0x92833db0 in HIView::GetClickTarget
#23 0x92833db0 in HIView::GetClickTarget
#24 0x92878ef8 in HIViewGetViewForMouseEvent
#25 0x928848b8 in HandleWindowClick
#26 0x92865dfc in HandleMouseEvent
#27 0x92827ce4 in StandardWindowEventHandler
#28 0x927d1f94 in DispatchEventToHandlers
#29 0x927d2208 in SendEventToEventTargetInternal
#30 0x927e4634 in SendEventToEventTarget
#31 0x927f2dd8 in HandleMouseEventForWindow
#32 0x927e8704 in HandleMouseEvent
#33 0x927e2bd4 in ToolboxEventDispatcherHandler
#34 0x927d2050 in DispatchEventToHandlers
#35 0x927d2208 in SendEventToEventTargetInternal...
#36 0x927e4634 in SendEventToEventTarget...
#37 0x927e8560 in ToolboxEventDispatcher...
#38 0x92805814 in HLTBEventDispatcher (HLTBEventDispatcher + 16)
#39 0x927fb6b0 in RunApplicationEventLoop (RunApplicationEventLoop + 152)
#40 0x002fff30 in main (TEMain.c:22)
#41 0x000019d0 in start (start + 444)
#42 0x00001844 in start (start + 48)

*******

This problem does not exist in either 10.1 or 10.2. (I re-installed just to
make sure.) The scrollbar instability resolves if I first open a new window
using the normal method (File>New or File>Open... or "make new window at back",
etc.). All scrollbars are affected similarly, even one subsequently created
by CreateScrollingTextBoxControl in a modal dialog (see below). The
scrollbars and the windows otherwise behave perfectly--resizing, drawing, activating,
updating, even the updown scrollbar _arrows_ work perfectly. You just can't
click in the thumb or the pageupdown area.

I use XCode and all my data structures appear to be intact up to the time of
the crash. Attempts at setting the grafport and checking window retain
counts have been unsuccessful. All other navigation sheets behave normally
(NavCreatePutFileDialog, NavCreateAskDiscardChangesDialog) including the pagesetup
and print sheets. Pressing the "Cancel" button causes no residual problems.

My questions:

1) Has anyone else seen this sort of problem? What could be causing this?
2) Are the changes to the NavCreateAskSaveChangesDialog sheet behavior for
10.3 documented anywhere?
3) Is there a big FAQ detailing developer changes with respect to 10.3?
4) Where is the best place to find sample code that illustrates the
simultaneous use of Carbon Events, NavDialogSheets, nib-based resources? I had been
using the WASTE demo code, but it crashes too!
5) Possibly related: Why does the cmd-D shortcut for the
NavCreateAskSaveChangesDialog sheet now "leak through" to my main menu handler? (This did not
happen pre-10.3) I had to remove the cmd-D shortcut from my menu due to
interference.

My program lives at:
http://idisk.mac.com/tombb/Public/tex-edit-plus-X-beta.sit
if you wish to see it crash in person! ;-)

Here is a skeleton:

/******/
pascal void MyAskSaveChangesProc ( NavEventCallbackMessage
inCallBackSelector,
NavCBRecPtr
inCallBackParms,
NavCallBackUserData inCallBackUD
)
{
switch ( inCallBackSelector )
{
case kNavCBUserAction:
{
switch ( NavDialogGetUserAction( inCallBackParms->context ) )
{
case kNavUserActionSaveChanges:
DoSave( ( WindowRef )inCallBackUD );
break;
case kNavUserActionDontSaveChanges:
DoFinishClose( ( WindowRef )inCallBackUD );
break;
default:
...cancel...
break;
}
break;
}
case kNavCBTerminate:
NavDialogDispose( inCallBackParms->context );
break;
}
}
/******/
OSStatus MyDoNavAskSaveChanges ( ... )
{
myErr = NavGetDefaultDialogCreationOptions( &options );
options.clientName = CFStringCreateWithPascalString( NULL,
LMGetCurApName(), GetApplicationTextEncoding() );
options.modality = kWindowModalityWindowModal;
options.parentWindow = inWPtr;
myErr = CopyWindowTitleAsCFString( inWPtr, &options.saveFileName );

myErr = NavCreateAskSaveChangesDialog(...);
myErr = NavDialogRun( dialogHdl );

MyCFRelease( options.clientName );
MyCFRelease( options.saveFileName );
if ( myErr && ( dialogHdl != NULL ) )
NavDialogDispose( dialogHdl );
}
/******/
OSStatus MyCreateWindow ( ... )
{
...

myErr = CreateNibReference( CFSTR( "main" ), &nibRef );
myErr = CreateWindowFromNib( nibRef, CFSTR( "MainWindow" ), wPtr );
DisposeNibReference( nibRef );
myErr = InstallWindowCarbonEventHandlers( *wPtr );

...etc...

ShowWindow( *wPtr );
}
/******/

OSStatus MyDestroyWindow ( WindowRef * ioWPtr )
{
if ( IsMyWindow( *ioWPtr ) )
{
HideWindow( *ioWPtr )

...etc...

ReleaseWindow( *ioWPtr ); // **** if this line is removed, the
crash is
// **** prevented, but there is a memory
leak
}
}

/******/
OSStatus MyDoAboutDialog ( void )
{
myErr = CreateNibReference( CFSTR( "dialogs" ), &nibRef );
myErr = CreateWindowFromNib( nibRef, CFSTR( "about" ), &dlgWPtr );
DisposeNibReference( nibRef );

myErr = InstallWindowEventHandler(...);
myErr = InstallWindowEventHandler(...);
myErr = CreateScrollingTextBoxControl(...);

// **** the scrollbar in the ScrollingTextBox also crashes, just the
same as any document scrollbar
// **** This crash is avoided if I precede the RunAppModalLoopForWindow
with a SetPortWindowPort call (a clue!!!)
if ( !myErr )
{
ShowWindow( dlgWPtr );
myErr = RunAppModalLoopForWindow( dlgWPtr );
HideWindow( dlgWPtr );
}
}
/******/

Thank you for your help!
Sincerely,
Tom Bender
email@hidden
_______________________________________________
carbon-development mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/carbon-development
Do not post admin requests to the list. They will be ignored.



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.