Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-944] accessing detail default popover = crash

GitHub Issuen/a
TypeBug
PriorityTrivial
StatusClosed
ResolutionFixed
Resolution Date2011-04-17T01:54:44.000+0000
Affected Version/sn/a
Fix Version/sRelease 1.4.0
ComponentsiOS
Labelsn/a
ReporterNolan Wright
AssigneeBlain Hamon
Created2011-04-15T02:39:49.000+0000
Updated2011-04-17T01:54:44.000+0000

Description

if you try to save a reference to the popover from the visible event and then use it later, it crashes. here's the code:

var masterWindow = Ti.UI.createWindow({

backgroundColor: '#fdf5e5',
barColor: '#ec4930'

});

var masterNavigationGroup = Ti.UI.iPhone.createNavigationGroup({
window: masterWindow });

var b = Ti.UI.createButton({

title:'Search',
height:100,
width:100

}); b.addEventListener('click', function()
{

Ti.App.fireEvent('openMasterView');

});

var detailWindow = Ti.UI.createWindow({
backgroundColor: '#f7f0e3', barColor: '#ec4930', rightNavButton: b });

var detailNavigationGroup = Ti.UI.iPhone.createNavigationGroup({
window: detailWindow });

var splitWindow = Ti.UI.iPad.createSplitWindow({

detailView: detailNavigationGroup,
masterView: masterNavigationGroup

});

var masterPopover = null;
var masterView = null;
splitWindow.addEventListener('visible', function(e)
{

masterPopover = e.popover;
masterView = e.button
if (e.view == 'detail') 
{
    e.button.title = "foo";
    detailWindow.leftNavButton = e.button; 

}

else if (e.view == 'master') 
{
    detailWindow.leftNavButton = null;

} });

Ti.App.addEventListener("openMasterView", function(d)
{

Ti.API.info('in openMasterView pop ' + masterPopover)
if (masterPopover != null)
{
    masterPopover.show({view:masterView});  
}

});

splitWindow.open();

Comments

  1. Stephen Tramer 2011-04-15

    The biggest issue here is that I have no idea what the user is trying to accomplish. Why would you show a popover of a button? The wording seems to indicate that they want to show a popover of the master view, but why would you ever do that?

    There is an additional problem that the masterView variable appears to be incorrectly set at certain times as far as the context for the app event listener is concerned. Regardless, there are still problems with popovers.

    Here is some slightly modified code, which crashes in a different (but vastly more appropriate) way:

       var masterWindow = Ti.UI.createWindow({
           backgroundColor: 'red',
           barColor: '#ec4930'
       });
       
       var masterPopover = null;
       var masterView = null;
       var b = Ti.UI.createButton({
           title:'Search',
           height:100,
           width:100
       }); 
       b.addEventListener('click', function()
       {
           Ti.API.info('in openMasterView pop ' + masterPopover);
           Ti.API.info('Master view: '+masterView);
           if (masterPopover != null)
           {
               masterPopover.show({view:masterView, 
                                   rect:{x:100,y:100,width:100,height:300}});  
           }
       });
       
       var detailWindow = Ti.UI.createWindow({
           backgroundColor: 'blue', 
           barColor: '#ec4930', 
           rightNavButton: b 
       });
       
       var masterNavigationGroup = Ti.UI.iPhone.createNavigationGroup({
           window: masterWindow
       });
       var detailNavigationGroup = Ti.UI.iPhone.createNavigationGroup({
           window:detailWindow
       });
       
       var splitWindow = Ti.UI.iPad.createSplitWindow({
           detailView: detailNavigationGroup,
           masterView: masterNavigationGroup
       });
       
       splitWindow.addEventListener('visible', function(e) {
           Ti.API.log(e);
           masterPopover = e.popover;
           masterView = e.button;
           if (e.view == 'detail') 
           {
               e.button.title = "foo";
               detailWindow.leftNavButton = e.button; 
           }
           else if (e.view == 'master') 
           {
               detailWindow.leftNavButton = null;
           } 
           Ti.API.log('Master view:'+masterView);
       });
       
       splitWindow.open();
       

    Looking into resolving this now.

  2. Nolan Wright 2011-04-15

    They are trying to set the value of masterPopover in order to use it later in the app. Seems valid to me.

  3. Stephen Tramer 2011-04-15

    Yeah, that comment was written before I took a look through some more of the presentation code. There is still some kind of very strange issue with setting masterView = e.button, however, because in the app event listener it wasn't the correct value (although it was the right value in the context of the function which set it).

  4. Jeff Haynie 2011-04-15

    (from [7fc6a66f81548c8535f270bed0106464fc0cfc65]) [#944 state:open] Fixes to split window buttons. Necessary for upcoming changes to how popovers display. http://github.com/appcelerator/titanium_mobile/commit/7fc6a66f81548c8535f270bed0106464fc0cfc65"> http://github.com/appcelerator/titanium_mobile/commit/7fc6a66f81548...

  5. Jeff Haynie 2011-04-15

    (from [c28c79c40727235b3481a0d042299b8a408fd22a]) Closes #944: Removed access to the splitview's builtin popover. See the ticket for why. http://github.com/appcelerator/titanium_mobile/commit/c28c79c40727235b3481a0d042299b8a408fd22a"> http://github.com/appcelerator/titanium_mobile/commit/c28c79c407272...

  6. Stephen Tramer 2011-04-15

    This was a case of burning the village to save it. We shouldn't allow access to the popover that's managed by the split view, because certain magic happens with it - if it's messed with in any way, that magic might not happen (or could appear very odd). Besides, the popover doesn't have anything innate about it beyond being used for this special system: It doesn't automatically hold the master view, for example.

    If it's absolutely necessary to display the master view in a non-convential way via popover, you should make your own popover and manage it yourself, to display the master view when required.

  7. Tim.Alosi 2011-04-15

    Regarding removing access to the Popover in a Splitview.

    There is one reason why one would need access to it ... to close it when an event is fired.

    If you look at the standard Mail app, when an email is selected from the splitview popover, the app automatically closes the popover and shows the detail window.

    Currently in the visible event, having the instance would allow the app to close the popover. With out that access to the object, there is no apparent way to close the default split view Popover.

    If there is, please post response.

    Thanks
    Tim

  8. Blain Hamon 2011-04-15

    Looking through the code, there is not currently a way exposed to close an open split view popover. I don't mind the ability to close the split view popover, but I'd much rather it be functionality explicitly added to split view (IE, splitView.closeMainViewPopover() ) rather than restore the previous hack. The previous hack was very error prone and would have caused a great many problems going forward.

  9. Tim.Alosi 2011-04-15

    So, can we get such a function into the road map for 1.5 or a later release?

  10. Craig Marvelley 2011-04-15

    Hi,

    Was a solution ever put in place for this functionality? It's crucial that we are able to dismiss the popover programmatically, not just from a UX point of view but also because it can cause crashes. For example, if one attempts to close a split window while the popover is still visible, the following crash occurs:

        2011-03-06 13:18:52.817 S4CiPad[91506:207] *** Terminating app due to uncaught exception 'NSGenericException', reason: '-[UIPopoverController dealloc] reached while popover is still visible.'
        

    Thanks.

JSON Source