Bug 161466 - Multiple sheet event firings in LibreCalc.
Summary: Multiple sheet event firings in LibreCalc.
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: BASIC (show other bugs)
Version:
(earliest affected)
24.2.3.2 release
Hardware: x86-64 (AMD64) Windows (All)
: medium normal
Assignee: Massaraksh7
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-06-08 00:06 UTC by Massaraksh7
Modified: 2024-06-09 15:30 UTC (History)
1 user (show)

See Also:
Crash report or crash signature:


Attachments
File to show bug (11.05 KB, application/vnd.oasis.opendocument.spreadsheet)
2024-06-08 00:07 UTC, Massaraksh7
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Massaraksh7 2024-06-08 00:06:24 UTC
Description:
When assigning a macro to the "Selected area changed" sheet event, left-clicking on any cell generates not one, but four event firings - one when clicked, three when released. There must be one.

Steps to Reproduce:
1. Open attached file.
2. Left-click any cell
3. Look at firings

Actual Results:
Multiple sheet event firings

Expected Results:
One sheet event firing


Reproducible: Always


User Profile Reset: No

Additional Info:
Version: 24.2.3.2 (X86_64) / LibreOffice Community
Build ID: 433d9c2ded56988e8a90e6b2e771ee4e6a5ab2ba
CPU threads: 4; OS: Windows 10.0 Build 22000; UI render: Skia/Raster; VCL: win
Locale: ru-RU (ru_RU); UI: ru-RU
Calc: CL threaded
Comment 1 Massaraksh7 2024-06-08 00:07:59 UTC
Created attachment 194602 [details]
File to show bug
Comment 2 Mike Kaganski 2024-06-09 15:30:26 UTC
The problem is that ScTabView::SelectionChanged (sc/source/ui/view/tabview3.cxx), which itself calls ScTabViewObj::SelectionChanged (sc/source/ui/unoobj/viewuno.cxx), finally executing the script, is called in conditions where a change *could* had happened, and then it needs to be done; but the call site has no information if that change has actually happened. For example, the mouse up event first fires that call from ScTabView::MoveCursorAbs, explicitly for the case when the coordinates *are the same*; then it calls the function two times directly in ScGridWindow::MouseButtonUp - before and after some code. The function does a lot of other stuff, and it is unclear to me how to fix this.

For file open case, the first two calls are from ScDrawView::SdrEndTextEdit, which itself is called, when "unselect all" code is executed when setting current sheet. Only the third call is actually setting the target cell (which in this case is unchanged compared to the previous state, just needs to be signalled to the Basic code for the first time).