Bug 495448 - ASSERT: "mn->findSchedule(sid) == nullptr" falls when tries to calculate a schedule
Summary: ASSERT: "mn->findSchedule(sid) == nullptr" falls when tries to calculate a sc...
Status: RESOLVED FIXED
Alias: None
Product: calligraplan
Classification: Applications
Component: general (other bugs)
Version First Reported In: unspecified
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Dag Andersen
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-10-27 20:39 UTC by miko
Modified: 2025-12-17 22:28 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed/Implemented In:
Sentry Crash Report:


Attachments
log of application (171.67 KB, text/plain)
2024-10-27 20:39 UTC, miko
Details
project example (10.19 KB, application/zip)
2024-10-27 20:39 UTC, miko
Details

Note You need to log in before you can comment on or make changes to this bug.
Description miko 2024-10-27 20:39:13 UTC
Created attachment 175286 [details]
log of application

SUMMARY

open a project, and calculate a schedule. Application crashes in:
ASSERT: "mn->findSchedule(sid) == nullptr" in file /home/mickael/projects/kde/calligraplan/src/libs/kernel/kptschedulerplugin.cpp, line 541

Do you know what is happens ?


STEPS TO REPRODUCE
1. open a project file
2. go to 'planification' click on calculate

OBSERVED RESULT

assert falls

EXPECTED RESULT

project rescheduled


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)

see example of project file  and log in attachement.
Comment 1 miko 2024-10-27 20:39:43 UTC
Created attachment 175287 [details]
project example
Comment 2 miko 2024-11-03 15:57:34 UTC
Hello,
May I have find the issue, in file ktpproject.cpp, calculated schedule seems not right (always 1), when browsed into m_schedule hash, it starts from 1 but in plan file (for example) it can be 3.
Here a example of fix, by browsing all hash value and take the max.

diff --git a/src/libs/kernel/kptproject.cpp b/src/libs/kernel/kptproject.cpp
index 37d612e8..0938bccf 100644
--- a/src/libs/kernel/kptproject.cpp
+++ b/src/libs/kernel/kptproject.cpp
@@ -2940,10 +2940,15 @@ void Project::addMainSchedule(MainSchedule *sch, int minId)
         return;
     }
     //debugPlan<<"No of schedules:"<<m_schedules.count();
-    long i = std::max(minId, 1); // keep this positive (negative values are special...)
-    while (m_schedules.contains(i)) {
-        ++i;
+    QHashIterator<long, Schedule*> it(m_schedules);
+    long i = minId;
+    while (it.hasNext()) {
+        it.next();
+        qInfo() << it.key() << ": " << it.value() ;
+        i = std::max(it.key(), i);
     }
+    ++i;
Comment 3 Albert Astals Cid 2025-12-17 22:28:06 UTC
Git commit 0fc4fbc5d8d19aae6293c78daee1b936e582ca2f by Albert Astals Cid, on behalf of Mickael Sergent.
Committed on 17/12/2025 at 22:15.
Pushed by aacid into branch 'master'.
Related: bug 1

M  +9    -3    src/libs/kernel/kptproject.cpp

https://invent.kde.org/office/calligraplan/-/commit/0fc4fbc5d8d19aae6293c78daee1b936e582ca2f