Opened 9 years ago

Closed 9 years ago

#471 closed defect (fixed)

Commands executed twice

Reported by: tic20@… Owned by: pett
Priority: major Milestone:
Component: Window Toolkit Version:
Keywords: Cc: goddard@…
Blocked By: Blocking:
Notify when closed: Platform: all
Project: ChimeraX

Description

Sometimes commands are executed twice when entered in the command line and Return is pressed. Appears to happen sporadically when commands that do a lot of computation are run.

Begin forwarded message:

From: Tristan Croll
Subject: Re: ISOLDE command
Date: November 3, 2016 at 7:18:22 AM PDT
To: Tom Goddard

Hi Tom,

I've got a basic command-line interface to ISOLDE more-or-less working. The code for it is in cmd.py. Something along the lines of:

isolde sim atoms #1/A map #2

will get a simulation started, but for some reason I don't yet understand ChimeraX attempts to run it twice, leading to the following error message:

Traceback (most recent call last):
File "/home/tic20/apps/chimerax/lib/python3.5/site-packages/chimerax/cmd_line/tool.py", line 147, in execute
cmd.run(cmd_text)
File "/home/tic20/apps/chimerax/lib/python3.5/site-packages/chimerax/core/commands/cli.py", line 2236, in run
results.append(ci.function(session, kw_args))
File "/home/tic20/apps/chimerax/lib/python3.5/site-packages/chimerax/isolde/cmd.py", line 85, in isolde
iobj.add_map('map0', map, mask_radius, k, mask=True)
File "/home/tic20/apps/chimerax/lib/python3.5/site-packages/chimerax/isolde/isolde.py", line 808, in add_map
raise Exception('Each map must have a unique name!')
Exception: Each map must have a unique name!

Any clues?

Thanks,

Tristan

Change History (4)

comment:1 by Tom Goddard, 9 years ago

Begin forwarded message:

From: Tristan Croll
Subject: Re: ISOLDE command
Date: November 3, 2016 at 7:57:26 AM PDT
To: Tom Goddard

OK, after a bit of digging it appears this is a bug in the Qt lineEdit.returnPressed() signal - for whatever reason it registers twice under these circumstances, and chimerax.cmd_line.execute() ends up running twice.

I've attached a copy of site-packages/chimerax/cmd_line/tool.py that fixes the problem for me. All I did was added a check that prevents an execute command running within 1ms of the last. On the other hand, I guess I should in any case modify the ISOLDE code to stop it attempting to prepare a second simulation when one is already running!

Cheers,

Tristan

comment:2 by Tom Goddard, 9 years ago

Qt bug is described here

https://forum.qt.io/topic/39141/qlineedit-editingfinished-signal-is-emitted-twice

Suggested work-around is lineedit.blockSignals(True) / lineedit.blockSignals(False) around the body of the returnPressed callback so it cannot be reentered. Blocked signals are not queued, and are only blocked for this QLineEdit. The duplicate signal may occur when status line messages give the Qt event queue a chance to run.

comment:3 by pett, 9 years ago

Status: newaccepted

Committed a fix where the signal-blocking workaround is placed around the command execution. Will not push the fix until Wednesday.

--Eric

comment:4 by Conrad Huang, 9 years ago

Resolution: fixed
Status: acceptedclosed

Keyboard forwarding happened twice.

Note: See TracTickets for help on using tickets.