Bug 413474

Summary: Crash when adding variable into swap file name
Product: [Frameworks and Libraries] frameworks-ktexteditor Reporter: Juraj <jurajoravec>
Component: generalAssignee: KWrite Developers <kwrite-bugs-null>
Status: RESOLVED FIXED    
Severity: crash CC: rdieter
Priority: NOR    
Version: 5.63.0   
Target Milestone: ---   
Platform: Arch Linux   
OS: Linux   
Latest Commit: Version Fixed In: 5.64
Sentry Crash Report:
Attachments: Video example
Backtrace from KDevelop with same crash
Backtrace from KDevelop with same crash

Description Juraj 2019-10-26 13:50:03 UTC
Created attachment 123493 [details]
Video example

SUMMARY
Kate crashed when adding variable to swap file name.

STEPS TO REPRODUCE
1. Start Kate
2. Go to > Menu > Settings > Configure Kate > [Editor Component] Open/Save > Advanced
3. Make prefix or suffix inputs focused (click on them)
4. Click on the icon '{}' on the right side which shows when the input is focused
5. Select something from the list which popped up (I did Date:Locale)

OBSERVED RESULT
Kate crashes.

EXPECTED RESULT
Kate runs.

SOFTWARE/OS VERSIONS
Operating System: Artix Linux 
KDE Plasma Version: 5.17.1
KDE Frameworks Version: 5.63.0
Qt Version: 5.13.1
Kernel Version: 4.19.80-1-lts
OS Type: 64-bit
Processors: 2 × Intel® Pentium® CPU B980 @ 2.40GHz
Memory: 7,6 GiB of RAM


ADDITIONAL INFORMATION
See the video
Comment 1 Juraj 2019-10-26 17:54:21 UTC
Created attachment 123500 [details]
Backtrace from KDevelop with same crash

I have KDevelop compiled from source, hope backtrace can help.
Comment 2 Juraj 2019-10-26 18:04:40 UTC
Created attachment 123501 [details]
Backtrace from KDevelop with same crash
Comment 3 Dominik Haumann 2019-10-28 15:43:39 UTC
Can you try again changing 

281 const auto name = QStringLiteral("%{") + var.name() + QLatin1Char('}');

to

 const QString name = QStringLiteral("%{") + var.name() + QLatin1Char('}');
Comment 4 Juraj 2019-10-28 16:08:36 UTC
(In reply to Dominik Haumann from comment #3)
> Can you try again changing 
> 
> 281 const auto name = QStringLiteral("%{") + var.name() + QLatin1Char('}');
> 
> to
> 
>  const QString name = QStringLiteral("%{") + var.name() + QLatin1Char('}');

That does the trick.
No crash and it adds variables into the text field.

Thank you.
Comment 5 Christoph Cullmann 2019-10-28 19:32:27 UTC
Git commit f6e72a23052339253daa79095391625cf01c96f1 by Christoph Cullmann.
Committed on 28/10/2019 at 19:32.
Pushed by cullmann into branch 'master'.

fix crash

M  +3    -1    src/utils/katevariableexpansionhelpers.cpp

https://commits.kde.org/ktexteditor/f6e72a23052339253daa79095391625cf01c96f1
Comment 6 Dominik Haumann 2019-10-28 19:34:39 UTC
Thanks for the quick testing Juraj.