A simple bug. Probably parent_window issues. I can't fix it. If I follow this bug I can learn fix it. Steps: Edit -> Style Sheets Select any stylesheet - opens "Select HTML Style Sheet" window Press Edit - opens "Edit HTML Style Sheet Properties" window Move Stylesheet Edit window away Press Close on the "Select HTML Style Sheet" window Expected: (maybe) "Select HTML Style Sheet" closes, stylesheet edit window remains. Actual: segfault This is more visible on v3.5 on Windows whereby, for some reason, the Edit-stylesheet window stays on top of the "Edit HTML Style Sheet Properties" window, and I try close the edit-stylesheet window, and it freezes.
The first step is to get a stack trace. See https://wiki.gnucash.org/wiki/Stack_Trace if you don't know how. You'll need to have built GnuCash with -DCMAKE_BUILD_TYPE=Debug in order to get the stack trace to show you the line where it crashed. The crash is at https://github.com/Gnucash/gnucash/blob/maint/gnucash/report/report-gnome/dialog-report-style-sheet.c#L134 from dereferencing "ss". Notice two lines above that ss is a copy of the file-global variable gnc_style_sheet_dialog, and apparently that has either not gotten set, set wrong, or cleared so that it points outside of the programs memory segment (that's what "segfault" or "segmentation fault" means: the program tried to access memory that it's not allowed to), most commonly address 0x0, aka NULL or in C++ nullptr. Now look at stack trace frame 16: It's https://github.com/Gnucash/gnucash/blob/maint/gnucash/report/report-gnome/dialog-report-style-sheet.c#L394. The line above it is "gnc_style_sheet_dialog = NULL". Oops. So the fix should indeed be pretty simple: Switch lines 393 and 394 so that the gnc_style_sheet_options_close_cb can find the dialog it's supposed to close.
(This wouldn't have happened with scheme :evil_grin: which fails more spectacularly to start with) My query is why crash now; wouldn't the source be an invalid parent_window somewhere? On Windows the select-stylesheet *does* remain focussed on top of the child edit-stylesheet window. From edit-stylesheet, click a colour box to launch edit-color, and close the parent edit-stylesheet works well - both edit-stylesheet and edit-color close down uneventfully. Wouldn't a proper fix fix both?
No, the question is why it doesn't crash when the child window is closed. This crash is because of the way pointers work: They're memory locations that contain the address of something, so the C notation ss->list_store means "look in ss for an address of a structure StyleSheet structure and return the contents of the list_store element of that structure. But ss contains 0x0 because that's what it was set to in line 393. That bit of code must not execute if there's no edit dialog open because it doesn't crash in that case, but I haven't analyzed why. I'm not sure that Windows even allows non-modal dialog boxes, but it would seem that in this case the Edit dialog is modal on Windows where it isn't on Unix. Since you can't close the Selection dialog with the Edit dialog open you can't trigger the crash.