open({modal:true}) throwing NSException

243 Views Asked by At

I am receiving a NSException when I click on my rightNavButton to try and open up a new window. However when I do this it suddenly quits the emulator and gives me a NSException error. I have done research on the subject and have not come across the same problem. My js file that I am trying to open does not have any errors in it and this is the error that I keep getting:

{[ERROR] The application has crashed with an unhandled exception. Stack trace:
0   CoreFoundation                      0x0238c58c __exceptionPreprocess + 156
1   libobjc.A.dylib                     0x024e0313 objc_exception_throw + 44
2   CoreFoundation                      0x02344ef8 +[NSException raise:format:arguments:] + 136
3   Foundation                          0x007313bb -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 116
4   UIKit                               0x00be51d6 -[UIWindowController transition:fromViewController:toViewController:target:didEndSelector:] + 290
5   UIKit                               0x009ea65d -[UIViewController presentModalViewController:withTransition:] + 3478
6   DiscountShelving                    0x00198716 -[TiApp attachModal:toController:animated:] + 166
7   DiscountShelving                    0x00198751 -[TiApp attachModal:toController:animated:] + 225
8   DiscountShelving                    0x0019865a -[TiApp showModalController:animated:] + 474
9   DiscountShelving                    0x00063172 -[TiWindowProxy openOnUIThread:] + 2978
10  Foundation                          0x006b594e __NSThreadPerformPerform + 251
11  CoreFoundation                      0x0236d8ff __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
12  CoreFoundation                      0x022cb88b __CFRunLoopDoSources0 + 571
13  CoreFoundation                      0x022cad86 __CFRunLoopRun + 470
14  CoreFoundation                      0x022ca840 CFRunLoopRunSpecific + 208
15  CoreFoundation                      0x022ca761 CFRunLoopRunInMode + 97
16  GraphicsServices                    0x041921c4 GSEventRunModal + 217
17  GraphicsServices                    0x04192289 GSEventRun + 115
18  UIKit                               0x00944c93 UIApplicationMain + 1160
19  DiscountShelving                    0x000045da main + 410
20  DiscountShelving                    0x00002ea5 start + 53
2012-05-30 14:58:46.035 DiscountShelving[19335:207] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Attempting to begin a modal transition from <UINavigationController: 0x6d39e90> to <UINavigationController: 0x6d438d0> while a transition is already in progress. Wait for viewDidAppear/viewDidDisappear to know the current transition has completed'
*** Call stack at first throw:
(
    0   CoreFoundation                      0x0238c5a9 __exceptionPreprocess + 185
    1   libobjc.A.dylib                     0x024e0313 objc_exception_throw + 44
    2   CoreFoundation                      0x02344ef8 +[NSException raise:format:arguments:] + 136
    3   Foundation                          0x007313bb -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 116
    4   UIKit                               0x00be51d6 -[UIWindowController transition:fromViewController:toViewController:target:didEndSelector:] + 290
    5   UIKit                               0x009ea65d -[UIViewController presentModalViewController:withTransition:] + 3478
    6   DiscountShelving                    0x00198716 -[TiApp attachModal:toController:animated:] + 166
    7   DiscountShelving                    0x00198751 -[TiApp attachModal:toController:animated:] + 225
    8   DiscountShelving                    0x0019865a -[TiApp showModalController:animated:] + 474
    9   DiscountShelving                    0x00063172 -[TiWindowProxy openOnUIThread:] + 2978
    10  Foundation                          0x006b594e __NSThreadPerformPerform + 251
    11  CoreFoundation                      0x0236d8ff __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
    12  CoreFoundation                      0x022cb88b __CFRunLoopDoSources0 + 571
    13  CoreFoundation                      0x022cad86 __CFRunLoopRun + 470
    14  CoreFoundation                      0x022ca840 CFRunLoopRunSpecific + 208
    15  CoreFoundation                      0x022ca761 CFRunLoopRunInMode + 97
    16  GraphicsServices                    0x041921c4 GSEventRunModal + 217
    17  GraphicsServices                    0x04192289 GSEventRun + 115
    18  UIKit                               0x00944c93 UIApplicationMain + 1160
    19  DiscountShelving                    0x000045da main + 410
    20  DiscountShelving                    0x00002ea5 start + 53
)
terminate called after throwing an instance of 'NSException'
[INFO] Application has exited from Simulator}

var btnCart = Titanium.UI.createButton({
title:'Cart'
});

btnCart.addEventListener('click', function(e){
var cartWin = Titanium.UI.createWindow({
    url:'../MainWindows/shoppingCart.js',
    barColor:'12235b',
    opacity: 1,
    zIndex: 1
});
cartWin.open({modal:true});
})

win.rightNavButton = btnCart;

If any body knows of this problem or has had it in the past and has fixed it please let me know ASAP!

Thanks

1

There are 1 best solutions below

0
On

I got a similar crash in my application.

I just implemented a sleep method like:

function sleep(milliseconds)
{
    var start = new Date().getTime();

    while((new Date().getTime() - start) < milliseconds)
    {
        // Do nothing
    }
}

and called it before opening the window like:

sleep(1000);
myWin.open();