Bug 388798 - KLineEdit emits textChanged signal when setText() or clear() is called
Summary: KLineEdit emits textChanged signal when setText() or clear() is called
Status: RESOLVED FIXED
Alias: None
Product: frameworks-kcompletion
Classification: Frameworks and Libraries
Component: general (show other bugs)
Version: 5.32.0
Platform: openSUSE Linux
: NOR major
Target Milestone: ---
Assignee: David Gil
URL: https://phabricator.kde.org/D9808
Keywords:
Depends on:
Blocks:
 
Reported: 2018-01-10 22:55 UTC by Dan Weatherill
Modified: 2018-04-07 12:47 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
minimal example which reproduces the bug (3.00 KB, application/gzip)
2018-01-10 22:55 UTC, Dan Weatherill
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Dan Weatherill 2018-01-10 22:55:38 UTC
Created attachment 109786 [details]
minimal example which reproduces the bug

Hi,
whilst debugging a segfault in kdevelop, I found this is the cause. I created a simple test case GUI which has a KLineEdit, a KUrlRequester, and a QLineEdit (source attached).

On my system (Qt 5.6.2, KDE frameworks 5.32.0, openSUSE Leap 42.3),
when the "test edited" or "test clear" buttons are pressed, QLineEdit correctly only emits the textChanged signal, but KUrlRequester and KLineEdit emit both textChanged (expected) and also textEdited (spurious). 

This signal should only (as per the docs) be emitted when the user themselves edits the box.

I searched the git logs and couldn't see any fix related to this up to now. I have not yet checked newer versions to see if the problem is still there.
Comment 1 Dan Weatherill 2018-01-11 01:18:53 UTC
I have confirmed this issue still exists building against git master kcompletions (SHA1: c351ff8be4f2bc84f) and latest Qt (5.10.0).
Comment 2 David Faure 2018-01-19 08:49:03 UTC
Git commit 31f226116f99bcf40ddc67fe6328594d5fb46222 by David Faure, on behalf of Dan Weatherill.
Committed on 19/01/2018 at 08:48.
Pushed by dfaure into branch 'master'.

Fix incorrect emission of textEdited() by KLineEdit

The unit test of kLineEdit was previously checking incorrectly that
textEdited _HAD_ been emitted when the text is changed with setText().
This is undesired behaviour.
This patch fixes the unit test, and changes the problematic behaviour by
removing the extra emission of textEdited in the private signal
_k_textChanged.
In addition this is the underlying cause of a bug in kdevelop (and
probably several others).
Related: bug 373004

M  +28   -3    autotests/klineedit_unittest.cpp
M  +0    -1    src/klineedit.cpp

https://commits.kde.org/kcompletion/31f226116f99bcf40ddc67fe6328594d5fb46222