← Back to team overview

mudlet-makers team mailing list archive

[Bug 812075] Re: Command history is not saved if auto-clearing of the input line is enabled

 

The problem is in TCommandLine::enterCommand( TCommandLine::enterCommand
).  In mudlet-HEAD-24bbfa4, the method performs these key actions:

1. obtains a copy of the plain text of the command line
2. if the autoclear flag is set, clears the command line (so it actually clears the line *before* sending)
3. sends the command
4. if the *current* command line text is non-empty, then it is put at the front of the command buffer.

When autoclear is enabled, the command line text is always empty at step
4 because it was cleared at step 2!

There is absolutely no reason for the method to use the current text
(via toPlainText()) at step 4.  From an efficiency standpoint it is
slightly wasteful.  If mudlet does or ever should run multithreaded,
however, then it's inherently wrong: it allows for different command
text to be buffered than was actually sent.  (I.e. if another thread
modifies the command line text at just the wrong time.)

All these issues can be addressed by using the copy of the command line
text obtained in step 1 to update the history buffer at step 4.  I
attach a patch that implements this change.  It solves the problem for
me.

I note that the patch does not modify the handling of the mHistoryBuffer
variable.  This may be a flaw, but it is currently harmless because
enterCommand() is private, and it is only invoked by
TCommandLine::event(QEvent *event), which performs its own handling of
mHistoryBuffer.  (event() also performs its own clearing of the command
line -- hmm).


** Patch added: "Patches TCommandLine::enterCommand to always buffer the command actually sent"
   https://bugs.launchpad.net/mudlet/+bug/812075/+attachment/2260852/+files/mudlet-history.patch

-- 
You received this bug notification because you are a member of Mudlet
Makers, which is subscribed to Mudlet.
https://bugs.launchpad.net/bugs/812075

Title:
  Command history is not saved if auto-clearing of the input line is
  enabled

Status in Mudlet the MUD client:
  New

Bug description:
  Steps to replicated:

  disable auto-clearing
  enter several commands
  enable auto-clearing
  enter several commands
  press up
  first command to come up will be the last one with auto-clearing off.

To manage notifications about this bug go to:
https://bugs.launchpad.net/mudlet/+bug/812075/+subscriptions


Follow ups

References