1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
|
From 4d9762cd151b7d6a208aece8cebcdbe09bd41703 Mon Sep 17 00:00:00 2001
From: Dag Andersen <danders@get2net.dk>
Date: Mon, 22 Aug 2016 09:15:32 +0200
Subject: [PATCH 66/80] Backport: Plan: Do not crash if scheduler plugins not
found
Shouldn't happen atm, but...
---
plan/libs/models/kptschedulemodel.cpp | 69 ++++++++++++++++++++++-------------
1 file changed, 43 insertions(+), 26 deletions(-)
diff --git a/plan/libs/models/kptschedulemodel.cpp b/plan/libs/models/kptschedulemodel.cpp
index 35b74bc..e3ce298 100644
--- a/plan/libs/models/kptschedulemodel.cpp
+++ b/plan/libs/models/kptschedulemodel.cpp
@@ -252,9 +252,16 @@ Qt::ItemFlags ScheduleItemModel::flags( const QModelIndex &index ) const
if ( !m_readWrite ) {
return flags &= ~Qt::ItemIsEditable;
}
- flags &= ~Qt::ItemIsEditable;
ScheduleManager *sm = manager( index );
- int capabilities = sm->schedulerPlugin()->capabilities();
+ if ( sm == 0 ) {
+ return flags;
+ }
+ SchedulerPlugin *pl = sm->schedulerPlugin();
+ if ( pl == 0 ) {
+ return flags;
+ }
+ int capabilities = pl->capabilities();
+ flags &= ~Qt::ItemIsEditable;
if ( sm && ! sm->isBaselined() ) {
switch ( index.column() ) {
case ScheduleModel::ScheduleState: break;
@@ -452,7 +459,11 @@ QVariant ScheduleItemModel::allowOverbooking( const QModelIndex &index, int role
if ( sm == 0 ) {
return QVariant();
}
- int capabilities = sm->schedulerPlugin()->capabilities();
+ SchedulerPlugin *pl = sm->schedulerPlugin();
+ if ( pl == 0 ) {
+ return QVariant();
+ }
+ int capabilities = pl->capabilities();
switch ( role ) {
case Qt::EditRole:
return sm->allowOverbooking();
@@ -480,11 +491,11 @@ QVariant ScheduleItemModel::allowOverbooking( const QModelIndex &index, int role
if ( capabilities & SchedulerPlugin::AllowOverbooking ) {
return sm->allowOverbooking()
? i18nc( "@info:tooltip", "Allow overbooking of resources" )
- : i18nc( "@info:tooltip 1=scheduler name", "%1 always allows overbooking of resources", sm->schedulerPlugin()->name() );
+ : i18nc( "@info:tooltip 1=scheduler name", "%1 always allows overbooking of resources", pl->name() );
}
if ( capabilities & SchedulerPlugin::AvoidOverbooking ) {
return sm->allowOverbooking()
- ? i18nc( "@info:tooltip 1=scheduler name", "%1 always avoids overbooking of resources", sm->schedulerPlugin()->name() )
+ ? i18nc( "@info:tooltip 1=scheduler name", "%1 always avoids overbooking of resources", pl->name() )
: i18nc( "@info:tooltip", "Avoid overbooking resources" );
}
break;
@@ -637,7 +648,11 @@ QVariant ScheduleItemModel::schedulingDirection( const QModelIndex &index, int r
if ( sm == 0 ) {
return QVariant();
}
- int capabilities = sm->schedulerPlugin()->capabilities();
+ SchedulerPlugin *pl = sm->schedulerPlugin();
+ if ( pl == 0 ) {
+ return QVariant();
+ }
+ int capabilities = pl->capabilities();
switch ( role ) {
case Qt::EditRole:
return sm->schedulingDirection();
@@ -664,13 +679,13 @@ QVariant ScheduleItemModel::schedulingDirection( const QModelIndex &index, int r
}
if ( capabilities & SchedulerPlugin::ScheduleForward ) {
return sm->schedulingDirection()
- ? i18nc( "@info:tooltip 1=scheduler name", "%1 always schedules from target start time", sm->schedulerPlugin()->name() )
+ ? i18nc( "@info:tooltip 1=scheduler name", "%1 always schedules from target start time", pl->name() )
: i18nc( "@info:tooltip", "Schedule project from target start time" );
}
if ( capabilities & SchedulerPlugin::ScheduleBackward ) {
return sm->schedulingDirection()
? i18nc( "@info:tooltip", "Schedule project from target end time" )
- : i18nc( "@info:tooltip 1=scheduler name", "%1 always schedules from target end time", sm->schedulerPlugin()->name() );
+ : i18nc( "@info:tooltip 1=scheduler name", "%1 always schedules from target end time", pl->name() );
}
break;
case Role::EnumList:
@@ -708,24 +723,26 @@ QVariant ScheduleItemModel::scheduler( const QModelIndex &index, int role ) cons
return QVariant();
}
SchedulerPlugin *pl = sm->schedulerPlugin();
- switch ( role ) {
- case Qt::EditRole:
- return sm->schedulerPluginId();
- case Qt::DisplayRole:
- return pl ? pl->name() : i18n( "Unknown" );
- case Qt::ToolTipRole:
- return pl ? pl->comment() : QString();
- case Role::EnumList:
- return sm->schedulerPluginNames();
- case Role::EnumListValue:
- return sm->schedulerPluginIndex();
- case Qt::TextAlignmentRole:
- return Qt::AlignCenter;
- case Qt::StatusTipRole:
- return QVariant();
- case Qt::WhatsThisRole: {
- QString s = pl->description();
- return s.isEmpty() ? QVariant() : QVariant( s );
+ if ( pl ) {
+ switch ( role ) {
+ case Qt::EditRole:
+ return sm->schedulerPluginId();
+ case Qt::DisplayRole:
+ return pl ? pl->name() : i18n( "Unknown" );
+ case Qt::ToolTipRole:
+ return pl ? pl->comment() : QString();
+ case Role::EnumList:
+ return sm->schedulerPluginNames();
+ case Role::EnumListValue:
+ return sm->schedulerPluginIndex();
+ case Qt::TextAlignmentRole:
+ return Qt::AlignCenter;
+ case Qt::StatusTipRole:
+ return QVariant();
+ case Qt::WhatsThisRole: {
+ QString s = pl->description();
+ return s.isEmpty() ? QVariant() : QVariant( s );
+ }
}
}
return QVariant();
--
2.7.4
|