SDK: 3.0.3
Device: Fenix 5s, Software version: 10.00
Eclipse: Photon Release (4.8.0), Build id: 20180619-1200
Description
Crash happens after deleting item and whenever last menu item comes into view (i.e. when trying to put focus on last or second last position).
The problem reproduces on Fenix 5s hardware, but not in simulator.
Steps to reproduce:
Source code is provided in listings below and sample project is attached: Menu2-crash-sample.zip
- Open app;
- Press Start - first menu item gets deleted;
- Press Down - menu scrolls down normally;
- Press Down again - app crashes with "IQ!" icon.
Nothing is getting written in CIQ_LOG.YML.
App log:
Before delete 0
After delete 0
Source code
Full sample project: Menu2-crash-sample.zip. Below are the listings of .mc files.
Menu2App.mc
using Toybox.Application;
using Toybox.WatchUi;
class Menu2App extends Application.AppBase {
function initialize() {
AppBase.initialize();
}
function getInitialView() {
return [ new StartPageView(), new WatchUi.BehaviorDelegate() ];
}
}
StartPageView.mc
using Toybox.WatchUi;
// Since Menu2 cannot be initial view, this dummy view will act as initial view and will redirect to Menu2
class StartPageView extends WatchUi.View {
function initialize() {
WatchUi.View.initialize();
}
function onLayout(dc) {
WatchUi.pushView(ExampleMenu2View.getInstance(), new ExampleMenu2Delegate(), WatchUi.SLIDE_IMMEDIATE);
}
}
ExampleMenu2View.mc
using Toybox.WatchUi;
using Toybox.Application;
class ExampleMenu2View extends WatchUi.Menu2 {
private static var sInstance;
static function getInstance() {
if (sInstance == null) {
sInstance = new ExampleMenu2View();
}
return sInstance;
}
private function initialize() {
WatchUi.Menu2.initialize({:title=>"Reproducing Menu2 bug"});
var totalItems = 5;
for(var i=0; i < totalItems; i += 1) {
addItem(createMenuItem(i));
}
}
function createMenuItem(i) {
return new WatchUi.MenuItem("item #" + i, "menu item #" + i, i, {});
}
function notifyItemDeleted(i) {
System.println("Before delete " + i);
var index = findItemById(i);
deleteItem(index);
System.println("After delete " + i);
}
}
ExampleMenu2Delegate.mc
using Toybox.WatchUi;
using Toybox.System;
class ExampleMenu2Delegate extends WatchUi.Menu2InputDelegate {
function initialize() {
Menu2InputDelegate.initialize();
}
function onSelect(item) {
var itemId = item.getId();
ExampleMenu2View.getInstance().notifyItemDeleted(itemId);
}
function onBack() {
// Exit skipping dummy start page view
System.exit();
}
}