Mercurial > dwindows
changeset 2685:17c34bdaec6c
Android: Put in some list bounds safety checks... them getting hit however...
means the app is in an unexpected state. But getting it from time to time in
the simulator.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Tue, 26 Oct 2021 06:17:53 +0000 |
parents | a26e5a2d94be |
children | 95f61d3f3d0d |
files | android/DWindows.kt |
diffstat | 1 files changed, 16 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/android/DWindows.kt Tue Oct 26 05:43:02 2021 +0000 +++ b/android/DWindows.kt Tue Oct 26 06:17:53 2021 +0000 @@ -949,17 +949,23 @@ val width: Int = windowLayout!!.width val height: Int = windowLayout!!.height val adapter: DWTabViewPagerAdapter = windowLayout!!.adapter as DWTabViewPagerAdapter - val window = adapter.viewList[windowLayout!!.currentItem] - - eventHandlerInt(window, DWEvent.CONFIGURE, width, height, 0, 0) + val index = windowLayout!!.currentItem + val count = adapter.viewList.count() + + if(count > 0 && index < count) { + val window = adapter.viewList[index] + + eventHandlerInt(window, DWEvent.CONFIGURE, width, height, 0, 0) + } } } override fun onCreateOptionsMenu(menu: Menu?): Boolean { if(windowLayout != null) { val index = windowLayout!!.currentItem - - if (windowMenuBars.count() > 0) { + val count = windowMenuBars.count() + + if (count > 0 && index < count) { var menuBar = windowMenuBars[index] if(menuBar == null) { @@ -976,8 +982,9 @@ override fun onPrepareOptionsMenu(menu: Menu?): Boolean { if(windowLayout != null) { val index = windowLayout!!.currentItem - - if (windowMenuBars.count() > 0) { + val count = windowMenuBars.count() + + if (count > 0 && index < count) { var menuBar = windowMenuBars[index] if(menuBar != null) { @@ -997,9 +1004,10 @@ if(windowLayout != null) { val adapter: DWTabViewPagerAdapter = windowLayout!!.adapter as DWTabViewPagerAdapter val index = windowLayout!!.currentItem + val count = windowStyles.count() // If the current window has a close button... - if (index > 0 && (windowStyles[index] and 1) == 1) { + if (count > 1 && index > 0 && index < count && (windowStyles[index] and 1) == 1) { // Send the DW_SIGNAL_DELETE to the event handler eventHandlerSimple(adapter.viewList[index], DWEvent.DELETE) }