Bug 224442 - KHistoryComboBox-addToHistory changes currentText (in some cases)
Summary: KHistoryComboBox-addToHistory changes currentText (in some cases)
Status: RESOLVED FIXED
Alias: None
Product: kdelibs
Classification: Frameworks and Libraries
Component: kdeui (show other bugs)
Version: unspecified
Platform: Ubuntu Linux
: NOR normal
Target Milestone: ---
Assignee: kdelibs bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-01-27 10:19 UTC by Peter Mühlenpfordt
Modified: 2018-02-03 13:14 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
Simple cmake project to demonstrate the bug (5.26 KB, application/x-gzip)
2010-01-27 10:23 UTC, Peter Mühlenpfordt
Details
Modified version of the demo program (1.29 KB, application/gzip)
2010-03-01 09:12 UTC, Peter Mühlenpfordt
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Peter Mühlenpfordt 2010-01-27 10:19:38 UTC
Version:            (using KDE 4.3.2)
Compiler:          gcc 4.4.1 
OS:                Linux
Installed from:    Ubuntu Packages

I spotted this bug in Krusader commandline history. If you enter a command (manually) that's already in the history and above the selected history entry the selected command is executed instead of the entered.
I looked to the source and tracked the problem down to the addToHistory method from KHistoryComboBox class.
While cleaning the duplicates, the currentText changes to the text of the currentItem as far as the old entry is removed (khistorycombobox.cpp, line 198).

I give an example...
We have three items in history: [0] c, [1] b, [2] a
The currentIndex is now 2 (a), the currentText 'a'
Enter 'b' in the editline and we get the following history: [0] b, [1] c, [2] a
The currentIndex is still 2 (a), but the currentText is 'a' and not 'b' as we entered.
This problem occurs, if any item from index 1..(currentIndex-1) is entered manually.

It seems to come from the QComboBox below, but I can't figure out what happens here...
A simple bugfix could be to store and reset the text with setEditText() after deleting the duplicates.

  Peter
Comment 1 Peter Mühlenpfordt 2010-01-27 10:23:44 UTC
Created attachment 40283 [details]
Simple cmake project to demonstrate the bug

compile and run the program (cmake .; make)
Three history items are added by default (a, b, c).
Enter e.g. 'd', the currentText will be 'd'.
Enter 'b' after that and the currentText / editline will change to 'a'.
Comment 2 Christoph Feck 2010-02-24 02:16:46 UTC
Which Qt version do you use? I cannot reproduce with Qt 4.6, or I did not understand the steps in comment #1. When you say "Enter", do you mean clicking the "Add" button, just typing the letter, or additionally pressing the Enter key?
Comment 3 Peter Mühlenpfordt 2010-02-24 12:26:13 UTC
I'm currently using Qt 4.5.2 (running Kubuntu 9.10 with KDE 4.3.2).

After starting the test-program:
- click in editline and hit backspace-key to clear
- hit 'd'-key (without enter-key)
- click [Add]
- click in editline and hit backspace-key to clear
- hit 'b'-key (without enter-key)
- click [Add]

I'll try it with Qt 4.6 on Kubuntu 10.04 (alpha) the next days.
Comment 4 Peter Mühlenpfordt 2010-03-01 09:12:09 UTC
Created attachment 41225 [details]
Modified version of the demo program

Tried it now on KDE 4.4.0 with Qt 4.6.1 - it works here with my first demo program as it should be - something has changed in Qt/KDE.
But the problem is still there in Krusader: it seems, the connection from returnPressed(const QString &) causes the bug (connecting returnPressed() without argument works).

I changed my demo program to show the bug with KDE 4.4/Qt 4.6, too. There is no 'Add' button anymore. Make sure, item 'a' is selected in the drop down list, delete 'a' and enter 'b', press 'Return' and it will change to 'a'.
Comment 5 Peter Mühlenpfordt 2010-12-02 14:50:35 UTC
This bug still exists in Kubuntu 10.10 with KDE 4.5.1 and Qt 4.7.0.
Comment 6 Peter Mühlenpfordt 2011-05-29 14:28:07 UTC
This bug still exists in Kubuntu 11.04 with KDE 4.6.2 and Qt 4.7.2.
Comment 7 Peter Mühlenpfordt 2011-11-03 06:27:12 UTC
This bug still exists in Kubuntu 11.10 with KDE 4.7.2 and Qt 4.7.2.
Comment 8 Peter Mühlenpfordt 2018-02-03 13:14:11 UTC
Can not be reproduced with current KDE/Qt versions.