enthought / enthought/traitsui

Bug when using a SimpleColorEditor as a cell editor

Open
#310 5 comments 0 reactions 0 assignees View on GitHub
type: bug
Dominant language
Python
Stars
306
Forks
99
PR merge metrics
No merged PRs in 30d

Description

I've got a table (via `TableEditor`) that displays colors in one of the columns. When I use the "simple" `ColorEditor`, I get an exception after editing the color. The editor presents a dialog to the user for selecting a color. By the time the dialog is closed (actually before it ever opens), the `factory` attribute on the `SimpleColorEditor` is set to `None`, and this causes and exception in the following code. (https://github.com/enthought/traitsui/blob/master/traitsui/qt4/color_editor.py#L125)

The problem is in how the `TableEditor` cleans up the traitsui editors for its cells. When a cell editor is created, the traits editor is attached to the QT control (https://github.com/enthought/traitsui/blob/master/traitsui/qt4/table_editor.py#L8298). When the control is cleaned up, it also `dispose`s the traits editor (https://github.com/enthought/traitsui/blob/master/traitsui/qt4/table_editor.py#L1125). In the case of the `SimpleEditor`, the `_SimpleField` editor gets cleaned up right before the color dialog, which clears out the `factory` and other traits from the `SimpleColorEditor`. (The cleanup is triggered by the dialog stealing focus from the cell.)

The right way to handle this is not clear. Either QT controls should not clean up traits editors, or cell editors should not create popups.

The editor cleanup was introduced (or fixed) in 864770bc76c0e15fc8e7f94eb4f2bf52e99b6f97 (a long time ago). @rkern, you made that change. What are your thoughts on this?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.