Crash with macro on GridControl

Hello.

I’m trying do create a bit unusual form - its content is partially depended on values from database. Specifically I need a gridcontrol with columns defined by content of table in base. I wrote a bit of macro which on execution deletes all columns from gridcontrol, query database and define new columns according to result, create table for that grid and assigns it to form. And it kinda works. Problem is that if change anything in that grid than call that macro again it LO crashes. Question - is this a bug or i need to do something extra to prevent that crash? Tested on 7.0 and 7.6 - both crashes. Sample crash from 7.6:
https://crashreport.libreoffice.org/stats/crash_details/d68c81a9-ca34-4765-ac94-20543bf50a2a
odb file:

baza_v001.odb (35.0 KB)

To replicate: open Forms, open "STATYSTYKA’, click on either element in left table, in right table should then be shown a few rows, and now sometimes clicking on other element in left table is enough, if not then change anything in rows and then click other element in left table.
Macro in question is called ‘updategrid’

THx for help.

would need to investigate a bit …
gridctrl.cxx (revision 6f2b5043) - OpenGrok cross reference for /core/svx/source/fmcomp/gridctrl.cxx

more likely in bugzilla : First steps to take before submitting a bug - The Document Foundation Wiki

Well, after some experiments i found out that culprit is:

while grid1.hasElements()
	grid1.removeByIndex(0)
wend

if changed to

while grid1.hasElements()
		j = grid1.getByIndex(0)
		j.dispose()    
wend

than it works without crash.

1 Like

(you can tick your post as Solution)

I’m on a fence with that. It is a workaround not solution, so yeah, it would help someone else with such a problem, but i think it is still bug or at least something strange. grid1.removeByindex is obvious counterpart of grid1.addByIndex so it should work together… Maybe forum should offer tick workaround?