Bug 309760 - Crash while inline-renaming a file and apply change with return-key
Summary: Crash while inline-renaming a file and apply change with return-key
Alias: None
Product: dolphin
Classification: Unclassified
Component: general (show other bugs)
Version: 2.1
Platform: Archlinux Packages Linux
: NOR critical (vote)
Target Milestone: ---
Assignee: Dolphin Bug Assignee
Depends on:
Reported: 2012-11-08 17:54 UTC by Emmanuel Pescosta
Modified: 2012-11-09 11:11 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In: 4.9.4


Note You need to log in before you can comment on or make changes to this bug.
Description Emmanuel Pescosta 2012-11-08 17:54:04 UTC
The crash was introduced with the commit 951cb9c35d7a9ef814b3de5b359915968da9b881

Author: Frank Reininghaus <frank78ac@googlemail.com>
Date:   Mon Nov 5 22:03:52 2012 +0100

    Prevent crashes caused by nested event loops run when renaming inline
    When renaming inline and starting a drag or invoking the context menu,
    a nested event loop will be run. If the role editor loses focus and
    emits roleEditingFinished(), we must prevent that deleteLater() is
    called because this would delete the role editor inside a nested event
    loop which is run from one of its own functions. We would get a crash
    when returning from that event loop otherwise.
    BUG: 308018
    BUG: 309421
    FIXED-IN: 4.9.4

Reproducible: Always

Steps to Reproduce:
1. Use inline-renaming instead of rename-dialog
2. Select a file
3. Start renaming
4. Accept changes with RETURN key.
Actual Results:  
Crash -> File not renamed

Expected Results:  
Don't Crash -> Rename the file

It works fine when you accept the changes with focus losing (click with the mouse outside the inline-renaming box) => It only crashes with RETURN key

A have already tried to fix that with Locking (QMutex, QMutexLocker), but that didn't work.

An "ugly" but working fix is, when we replace the line emitRoleEditingFinished(); (kitemlistroleeditor.cpp line 147) with clearFocus();
=> So the event KItemListRoleEditor::event(QEvent* event) is only called once instead of two times, when you press the return key.
Comment 1 Frank Reininghaus 2012-11-08 18:30:36 UTC
Thanks Emmanuel! This was actually a rather tricky issue that I spent a lot
of time on, but nonetheless,I forgot to test this trivial use case. This
shows that I should have my own commits reviewed as well, at least the
non-trivial ones.

Using a mutex won't help because it's all in the same thread.

I'm not sure when I'll have the time to look into this. If the clearFocus
hack works, feel free to commit that and add a TODO comment that we should
look for a better long-term solution.

Thanks again for investigating the mess that I caused!
Comment 2 Emmanuel Pescosta 2012-11-09 11:11:23 UTC
Git commit 3143acc084d54d43df469b54762bfa10a7050a9f by Emmanuel Pescosta.
Committed on 09/11/2012 at 12:10.
Pushed by emmanuelp into branch 'KDE/4.9'.

Fix Bug 309760 - Crash while inline-renaming a file and apply change with return-key
FIXED-IN: 4.9.4

M  +2    -1    dolphin/src/kitemviews/private/kitemlistroleeditor.cpp