<table><tr><td style="">mwolff updated this revision to Diff 23508.<br />mwolff retitled this revision from "Do not crash when completion object gets destroyed underneath us" to "Do not crash when setting new line edit on an editable combo box".<br />mwolff edited the summary of this revision. <a href="https://phabricator.kde.org/transactions/detail/PHID-XACT-DREV-7qlqv6xoilnwte7/" rel="noreferrer">(Show Details)</a><br />mwolff removed subscribers: anthonyfieroni, dfaure.<br />mwolff added a comment.
</td><a style="text-decoration: none; padding: 4px 8px; margin: 0 8px 8px; float: right; color: #464C5C; font-weight: bold; border-radius: 3px; background-color: #F7F7F9; background-image: linear-gradient(to bottom,#fff,#f1f0f1); display: inline-block; border: 1px solid rgba(71,87,120,.2);" href="https://phabricator.kde.org/D9189" rel="noreferrer">View Revision</a></tr></table><br /><div><div><p>update commit message</p></div></div><br /><div><strong>CHANGES TO REVISION SUMMARY</strong><div><div style="white-space: pre-wrap; color: #74777D;"><span style="padding: 0 2px; color: #333333; background: rgba(251, 175, 175, .7);">For some reason the</span><span style="padding: 0 2px; color: #333333; background: rgba(151, 234, 151, .6);">The</span> 'Open With' dialog opened by KMail triggers the<span style="padding: 0 2px; color: #333333; background: rgba(151, 234, 151, .6);"> following crash</span><br />
<span style="padding: 0 2px; color: #333333; background: rgba(251, 175, 175, .7);">following crash </span>for me:<br />
<br />
<span style="padding: 0 2px; color: #333333; background: rgba(251, 175, 175, .7);">```<br />
</span> #0  0x0000555568ea4220 in ?? ()<div style="padding: 8px 0;">...</div>    asn=<QArrayData::shared_null+24> "") at /home/milian/projects/kf5/src/frameworks/kio/src/widgets/krun.cpp:267<span style="padding: 0 2px; color: #333333; background: rgba(151, 234, 151, .6);"><br />
<br />
This happens when an editable KComboBox is initialized (i.e.<br />
KHistoryComboBox in this case). When we then ask for the completionObject,<br />
this will alias the lineEdit's completion object, which gets destroyed by</span><br />
<span style="padding: 0 2px; color: #333333; background: rgba(251, 175, 175, .7);">```</span><span style="padding: 0 2px; color: #333333; background: rgba(151, 234, 151, .6);">the call to `QComboBox::setLineEdit`, leading to the crash above.</span><br />
<br />
<span style="padding: 0 2px; color: #333333; background: rgba(251, 175, 175, .7);">Guard against it by using a QPointer to check whether the completion</span><span style="padding: 0 2px; color: #333333; background: rgba(151, 234, 151, .6);">Overall, I think the whole aliasing / delegation here is quite<br />
confusing and I'm unsure as to what the desired behavior is here.<br />
Should we transfer ownership to the new line edit, if it has no</span><br />
<span style="padding: 0 2px; color: #333333; background: rgba(251, 175, 175, .7);">object gets destroyed before we want to use it again.</span><span style="padding: 0 2px; color: #333333; background: rgba(151, 234, 151, .6);">compObj of its own?</span><br />
<br />
<span style="padding: 0 2px; color: #333333; background: rgba(251, 175, 175, .7);">Sadly WebEngine in KMail prevents me from using Valgrind,</span><span style="padding: 0 2px; color: #333333; background: rgba(151, 234, 151, .6);">The unit test is extended to catch this scenario now.</span> <span style="padding: 0 2px; color: #333333; background: rgba(251, 175, 175, .7);">so I have</span><span style="padding: 0 2px; color: #333333; background: rgba(151, 234, 151, .6);">It at least</span><br />
<span style="padding: 0 2px; color: #333333; background: rgba(251, 175, 175, .7);">not yet figured out where exactly the deletion is coming from. That</span><span style="padding: 0 2px; color: #333333; background: rgba(151, 234, 151, .6);">ensures that nothing crashes and also documents the status quo</span><br />
<span style="padding: 0 2px; color: #333333; background: rgba(251, 175, 175, .7);">said, this fix should make this working again with minimal impact</span><span style="padding: 0 2px; color: #333333; background: rgba(151, 234, 151, .6);">of the behavior right now</span>.</div></div></div><br /><div><strong>REPOSITORY</strong><div><div>R284 KCompletion</div></div></div><br /><div><strong>CHANGES SINCE LAST UPDATE</strong><div><a href="https://phabricator.kde.org/D9189?vs=23507&id=23508" rel="noreferrer">https://phabricator.kde.org/D9189?vs=23507&id=23508</a></div></div><br /><div><strong>BRANCH</strong><div><div>master</div></div></div><br /><div><strong>REVISION DETAIL</strong><div><a href="https://phabricator.kde.org/D9189" rel="noreferrer">https://phabricator.kde.org/D9189</a></div></div><br /><div><strong>AFFECTED FILES</strong><div><div>autotests/kcombobox_unittest.cpp<br />
src/kcombobox.cpp</div></div></div><br /><div><strong>To: </strong>mwolff, dfaure<br /><strong>Cc: </strong>Frameworks<br /></div>