Bug 404566

Summary: KDevelop can get stuck trying to open a project
Product: [Developer tools] kdevplatform Reporter: RJVB <rjvbertin>
Component: projectAssignee: kdevelop-bugs-null
Status: REPORTED ---    
Severity: critical    
Priority: NOR    
Version First Reported In: 5.3.1   
Target Milestone: ---   
Platform: Compiled Sources   
OS: All   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:

Description RJVB 2019-02-19 18:19:24 UTC
SUMMARY
Sending a directory from the commandline to be opened in a running session can lead to that session getting stuck calling a KIO function, with a KIO progress dialog opening and closing at maximum speed.

STEPS TO REPRODUCE
1. Open a KDevelop session or two
2. Execute `kdevelop /path/to/projectdir/subdir1/subdir2`, select the session to target

EXPECTED RESULT
Anything but a stuck session.

KDevelop 5.3 branch head
KDE Frameworks Version: 5.52.0
Qt Version: 5.9.7

ADDITIONAL INFORMATION
This is a classic example of a dead loop:

```
        QUrl oldTest = testAt.adjusted(QUrl::RemoveFilename);
        if(oldTest == testAt)
            break;
```

QUrl::adjusted() returns the adjusted, not the old version and doesn't alter its instance. The break test thus never succeeds unless QUrl::adjusted has no effect to start with.

If the logic used is correct (keep removing filename(s) until that no longer has an effect), the code should be something like:

```
        QUrl oldTest = testAt;
        testAt = testAt.adjusted(QUrl::RemoveFilename);
        if(oldTest == testAt)
            break;
```