Bug 151903

Summary: Crash when using removeChildByIndex of node in TreeControl
Product: LibreOffice Reporter: Gabe <gabe.kleiman>
Component: BASICAssignee: Not Assigned <libreoffice-bugs>
Status: RESOLVED INSUFFICIENTDATA    
Severity: minor CC: andreas.heinisch, ilmari.lauhakangas, xiscofauli
Priority: medium    
Version: 7.4.2.3 release   
Hardware: x86 (IA32)   
OS: macOS (All)   
Whiteboard:
Crash report or crash signature: Regression By:

Description Gabe 2022-11-04 14:48:11 UTC
Description:
In a tree control of a dialog in Base, the removeChildByIndex method causes Libreoffice to crash (spinning color wheel).  Must use 'force quit' and restart application.  The tree data model of the tree control was initiated as createUnoService("com.sun.star.awt.tree.MutableTreeDataModel").  Occurs regardless of whether the node to be removed has any children nodes.

Steps to Reproduce:
1. oNode = oDialog.getControl("sTreeControl").getSelection
2. oParentNode = oNode.getParent
3. iIndex = oParentNode.getIndex(oNode)
4. oParentNode.removeChildByIndex(iIndex)

Actual Results:
Crash of Libreoffice (spinning color wheel) at execution of step 4.

Expected Results:
Deletion of selected node.


Reproducible: Always


User Profile Reset: No

Additional Info:
Version - 7.4.2.3
Build - 382eef1f22670f7f4118c8c2dd222ec7ad009daf
Environment - CPU Threads: 4, OS: Mac OS X 12.6
User Interface - UI render: default; vcl: osx
Locale - en-US; UI: en-US
Misc - Calc: threaded
Comment 1 Gabe 2022-11-04 15:35:12 UTC
I have done further testing by creating a fresh dialog.  The function seems to be working fine.  I will test further to try to determine why the dialog I developed is giving this problem.  In the meantime, I suggest putting the report on hold.
Comment 2 Gabe 2022-11-04 19:11:20 UTC
After some testing, I believe I found the problem.  It seems the 'Enable' setting fo the tree control object had been set to false -- oDialog.oTreeControl.setEnable(false)

When a removal of a node is attempted, no error is thrown; LibreOffice just hangs.  I will modify the bug report accordingly and lower the priority level.
Comment 3 Gabe 2022-11-04 19:15:39 UTC
Amending importance to 'minor'.  This is now a request to generate an appropriate error to avoid Libreoffice hanging up/crashing in the case described below (attempting to removeChildByIndex of a tree control node when the tree control Enable = false
Comment 4 Gabe 2022-11-14 03:25:32 UTC
After further testing, I confirmed that the cause of the crash was actually due to having set up a for-next loop in which the high range of the loop was changing.  The code includes removal of nodes via the loop.  However, as each node was deleted the high end of the range was changing.  Seems more likely to be an issue regarding for-next loops and not the node deletion as I thought.  My fix was easy - simply stepping backwards in the for-next loop -- i.el, "for i = oParentNode.getChildCount-1 to 0 step -1".  The issue of the system crashing rather than throwing an error message remains but I think is low priority.
Comment 5 Andreas Heinisch 2023-01-06 13:21:21 UTC
May you add a sample document in order to speed up the testing? Thank you very much!
Comment 6 Xisco FaulĂ­ 2023-01-17 09:02:48 UTC
Thank you for reporting the bug. Please attach a sample document, as this makes it easier for us to verify the bug. 
I have set the bug's status to 'NEEDINFO'. Please change it back to 'UNCONFIRMED' once the requested document is provided.
(Please note that the attachment will be public, remove any sensitive information before attaching it. 
See https://wiki.documentfoundation.org/QA/FAQ#How_can_I_eliminate_confidential_data_from_a_sample_document.3F for help on how to do so.)
Comment 7 Gabe 2023-01-25 14:34:56 UTC
(In reply to Xisco FaulĂ­ from comment #6)
> Thank you for reporting the bug. Please attach a sample document, as this
> makes it easier for us to verify the bug. 
> I have set the bug's status to 'NEEDINFO'. Please change it back to
> 'UNCONFIRMED' once the requested document is provided.
> (Please note that the attachment will be public, remove any sensitive
> information before attaching it. 
> See
> https://wiki.documentfoundation.org/QA/
> FAQ#How_can_I_eliminate_confidential_data_from_a_sample_document.3F for help
> on how to do so.)

Hi, thanks for reviewing.  after much further testing, I could not make treeview work and decided to ditch the effort in favor of an alternative solution (python/tkinter/sqlite).  Also, Libreoffice generally was crashing often possibly linked to recent macOS updates.  Anyway, for now I'm using alternative solutions, but will keep trying to implement LO's other applications if the crash issue is resolved with new Apple microprocessor which I've started using.  Please deactivate this submission.  Thanks.
Comment 8 QA Administrators 2023-01-26 03:24:20 UTC Comment hidden (obsolete)