summaryrefslogblamecommitdiff
path: root/user/calligra/plan.patch
blob: c8f8c91fb7cc4dbf93e2156f69c37bdae0e6eedf (plain) (tree)















































                                                                                                                    
From 36ec68024620211edbcdb31a5ef6021545fe9451 Mon Sep 17 00:00:00 2001
From: Dag Andersen <danders@get2net.dk>
Date: Fri, 9 Feb 2018 08:40:34 +0100
Subject: Plan: Fix crash in tj scheduler if a resource does not have a
 calendar

This can happen when there is no default calendar and no calendar has been set for a resource.
---
 plan/src/plugins/schedulers/tj/PlanTJScheduler.cpp | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/plan/src/plugins/schedulers/tj/PlanTJScheduler.cpp b/plan/src/plugins/schedulers/tj/PlanTJScheduler.cpp
index 4f4e825..548969e 100644
--- a/plan/src/plugins/schedulers/tj/PlanTJScheduler.cpp
+++ b/plan/src/plugins/schedulers/tj/PlanTJScheduler.cpp
@@ -259,6 +259,9 @@ bool PlanTJScheduler::kplatoToTJ()
     addRequests();
     addStartEndJob();
 
+    if (result != -1) {
+        return false;
+    }
     return check();
 }
 
@@ -596,6 +599,7 @@ TJ::Resource *PlanTJScheduler::addResource( KPlato::Resource *r)
         res->setEfficiency( (double)(r->units()) / 100. );
     }
     Calendar *cal = r->calendar();
+    Q_ASSERT(cal);
     DateTime start = qMax( r->availableFrom(), m_project->constraintStartTime() );
     DateTime end = m_project->constraintEndTime();
     if ( r->availableUntil().isValid() && end > r->availableUntil() ) {
@@ -887,6 +891,11 @@ void PlanTJScheduler::addRequest( TJ::Task *job, Task *task )
         return;
     }
     foreach ( ResourceRequest *rr, task->requests().resourceRequests( true /*resolveTeam*/ ) ) {
+        if (!rr->resource()->calendar()) {
+            result = 1; // stops scheduling
+            logError(task, 0, i18n("No working hours defined for resource: %1",rr->resource()->name()));
+            continue; // may happen if no calendar is set, and no default calendar
+        }
         TJ::Resource *tjr = addResource( rr->resource() );
         TJ::Allocation *a = new TJ::Allocation();
         a->setSelectionMode( TJ::Allocation::order );
-- 
cgit v1.1