Bug 496133

Summary: dependency of task is wrongly calculated when tasks have priority
Product: [Applications] calligraplan Reporter: miko <mickael.sergent>
Component: usabilityAssignee: Dag Andersen <dag.andersen>
Status: RESOLVED FIXED    
Severity: normal    
Priority: NOR    
Version First Reported In: unspecified   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:
Attachments: test ok
test ko

Description miko 2024-11-11 16:12:20 UTC
Created attachment 175728 [details]
test ok

SUMMARY

Create a project with several tasks grouped by sub-task (see project example test2).
With default schedule, build a gannt, ok dependencies are correct

On some tasks, add priority (see project test3_prio), calculate again Gannt. We can see that the last task which depend of two another sub-tasks is scheduled too early


OBSERVED RESULT
with priority on some tasks, some tasks are scheduled too early

EXPECTED RESULT
see test2 (without priority => good) and test3_prio (with priority) => wrong gannt 

SOFTWARE/OS VERSIONS
Linux/KDE Plasma:  on Debian 12
KDE Plasma Version: 5.103
KDE Frameworks Version: 5.103
Qt Version: 5.15.8

ADDITIONAL INFORMATION
It is 'master' branch, compiled in debug mode (7e8350e8)
Comment 1 miko 2024-11-11 16:12:41 UTC
Created attachment 175729 [details]
test ko
Comment 2 miko 2024-11-16 17:15:36 UTC
Origin of the issue could be in scheduleForward() function. In fact, for priority it call scheduleFromStartTime which doesn't take into account predecessors instead of scheduleForward().

We don't find the bug in calculateBackward() which is a mirror function.

Probably a copy/past error from line 1040...1046 ?

Here a possible fix. 

diff --git a/src/libs/kernel/kptproject.cpp b/src/libs/kernel/kptproject.cpp
index 37d612e8..ab58a89a 100644
--- a/src/libs/kernel/kptproject.cpp
+++ b/src/libs/kernel/kptproject.cpp
@@ -1026,7 +1026,7 @@ DateTime Project::scheduleForward(const DateTime &earliest, int use)
     if (!m_priorityNodes.isEmpty()) {
         for (Node *n : qAsConst(m_priorityNodes)) {
             cs->logDebug(QStringLiteral("Schedule task '%1' by priority: %2").arg(n->name()).arg(n->priority()));
-            DateTime time = n->scheduleFromStartTime(use); // do not do predeccessors
+            DateTime time = n->scheduleForward(earliest, use);
             if (time > end) {
                 end = time;
                 cs->setLatestFinish(time);
Comment 3 Albert Astals Cid 2025-12-17 22:28:16 UTC
Git commit 2e739992be561ee629ed69ef5588bc07596de939 by Albert Astals Cid, on behalf of Mickael Sergent.
Committed on 17/12/2025 at 22:15.
Pushed by aacid into branch 'master'.

M  +1    -1    src/libs/kernel/kptproject.cpp

https://invent.kde.org/office/calligraplan/-/commit/2e739992be561ee629ed69ef5588bc07596de939