Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash when deleting the first character in save dialog after switching from nxpse to ascii #995

Open
thomashampson opened this issue Jul 31, 2024 · 5 comments
Assignees
Labels

Comments

@thomashampson
Copy link

Describe the bug
MSlice will crash mantid when modifying the filename in the save file dialog. This was reported by a user who was using mantid 6.10 on IDAaaS, with the following description:

After data reduction I am plotting MAPS data using MSlice.
I load a .nxspe file and go to plot a cut across energy, which works fine. I then click the "save" icon on the plot and change the type to ASCII.
If I single click a current file in the save folder to auto-populate the filename text box in the save dialog window I can then go to edit that filename (e.g. my workflow involves saving a number of similar but slightly different files and so I want to edit one part of the filename without retyping the whole thing.)
The bug happens if you attempt to delete the first character of the filename in that textbox. Mantid freezes briefly then hard crashes.
I have repeated it a number of times using the above method and it has happened 100% of the time.

To Reproduce
I have managed to replicate with the following steps:

  1. Open MSlice
  2. Load some data, e.g. MAR11060 from training course data
  3. In the "Workspace Manager" tab, click Save, and select NXSPE
  4. Once the save dialog is open, change the file type to Ascii
  5. Click on an existing file to populate the name field
  6. Attempt to delete the first character of the name

Mantid will crash completely

Expected behavior
Should allow you to change the file name.

MSlice Version (please complete the following information):

  • MSlice Version 2.9.0

Additional context
Add any other context about the problem here.

@GuiMacielPereira GuiMacielPereira self-assigned this Aug 2, 2024
@GuiMacielPereira
Copy link
Contributor

Uhm, I am not getting a crash:
test_save_asacii_mslice

@GuiMacielPereira
Copy link
Contributor

I tried to reproduce on IDAaaS, but also did not get a crash

@GuiMacielPereira
Copy link
Contributor

Nevermind, it is reproducible if the object being saved is a slice or cut plot. Will look into this

@GuiMacielPereira
Copy link
Contributor

This issue is seems to be caused by gtk theme from qt https://github.com/qt/qtbase/tree/dev/src/plugins/platformthemes/gtk3, which is used when the library qt-gtk-platformtheme is present in the conda environment: mantidproject/mantid#35482. I checked that using the normal Qt QFileDialog without the theme does not have this problem.

One way of improving this issue is to catch the error from Gtk that causes it, but this doesn't look very straight forward at all, since a normal catch with std::exception() will not work, and the call to the Gtk library is hidden away by Qt.

I will return to this again soon.

@GuiMacielPereira
Copy link
Contributor

By the way, the way to cause the crash is not very reliable, but it's a combination of changing the extensions to search, clicking in a file to populate the filename box, and clicking in the box to edit the filename.

I wrote a simple script that calls QFileDialog to test the file dialog:

import sys
from PyQt5.QtWidgets import QApplication
from qtpy.QtWidgets import QFileDialog

app = QApplication(sys.argv)

file_dialog = QFileDialog()
QFileDialog.getSaveFileName(file_dialog, "Save File", "/~", "Nexus (*.nxs);; NXSPE (*.nxspe);; Ascii (*.txt);; Matlab (*.mat)")

sys.exit(app.exec_())

And to cause the crash (doesn't happen exactly like this every time):
gtk-theme-crash

Output:

(python:129723): Gtk-CRITICAL **: 11:23:43.325: gtk_tree_view_scroll_to_cell: assertion 'tree_view->priv->tree != NULL' failed
**
Gtk:ERROR:../gtk/gtkrbtree.c:471:_gtk_rbtree_insert_after: assertion failed: (_gtk_rbtree_is_nil (tree->root))
Bail out! Gtk:ERROR:../gtk/gtkrbtree.c:471:_gtk_rbtree_insert_after: assertion failed: (_gtk_rbtree_is_nil (tree->root))
Aborted (core dumped)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants