summaryrefslogtreecommitdiff
path: root/source/kde/patch
diff options
context:
space:
mode:
Diffstat (limited to 'source/kde/patch')
-rw-r--r--source/kde/patch/calligra.patch9
-rw-r--r--source/kde/patch/calligra/0001-adapt-to-libwps-0.4.patch52
-rw-r--r--source/kde/patch/calligra/0065-Backport-Plan-Fix-crash-due-to-accessing-deleted-obj.patch32
-rw-r--r--source/kde/patch/calligra/0066-Backport-Plan-Do-not-crash-if-scheduler-plugins-not-.patch138
-rw-r--r--source/kde/patch/calligra/0067-Backport-Plan-Fix-insert-file.patch101
-rw-r--r--source/kde/patch/calligra/0068-Backport-Plan-Fix-task-module-load-and-save.patch68
-rw-r--r--source/kde/patch/calligra/0069-Backport-Plan-Avoid-crash-in-special-cases.patch452
-rw-r--r--source/kde/patch/calligra/0070-Plan-Guard-against-trying-to-move-a-task-into-the-sa.patch50
-rw-r--r--source/kde/patch/calligra/calligra-2.9.11-gcc6_arm.patch12
9 files changed, 914 insertions, 0 deletions
diff --git a/source/kde/patch/calligra.patch b/source/kde/patch/calligra.patch
index 9e109851..e9e6cfd7 100644
--- a/source/kde/patch/calligra.patch
+++ b/source/kde/patch/calligra.patch
@@ -4,3 +4,12 @@ zcat $CWD/patch/calligra/calligra.mariadb.diff.gz | patch -p1 --verbose || { tou
# Patch for boost 1.65.0+:
zcat $CWD/patch/calligra/boost-1.65.0.patch.gz | patch -p1 --verbose || { touch ${SLACK_KDE_BUILD_DIR}/${PKGNAME}.failed ; continue ; }
+# Fedora patches, mostly backports to fix a Calligra Plan crash:
+zcat $CWD/patch/calligra/0001-adapt-to-libwps-0.4.patch.gz | patch -p1 --verbose || { touch ${SLACK_KDE_BUILD_DIR}/${PKGNAME}.failed ; continue ; }
+zcat $CWD/patch/calligra/0065-Backport-Plan-Fix-crash-due-to-accessing-deleted-obj.patch.gz | patch -p1 --verbose || { touch ${SLACK_KDE_BUILD_DIR}/${PKGNAME}.failed ; continue ; }
+zcat $CWD/patch/calligra/0066-Backport-Plan-Do-not-crash-if-scheduler-plugins-not-.patch.gz | patch -p1 --verbose || { touch ${SLACK_KDE_BUILD_DIR}/${PKGNAME}.failed ; continue ; }
+zcat $CWD/patch/calligra/0067-Backport-Plan-Fix-insert-file.patch.gz | patch -p1 --verbose || { touch ${SLACK_KDE_BUILD_DIR}/${PKGNAME}.failed ; continue ; }
+zcat $CWD/patch/calligra/0068-Backport-Plan-Fix-task-module-load-and-save.patch.gz | patch -p1 --verbose || { touch ${SLACK_KDE_BUILD_DIR}/${PKGNAME}.failed ; continue ; }
+zcat $CWD/patch/calligra/0069-Backport-Plan-Avoid-crash-in-special-cases.patch.gz | patch -p1 --verbose || { touch ${SLACK_KDE_BUILD_DIR}/${PKGNAME}.failed ; continue ; }
+zcat $CWD/patch/calligra/0070-Plan-Guard-against-trying-to-move-a-task-into-the-sa.patch.gz | patch -p1 --verbose || { touch ${SLACK_KDE_BUILD_DIR}/${PKGNAME}.failed ; continue ; }
+zcat $CWD/patch/calligra/calligra-2.9.11-gcc6_arm.patch.gz | patch -p1 --verbose || { touch ${SLACK_KDE_BUILD_DIR}/${PKGNAME}.failed ; continue ; }
diff --git a/source/kde/patch/calligra/0001-adapt-to-libwps-0.4.patch b/source/kde/patch/calligra/0001-adapt-to-libwps-0.4.patch
new file mode 100644
index 00000000..b4494b3e
--- /dev/null
+++ b/source/kde/patch/calligra/0001-adapt-to-libwps-0.4.patch
@@ -0,0 +1,52 @@
+From e81fe84405bc635dfa93e54fb8a3c8e6065dbf10 Mon Sep 17 00:00:00 2001
+From: David Tardon <dtardon@redhat.com>
+Date: Sat, 6 Jun 2015 18:27:24 +0200
+Subject: [PATCH] adapt to libwps 0.4
+
+---
+ cmake/modules/FindLibWps.cmake | 6 +++---
+ filters/words/works/import/WPSImport.cpp | 4 +++-
+ 2 files changed, 6 insertions(+), 4 deletions(-)
+
+diff --git a/cmake/modules/FindLibWps.cmake b/cmake/modules/FindLibWps.cmake
+index f8c8225..58ef2b5 100644
+--- a/cmake/modules/FindLibWps.cmake
++++ b/cmake/modules/FindLibWps.cmake
+@@ -10,16 +10,16 @@
+
+ include(LibFindMacros)
+ libfind_package(LIBWPS LibWpd)
+-libfind_pkg_check_modules(LIBWPS_PKGCONF libwps-0.3)
++libfind_pkg_check_modules(LIBWPS_PKGCONF libwps-0.4)
+
+ find_path(LIBWPS_INCLUDE_DIR
+ NAMES libwps/libwps.h
+ HINTS ${LIBWPS_PKGCONF_INCLUDE_DIRS} ${LIBWPS_PKGCONF_INCLUDEDIR}
+- PATH_SUFFIXES libwps-0.3
++ PATH_SUFFIXES libwps-0.4
+ )
+
+ find_library(LIBWPS_LIBRARY
+- NAMES wps wps-0.3
++ NAMES wps wps-0.4
+ HINTS ${LIBWPS_PKGCONF_LIBRARY_DIRS} ${LIBWPS_PKGCONF_LIBDIR}
+ )
+
+diff --git a/filters/words/works/import/WPSImport.cpp b/filters/words/works/import/WPSImport.cpp
+index eea2cc9..94b859d 100644
+--- a/filters/words/works/import/WPSImport.cpp
++++ b/filters/words/works/import/WPSImport.cpp
+@@ -91,7 +91,9 @@ public:
+ bool isSupportedFormat(librevenge::RVNGInputStream &input)
+ {
+ WPSKind kind = WPS_TEXT;
+- WPSConfidence confidence = WPSDocument::isFileFormatSupported(&input, kind);
++ WPSCreator creator = WPS_MSWORKS;
++ bool needsEncoding = false;
++ WPSConfidence confidence = WPSDocument::isFileFormatSupported(&input, kind, creator, needsEncoding);
+ if (confidence == WPS_CONFIDENCE_NONE || kind != WPS_TEXT)
+ return false;
+ return true;
+--
+2.4.2
+
diff --git a/source/kde/patch/calligra/0065-Backport-Plan-Fix-crash-due-to-accessing-deleted-obj.patch b/source/kde/patch/calligra/0065-Backport-Plan-Fix-crash-due-to-accessing-deleted-obj.patch
new file mode 100644
index 00000000..b3f38d47
--- /dev/null
+++ b/source/kde/patch/calligra/0065-Backport-Plan-Fix-crash-due-to-accessing-deleted-obj.patch
@@ -0,0 +1,32 @@
+From 7c64caec3022b28775ea85864eef47bf2ac51066 Mon Sep 17 00:00:00 2001
+From: Dag Andersen <danders@get2net.dk>
+Date: Mon, 22 Aug 2016 08:49:13 +0200
+Subject: [PATCH 65/80] Backport: Plan: Fix crash due to accessing deleted
+ object
+
+KReportDesigner takes ownership of reportdata, so give it a clone it can delete
+---
+ plan/libs/ui/reports/reportview.cpp | 6 +++---
+ 1 file changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/plan/libs/ui/reports/reportview.cpp b/plan/libs/ui/reports/reportview.cpp
+index 462a31d..8552790 100644
+--- a/plan/libs/ui/reports/reportview.cpp
++++ b/plan/libs/ui/reports/reportview.cpp
+@@ -1250,10 +1250,10 @@ void ReportDesigner::createDockers()
+
+ void ReportDesigner::setReportData( const QString &tag )
+ {
+-
++ emit optionsModified();
+ ReportData *rd = Report::findReportData( m_reportdatamodels, tag );
+- if ( rd != m_designer->reportData() ) {
+- emit optionsModified();
++ if ( rd ) {
++ rd = rd->clone(); // KReportDesigner takes ownership, so give it a clone it can delete
+ }
+ m_designer->setReportData( rd );
+
+--
+2.7.4
+
diff --git a/source/kde/patch/calligra/0066-Backport-Plan-Do-not-crash-if-scheduler-plugins-not-.patch b/source/kde/patch/calligra/0066-Backport-Plan-Do-not-crash-if-scheduler-plugins-not-.patch
new file mode 100644
index 00000000..efbd9ac8
--- /dev/null
+++ b/source/kde/patch/calligra/0066-Backport-Plan-Do-not-crash-if-scheduler-plugins-not-.patch
@@ -0,0 +1,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
+
diff --git a/source/kde/patch/calligra/0067-Backport-Plan-Fix-insert-file.patch b/source/kde/patch/calligra/0067-Backport-Plan-Fix-insert-file.patch
new file mode 100644
index 00000000..4db4becc
--- /dev/null
+++ b/source/kde/patch/calligra/0067-Backport-Plan-Fix-insert-file.patch
@@ -0,0 +1,101 @@
+From 5cffbe5ecf1f82369abbad1a06154368459f7845 Mon Sep 17 00:00:00 2001
+From: Dag Andersen <danders@get2net.dk>
+Date: Mon, 22 Aug 2016 09:20:32 +0200
+Subject: [PATCH 67/80] Backport: Plan: Fix insert file
+
+Use KUrl instead of QString for filename
+KoDocument::openUrl() opens the url (not KoPart)
+---
+ plan/kptmaindocument.cpp | 23 ++++++++++-------------
+ plan/kptmaindocument.h | 4 ++--
+ plan/kptview.cpp | 2 +-
+ 3 files changed, 13 insertions(+), 16 deletions(-)
+
+diff --git a/plan/kptmaindocument.cpp b/plan/kptmaindocument.cpp
+index 2343471..e418972 100644
+--- a/plan/kptmaindocument.cpp
++++ b/plan/kptmaindocument.cpp
+@@ -947,35 +947,32 @@ bool MainDocument::loadAndParse(KoStore *store, const QString &filename, KoXmlDo
+ return true;
+ }
+
+-void MainDocument::insertFile( const QString &filename, Node *parent, Node *after )
++void MainDocument::insertFile( const KUrl &url, Node *parent, Node *after )
+ {
+ Part *part = new Part( this );
+ MainDocument *doc = new MainDocument( part );
+ part->setDocument( doc );
+ doc->disconnect(); // doc shall not handle feedback from openUrl()
+ doc->setAutoSave( 0 ); //disable
+- doc->m_insertFileInfo.url = filename;
++ doc->m_insertFileInfo.url = url;
+ doc->m_insertFileInfo.parent = parent;
+ doc->m_insertFileInfo.after = after;
+ connect(doc, SIGNAL(completed()), SLOT(insertFileCompleted()));
+ connect(doc, SIGNAL(canceled(QString)), SLOT(insertFileCancelled(QString)));
+
+- doc->openUrl( KUrl( filename ) );
++ doc->openUrl( url );
+ }
+
+ void MainDocument::insertFileCompleted()
+ {
+ kDebug(planDbg())<<sender();
+- Part *part = qobject_cast<Part*>( sender() );
+- if ( part ) {
+- MainDocument *doc = qobject_cast<MainDocument*>( part->document() );
+- if ( doc ) {
+- Project &p = doc->getProject();
+- insertProject( p, doc->m_insertFileInfo.parent, doc->m_insertFileInfo.after );
+- } else {
+- KMessageBox::error( 0, i18n("Internal error, failed to insert file.") );
+- }
+- part->deleteLater(); // also deletes document
++ MainDocument *doc = qobject_cast<MainDocument*>( sender() );
++ if ( doc ) {
++ Project &p = doc->getProject();
++ insertProject( p, doc->m_insertFileInfo.parent, doc->m_insertFileInfo.after );
++ doc->documentPart()->deleteLater(); // also deletes document
++ } else {
++ KMessageBox::error( 0, i18n("Internal error, failed to insert file.") );
+ }
+ }
+
+diff --git a/plan/kptmaindocument.h b/plan/kptmaindocument.h
+index 5ead4ea..c467e1f 100644
+--- a/plan/kptmaindocument.h
++++ b/plan/kptmaindocument.h
+@@ -117,7 +117,7 @@ public:
+ Package *loadWorkPackageXML( Project& project, QIODevice*, const KoXmlDocument& document, const KUrl& url );
+ QMap<KDateTime, Package*> workPackages() const { return m_workpackages; }
+
+- void insertFile( const QString &filename, Node *parent, Node *after = 0 );
++ void insertFile( const KUrl &url, Node *parent, Node *after = 0 );
+ bool insertProject( Project &project, Node *parent, Node *after );
+
+ KPlatoAboutPage &aboutPage() { return m_aboutPage; }
+@@ -165,7 +165,7 @@ protected:
+
+ // used by insert file
+ struct InsertFileInfo {
+- QString url;
++ KUrl url;
+ Node *parent;
+ Node *after;
+ } m_insertFileInfo;
+diff --git a/plan/kptview.cpp b/plan/kptview.cpp
+index 6876c3e..b38d8b6 100644
+--- a/plan/kptview.cpp
++++ b/plan/kptview.cpp
+@@ -1452,7 +1452,7 @@ void View::slotInsertFileFinished( int result )
+ return;
+ }
+ if ( result == QDialog::Accepted ) {
+- getPart()->insertFile( dlg->url().url(), dlg->parentNode(), dlg->afterNode() );
++ getPart()->insertFile( dlg->url(), dlg->parentNode(), dlg->afterNode() );
+ }
+ dlg->deleteLater();
+ }
+--
+2.7.4
+
diff --git a/source/kde/patch/calligra/0068-Backport-Plan-Fix-task-module-load-and-save.patch b/source/kde/patch/calligra/0068-Backport-Plan-Fix-task-module-load-and-save.patch
new file mode 100644
index 00000000..ca6ae192
--- /dev/null
+++ b/source/kde/patch/calligra/0068-Backport-Plan-Fix-task-module-load-and-save.patch
@@ -0,0 +1,68 @@
+From fd5b8dca68d0a418aac926fe60814ebe537ee032 Mon Sep 17 00:00:00 2001
+From: Dag Andersen <danders@get2net.dk>
+Date: Mon, 22 Aug 2016 10:00:52 +0200
+Subject: [PATCH 68/80] Backport: Plan: Fix task module load and save
+
+Workaround: saveTaskModules destroys project
+---
+ plan/kptview.cpp | 19 ++++++++++++-------
+ plan/libs/models/kptnodeitemmodel.cpp | 6 +++++-
+ 2 files changed, 17 insertions(+), 8 deletions(-)
+
+diff --git a/plan/kptview.cpp b/plan/kptview.cpp
+index b38d8b6..af606f6 100644
+--- a/plan/kptview.cpp
++++ b/plan/kptview.cpp
+@@ -114,6 +114,7 @@
+ #include "kptviewlistdocker.h"
+ #include "kptviewlist.h"
+ #include "kptschedulesdocker.h"
++#include "kptpart.h"
+ #include "kptdebug.h"
+
+ #include "plansettings.h"
+@@ -3033,13 +3034,17 @@ void View::saveTaskModule( const KUrl &url, Project *project )
+ QString dir = Factory::global().dirs()->saveLocation( "plan_taskmodules" );
+ kDebug(planDbg())<<"dir="<<dir;
+ if ( ! dir.isEmpty() ) {
+- MainDocument part(getKoPart());
+- part.insertProject( *project, 0, 0 );
+- part.getProject().setName( project->name() );
+- part.getProject().setLeader( project->leader() );
+- part.getProject().setDescription( project->description() );
+- part.saveNativeFormat( dir + url.fileName() );
+- kDebug(planDbg())<<dir + url.fileName();
++ Part *part = new Part( this );
++ MainDocument *doc = new MainDocument( part );
++ part->setDocument( doc );
++ doc->disconnect(); // doc shall not handle feedback from openUrl()
++ doc->setAutoSave( 0 ); //disable
++ doc->insertProject( *project, 0, 0 );
++ doc->getProject().setName( project->name() );
++ doc->getProject().setLeader( project->leader() );
++ doc->getProject().setDescription( project->description() );
++ doc->saveNativeFormat( dir + url.fileName() );
++ part->deleteLater(); // also deletes document
+ } else {
+ kDebug(planDbg())<<"Could not find a location";
+ }
+diff --git a/plan/libs/models/kptnodeitemmodel.cpp b/plan/libs/models/kptnodeitemmodel.cpp
+index 834e45a..45b1650 100644
+--- a/plan/libs/models/kptnodeitemmodel.cpp
++++ b/plan/libs/models/kptnodeitemmodel.cpp
+@@ -4990,7 +4990,11 @@ bool TaskModuleModel::importProject( const KUrl &url, bool emitsignal )
+ stripProject( project );
+ addTaskModule( project );
+ if ( emitsignal ) {
+- emit saveTaskModule( url, project );
++ // FIXME: save modifies the project, so give it a copy (see kptview.cpp)
++ Project p;
++ status.setProject( &p );
++ p.load( element, status );
++ emit saveTaskModule( url, &p );
+ }
+ } else {
+ kDebug(planDbg())<<"Failed to load project from:"<<url;
+--
+2.7.4
+
diff --git a/source/kde/patch/calligra/0069-Backport-Plan-Avoid-crash-in-special-cases.patch b/source/kde/patch/calligra/0069-Backport-Plan-Avoid-crash-in-special-cases.patch
new file mode 100644
index 00000000..75ec66b5
--- /dev/null
+++ b/source/kde/patch/calligra/0069-Backport-Plan-Avoid-crash-in-special-cases.patch
@@ -0,0 +1,452 @@
+From b25d46bf9fa6d5b9ff34115edb4719592c191935 Mon Sep 17 00:00:00 2001
+From: Dag Andersen <danders@get2net.dk>
+Date: Tue, 23 Aug 2016 08:01:58 +0200
+Subject: [PATCH 69/80] Backport: Plan: Avoid crash in special cases
+
+Sometimes (eg. when New is pressed) the Project can be deleted before models
+and thus cause a crash.
+Added a Project::aboutToBeDeleted signal so models can adjust.
+
+BUG: 346976
+FIXED_IN: 2.9.12
+---
+ plan/libs/kernel/kptproject.cpp | 1 +
+ plan/libs/kernel/kptproject.h | 2 ++
+ plan/libs/models/kptaccountsmodel.cpp | 2 ++
+ plan/libs/models/kptcalendarmodel.cpp | 4 ++++
+ plan/libs/models/kptitemmodelbase.cpp | 5 +++++
+ plan/libs/models/kptitemmodelbase.h | 1 +
+ plan/libs/models/kptnodechartmodel.cpp | 2 ++
+ plan/libs/models/kptnodeitemmodel.cpp | 4 ++++
+ plan/libs/models/kptpertcpmmodel.cpp | 4 ++++
+ plan/libs/models/kptrelationmodel.cpp | 2 ++
+ plan/libs/models/kptresourceallocationmodel.cpp | 2 ++
+ plan/libs/models/kptresourceappointmentsmodel.cpp | 8 ++++++++
+ plan/libs/models/kptresourcemodel.cpp | 12 +++++++-----
+ plan/libs/models/kptschedulemodel.cpp | 13 +++++++++++++
+ plan/libs/models/kptschedulemodel.h | 2 ++
+ plan/libs/models/kpttaskstatusmodel.cpp | 2 ++
+ 16 files changed, 61 insertions(+), 5 deletions(-)
+
+diff --git a/plan/libs/kernel/kptproject.cpp b/plan/libs/kernel/kptproject.cpp
+index 158040b..451e897 100644
+--- a/plan/libs/kernel/kptproject.cpp
++++ b/plan/libs/kernel/kptproject.cpp
+@@ -89,6 +89,7 @@ void Project::deref()
+ --m_refCount;
+ Q_ASSERT( m_refCount >= 0 );
+ if ( m_refCount <= 0 ) {
++ emit aboutToBeDeleted();
+ deleteLater();
+ }
+ }
+diff --git a/plan/libs/kernel/kptproject.h b/plan/libs/kernel/kptproject.h
+index 1dbea7d..db18d36 100644
+--- a/plan/libs/kernel/kptproject.h
++++ b/plan/libs/kernel/kptproject.h
+@@ -519,6 +519,8 @@ public Q_SLOTS:
+ void setMaxProgress( int max, ScheduleManager *sm = 0 );
+
+ Q_SIGNALS:
++ /// Emitted when the project is about to be deleted (The destroyed signal is disabled)
++ void aboutToBeDeleted();
+ /// Emitted when anything in the project is changed (use with care)
+ void projectChanged();
+ /// Emitted when the WBS code definition has changed. This may change all nodes.
+diff --git a/plan/libs/models/kptaccountsmodel.cpp b/plan/libs/models/kptaccountsmodel.cpp
+index 53f725a..4657979 100644
+--- a/plan/libs/models/kptaccountsmodel.cpp
++++ b/plan/libs/models/kptaccountsmodel.cpp
+@@ -533,6 +533,7 @@ void CostBreakdownItemModel::setProject( Project *project )
+ disconnect( acc, SIGNAL(accountRemoved(const Account*)), this, SLOT(slotAccountRemoved(const Account*)) );
+ disconnect( acc, SIGNAL(accountToBeRemoved(const Account*)), this, SLOT(slotAccountToBeRemoved(const Account*)) );
+
++ disconnect(m_project, SIGNAL(aboutToBeDeleted()), this, SLOT(projectDeleted()));
+ disconnect( m_project , SIGNAL(nodeChanged(Node*)), this, SLOT(slotDataChanged()) );
+ disconnect( m_project , SIGNAL(nodeAdded(Node*)), this, SLOT(slotDataChanged()) );
+ disconnect( m_project , SIGNAL(nodeRemoved(Node*)), this, SLOT(slotDataChanged()) );
+@@ -553,6 +554,7 @@ void CostBreakdownItemModel::setProject( Project *project )
+ connect( acc, SIGNAL(accountRemoved(const Account*)), this, SLOT(slotAccountRemoved(const Account*)) );
+ connect( acc, SIGNAL(accountToBeRemoved(const Account*)), this, SLOT(slotAccountToBeRemoved(const Account*)) );
+
++ connect(m_project, SIGNAL(aboutToBeDeleted()), this, SLOT(projectDeleted()));
+ connect( m_project , SIGNAL(nodeChanged(Node*)), this, SLOT(slotDataChanged()) );
+ connect( m_project , SIGNAL(nodeAdded(Node*)), this, SLOT(slotDataChanged()) );
+ connect( m_project , SIGNAL(nodeRemoved(Node*)), this, SLOT(slotDataChanged()) );
+diff --git a/plan/libs/models/kptcalendarmodel.cpp b/plan/libs/models/kptcalendarmodel.cpp
+index 6c0f017..401379c 100644
+--- a/plan/libs/models/kptcalendarmodel.cpp
++++ b/plan/libs/models/kptcalendarmodel.cpp
+@@ -74,10 +74,12 @@ void CalendarDayItemModelBase::setProject( Project *project )
+ {
+ setCalendar( 0 );
+ if ( m_project ) {
++ disconnect(m_project, SIGNAL(aboutToBeDeleted()), this, SLOT(projectDeleted()));
+ disconnect( m_project, SIGNAL(calendarToBeRemoved(const Calendar*)), this, SLOT(slotCalendarToBeRemoved(const Calendar*)) );
+ }
+ m_project = project;
+ if ( project ) {
++ connect(m_project, SIGNAL(aboutToBeDeleted()), this, SLOT(projectDeleted()));
+ connect( m_project, SIGNAL(calendarToBeRemoved(const Calendar*)), this, SLOT(slotCalendarToBeRemoved(const Calendar*)) );
+ }
+ reset();
+@@ -136,6 +138,7 @@ void CalendarItemModel::slotCalendarRemoved( const Calendar * )
+ void CalendarItemModel::setProject( Project *project )
+ {
+ if ( m_project ) {
++ disconnect(m_project, SIGNAL(aboutToBeDeleted()), this, SLOT(projectDeleted()));
+ disconnect( m_project , SIGNAL(calendarChanged(Calendar*)), this, SLOT(slotCalendarChanged(Calendar*)) );
+
+ disconnect( m_project, SIGNAL(calendarAdded(const Calendar*)), this, SLOT(slotCalendarInserted(const Calendar*)) );
+@@ -146,6 +149,7 @@ void CalendarItemModel::setProject( Project *project )
+ }
+ m_project = project;
+ if ( project ) {
++ connect(m_project, SIGNAL(aboutToBeDeleted()), this, SLOT(projectDeleted()));
+ connect( m_project, SIGNAL(calendarChanged(Calendar*)), this, SLOT(slotCalendarChanged(Calendar*)) );
+
+ connect( m_project, SIGNAL(calendarAdded(const Calendar*)), this, SLOT(slotCalendarInserted(const Calendar*)) );
+diff --git a/plan/libs/models/kptitemmodelbase.cpp b/plan/libs/models/kptitemmodelbase.cpp
+index 499fcfe..ff74394 100644
+--- a/plan/libs/models/kptitemmodelbase.cpp
++++ b/plan/libs/models/kptitemmodelbase.cpp
+@@ -731,6 +731,11 @@ bool ItemModelBase::setData( const QModelIndex &index, const QVariant &value, in
+ return false;
+ }
+
++void ItemModelBase::projectDeleted()
++{
++ setProject(0);
++}
++
+ } //namespace KPlato
+
+ #include "kptitemmodelbase.moc"
+diff --git a/plan/libs/models/kptitemmodelbase.h b/plan/libs/models/kptitemmodelbase.h
+index 578c18e..5d3719d 100644
+--- a/plan/libs/models/kptitemmodelbase.h
++++ b/plan/libs/models/kptitemmodelbase.h
+@@ -309,6 +309,7 @@ protected Q_SLOTS:
+ virtual void slotLayoutToBeChanged();
+ virtual void slotLayoutChanged();
+
++ void projectDeleted();
+ protected:
+ Project *m_project;
+ ScheduleManager *m_manager;
+diff --git a/plan/libs/models/kptnodechartmodel.cpp b/plan/libs/models/kptnodechartmodel.cpp
+index 025da86..9b8d397 100644
+--- a/plan/libs/models/kptnodechartmodel.cpp
++++ b/plan/libs/models/kptnodechartmodel.cpp
+@@ -294,6 +294,7 @@ void ChartItemModel::setProject( Project *project )
+ m_bcws.clear();
+ m_acwp.clear();
+ if ( m_project ) {
++ disconnect(m_project, SIGNAL(aboutToBeDeleted()), this, SLOT(projectDeleted()));
+ disconnect( m_project, SIGNAL(projectCalculated(ScheduleManager*)), this, SLOT(setScheduleManager(ScheduleManager*)) );
+ disconnect( m_project, SIGNAL(nodeRemoved(Node*)), this, SLOT(slotNodeRemoved(Node*)) );
+ disconnect( m_project, SIGNAL(nodeChanged(Node*)), this, SLOT(slotNodeChanged(Node*)) );
+@@ -302,6 +303,7 @@ void ChartItemModel::setProject( Project *project )
+ }
+ m_project = project;
+ if ( m_project ) {
++ connect(m_project, SIGNAL(aboutToBeDeleted()), this, SLOT(projectDeleted()));
+ connect( m_project, SIGNAL(projectCalculated(ScheduleManager*)), this, SLOT(setScheduleManager(ScheduleManager*)) );
+ connect( m_project, SIGNAL(nodeRemoved(Node*)), this, SLOT(slotNodeRemoved(Node*)) );
+ connect( m_project, SIGNAL(nodeChanged(Node*)), this, SLOT(slotNodeChanged(Node*)) );
+diff --git a/plan/libs/models/kptnodeitemmodel.cpp b/plan/libs/models/kptnodeitemmodel.cpp
+index 45b1650..e66277f 100644
+--- a/plan/libs/models/kptnodeitemmodel.cpp
++++ b/plan/libs/models/kptnodeitemmodel.cpp
+@@ -3122,6 +3122,7 @@ void NodeItemModel::slotWbsDefinitionChanged()
+ void NodeItemModel::setProject( Project *project )
+ {
+ if ( m_project ) {
++ disconnect(m_project, SIGNAL(aboutToBeDeleted()), this, SLOT(projectDeleted()));
+ disconnect( m_project, SIGNAL(localeChanged()), this, SLOT(slotLayoutChanged()) );
+ disconnect( m_project, SIGNAL(wbsDefinitionChanged()), this, SLOT(slotWbsDefinitionChanged()) );
+ disconnect( m_project, SIGNAL(nodeChanged(Node*)), this, SLOT(slotNodeChanged(Node*)) );
+@@ -3139,6 +3140,7 @@ void NodeItemModel::setProject( Project *project )
+ kDebug(planDbg())<<this<<m_project<<"->"<<project;
+ m_nodemodel.setProject( project );
+ if ( project ) {
++ connect(m_project, SIGNAL(aboutToBeDeleted()), this, SLOT(projectDeleted()));
+ connect( m_project, SIGNAL(localeChanged()), this, SLOT(slotLayoutChanged()) );
+ connect( m_project, SIGNAL(wbsDefinitionChanged()), this, SLOT(slotWbsDefinitionChanged()) );
+ connect( m_project, SIGNAL(nodeChanged(Node*)), this, SLOT(slotNodeChanged(Node*)) );
+@@ -4381,6 +4383,7 @@ void MilestoneItemModel::slotNodeMoved( Node *node )
+ void MilestoneItemModel::setProject( Project *project )
+ {
+ if ( m_project ) {
++ disconnect(m_project, SIGNAL(aboutToBeDeleted()), this, SLOT(projectDeleted()));
+ disconnect( m_project, SIGNAL(localeChanged()), this, SLOT(slotLayoutChanged()) );
+ disconnect( m_project, SIGNAL(wbsDefinitionChanged()), this, SLOT(slotWbsDefinitionChanged()) );
+ disconnect( m_project, SIGNAL(nodeChanged(Node*)), this, SLOT(slotNodeChanged(Node*)) );
+@@ -4397,6 +4400,7 @@ void MilestoneItemModel::setProject( Project *project )
+ //kDebug(planDbg())<<m_project<<"->"<<project;
+ m_nodemodel.setProject( project );
+ if ( project ) {
++ connect(m_project, SIGNAL(aboutToBeDeleted()), this, SLOT(projectDeleted()));
+ connect( m_project, SIGNAL(localeChanged()), this, SLOT(slotLayoutChanged()) );
+ connect( m_project, SIGNAL(wbsDefinitionChanged()), this, SLOT(slotWbsDefinitionChanged()) );
+ connect( m_project, SIGNAL(nodeChanged(Node*)), this, SLOT(slotNodeChanged(Node*)) );
+diff --git a/plan/libs/models/kptpertcpmmodel.cpp b/plan/libs/models/kptpertcpmmodel.cpp
+index 71745ef..7340c61 100644
+--- a/plan/libs/models/kptpertcpmmodel.cpp
++++ b/plan/libs/models/kptpertcpmmodel.cpp
+@@ -82,6 +82,7 @@ void CriticalPathItemModel::slotNodeRemoved( Node *node )
+ void CriticalPathItemModel::setProject( Project *project )
+ {
+ if ( m_project ) {
++ disconnect(m_project, SIGNAL(aboutToBeDeleted()), this, SLOT(projectDeleted()));
+ disconnect( m_project, SIGNAL(nodeChanged(Node*)), this, SLOT(slotNodeChanged(Node*)) );
+ disconnect( m_project, SIGNAL(nodeToBeAdded(Node*,int)), this, SLOT(slotNodeToBeInserted(Node*,int)) );
+ disconnect( m_project, SIGNAL(nodeToBeRemoved(Node*)), this, SLOT(slotNodeToBeRemoved(Node*)) );
+@@ -94,6 +95,7 @@ void CriticalPathItemModel::setProject( Project *project )
+ m_project = project;
+ m_nodemodel.setProject( project );
+ if ( project ) {
++ connect(m_project, SIGNAL(aboutToBeDeleted()), this, SLOT(projectDeleted()));
+ connect( m_project, SIGNAL(nodeChanged(Node*)), this, SLOT(slotNodeChanged(Node*)) );
+ connect( m_project, SIGNAL(nodeToBeAdded(Node*,int)), this, SLOT(slotNodeToBeInserted(Node*,int)) );
+ connect( m_project, SIGNAL(nodeToBeRemoved(Node*)), this, SLOT(slotNodeToBeRemoved(Node*)) );
+@@ -354,6 +356,7 @@ void PertResultItemModel::setProject( Project *project )
+ {
+ clear();
+ if ( m_project ) {
++ disconnect(m_project, SIGNAL(aboutToBeDeleted()), this, SLOT(projectDeleted()));
+ disconnect( m_project, SIGNAL(nodeChanged(Node*)), this, SLOT(slotNodeChanged(Node*)) );
+ disconnect( m_project, SIGNAL(nodeToBeAdded(Node*,int)), this, SLOT(slotNodeToBeInserted(Node*,int)) );
+ disconnect( m_project, SIGNAL(nodeToBeRemoved(Node*)), this, SLOT(slotNodeToBeRemoved(Node*)) );
+@@ -366,6 +369,7 @@ void PertResultItemModel::setProject( Project *project )
+ m_project = project;
+ m_nodemodel.setProject( project );
+ if ( project ) {
++ connect(m_project, SIGNAL(aboutToBeDeleted()), this, SLOT(projectDeleted()));
+ connect( m_project, SIGNAL(nodeChanged(Node*)), this, SLOT(slotNodeChanged(Node*)) );
+ connect( m_project, SIGNAL(nodeToBeAdded(Node*,int)), this, SLOT(slotNodeToBeInserted(Node*,int)) );
+ connect( m_project, SIGNAL(nodeToBeRemoved(Node*)), this, SLOT(slotNodeToBeRemoved(Node*)) );
+diff --git a/plan/libs/models/kptrelationmodel.cpp b/plan/libs/models/kptrelationmodel.cpp
+index b2617fb..a5acfb6 100644
+--- a/plan/libs/models/kptrelationmodel.cpp
++++ b/plan/libs/models/kptrelationmodel.cpp
+@@ -241,6 +241,7 @@ void RelationItemModel::slotLayoutChanged()
+ void RelationItemModel::setProject( Project *project )
+ {
+ if ( m_project ) {
++ disconnect(m_project, SIGNAL(aboutToBeDeleted()), this, SLOT(projectDeleted()));
+ disconnect( m_project, SIGNAL(nodeChanged(Node*)), this, SLOT(slotNodeChanged(Node*)) );
+ disconnect( m_project, SIGNAL(nodeToBeRemoved(Node*)), this, SLOT(slotNodeToBeRemoved(Node*)) );
+
+@@ -254,6 +255,7 @@ void RelationItemModel::setProject( Project *project )
+ }
+ m_project = project;
+ if ( project ) {
++ connect(m_project, SIGNAL(aboutToBeDeleted()), this, SLOT(projectDeleted()));
+ connect( m_project, SIGNAL(nodeChanged(Node*)), this, SLOT(slotNodeChanged(Node*)) );
+ connect( m_project, SIGNAL(nodeToBeRemoved(Node*)), this, SLOT(slotNodeToBeRemoved(Node*)) );
+
+diff --git a/plan/libs/models/kptresourceallocationmodel.cpp b/plan/libs/models/kptresourceallocationmodel.cpp
+index 11f909e..500a24c 100644
+--- a/plan/libs/models/kptresourceallocationmodel.cpp
++++ b/plan/libs/models/kptresourceallocationmodel.cpp
+@@ -425,6 +425,7 @@ void ResourceAllocationItemModel::slotResourceGroupRemoved( const ResourceGroup
+ void ResourceAllocationItemModel::setProject( Project *project )
+ {
+ if ( m_project ) {
++ disconnect(m_project, SIGNAL(aboutToBeDeleted()), this, SLOT(projectDeleted()));
+ disconnect( m_project, SIGNAL(resourceChanged(Resource*)), this, SLOT(slotResourceChanged(Resource*)) );
+ disconnect( m_project, SIGNAL(resourceGroupChanged(ResourceGroup*)), this, SLOT(slotResourceGroupChanged(ResourceGroup*)) );
+
+@@ -447,6 +448,7 @@ void ResourceAllocationItemModel::setProject( Project *project )
+ }
+ m_project = project;
+ if ( m_project ) {
++ connect(m_project, SIGNAL(aboutToBeDeleted()), this, SLOT(projectDeleted()));
+ connect( m_project, SIGNAL(resourceChanged(Resource*)), this, SLOT(slotResourceChanged(Resource*)) );
+ connect( m_project, SIGNAL(resourceGroupChanged(ResourceGroup*)), this, SLOT(slotResourceGroupChanged(ResourceGroup*)) );
+
+diff --git a/plan/libs/models/kptresourceappointmentsmodel.cpp b/plan/libs/models/kptresourceappointmentsmodel.cpp
+index b580dfe..f4700c6 100644
+--- a/plan/libs/models/kptresourceappointmentsmodel.cpp
++++ b/plan/libs/models/kptresourceappointmentsmodel.cpp
+@@ -220,7 +220,10 @@ void ResourceAppointmentsItemModel::setProject( Project *project )
+ {
+ kDebug(planDbg());
+ if ( m_project ) {
++ disconnect(m_project, SIGNAL(aboutToBeDeleted()), this, SLOT(projectDeleted()));
++
+ disconnect( m_project, SIGNAL(resourceChanged(Resource*)), this, SLOT(slotResourceChanged(Resource*)) );
++
+ disconnect( m_project, SIGNAL(resourceGroupChanged(ResourceGroup*)), this, SLOT(slotResourceGroupChanged(ResourceGroup*)) );
+
+ disconnect( m_project, SIGNAL(resourceGroupToBeAdded(const ResourceGroup*,int)), this, SLOT(slotResourceGroupToBeInserted(const ResourceGroup*,int)) );
+@@ -255,6 +258,7 @@ void ResourceAppointmentsItemModel::setProject( Project *project )
+ }
+ m_project = project;
+ if ( m_project ) {
++ connect(m_project, SIGNAL(aboutToBeDeleted()), this, SLOT(projectDeleted()));
+ connect( m_project, SIGNAL(resourceChanged(Resource*)), this, SLOT(slotResourceChanged(Resource*)) );
+ connect( m_project, SIGNAL(resourceGroupChanged(ResourceGroup*)), this, SLOT(slotResourceGroupChanged(ResourceGroup*)) );
+
+@@ -1351,6 +1355,8 @@ void ResourceAppointmentsRowModel::setProject( Project *project )
+ {
+ //kDebug(planDbg())<<project;
+ if ( m_project ) {
++ disconnect(m_project, SIGNAL(aboutToBeDeleted()), this, SLOT(projectDeleted()));
++
+ disconnect( m_project, SIGNAL(resourceGroupToBeAdded(const ResourceGroup*,int)), this, SLOT(slotResourceGroupToBeInserted(const ResourceGroup*,int)) );
+
+ disconnect( m_project, SIGNAL(resourceGroupToBeRemoved(const ResourceGroup*)), this, SLOT(slotResourceGroupToBeRemoved(const ResourceGroup*)) );
+@@ -1379,6 +1385,8 @@ void ResourceAppointmentsRowModel::setProject( Project *project )
+ }
+ m_project = project;
+ if ( m_project ) {
++ connect(m_project, SIGNAL(aboutToBeDeleted()), this, SLOT(projectDeleted()));
++
+ connect( m_project, SIGNAL(resourceGroupToBeAdded(const ResourceGroup*,int)), this, SLOT(slotResourceGroupToBeInserted(const ResourceGroup*,int)) );
+
+ connect( m_project, SIGNAL(resourceGroupToBeRemoved(const ResourceGroup*)), this, SLOT(slotResourceGroupToBeRemoved(const ResourceGroup*)) );
+diff --git a/plan/libs/models/kptresourcemodel.cpp b/plan/libs/models/kptresourcemodel.cpp
+index 81f3493..23242df 100644
+--- a/plan/libs/models/kptresourcemodel.cpp
++++ b/plan/libs/models/kptresourcemodel.cpp
+@@ -599,6 +599,7 @@ void ResourceItemModel::slotLayoutChanged()
+ void ResourceItemModel::setProject( Project *project )
+ {
+ if ( m_project ) {
++ disconnect(m_project, SIGNAL(aboutToBeDeleted()), this, SLOT(projectDeleted()));
+ disconnect( m_project, SIGNAL(localeChanged()), this, SLOT(slotLayoutChanged()) );
+ disconnect( m_project, SIGNAL(resourceChanged(Resource*)), this, SLOT(slotResourceChanged(Resource*)) );
+ disconnect( m_project, SIGNAL(resourceGroupChanged(ResourceGroup*)), this, SLOT(slotResourceGroupChanged(ResourceGroup*)) );
+@@ -623,6 +624,7 @@ void ResourceItemModel::setProject( Project *project )
+ }
+ m_project = project;
+ if ( m_project ) {
++ connect(m_project, SIGNAL(aboutToBeDeleted()), this, SLOT(projectDeleted()));
+ connect( m_project, SIGNAL(localeChanged()), this, SLOT(slotLayoutChanged()) );
+ connect( m_project, SIGNAL(resourceChanged(Resource*)), this, SLOT(slotResourceChanged(Resource*)) );
+ connect( m_project, SIGNAL(resourceGroupChanged(ResourceGroup*)), this, SLOT(slotResourceGroupChanged(ResourceGroup*)) );
+@@ -711,7 +713,7 @@ QModelIndex ResourceItemModel::parent( const QModelIndex &index ) const
+ }
+ //kDebug(planDbg())<<index.internalPointer()<<":"<<index.row()<<","<<index.column();
+
+- Resource *r = qobject_cast<Resource*>( object( index ) );
++ Resource *r = resource( index );
+ if ( r && r->parentGroup() ) {
+ // only resources have parent
+ int row = m_project->indexOf( r->parentGroup() );
+@@ -732,8 +734,7 @@ QModelIndex ResourceItemModel::index( int row, int column, const QModelIndex &pa
+ }
+ return QModelIndex();
+ }
+- QObject *p = object( parent );
+- ResourceGroup *g = qobject_cast<ResourceGroup*>( p );
++ ResourceGroup *g = group( parent );
+ if ( g ) {
+ if ( row < g->numResources() ) {
+ return createIndex( row, column, g->resourceAt( row ) );
+@@ -782,8 +783,7 @@ int ResourceItemModel::rowCount( const QModelIndex &parent ) const
+ if ( ! parent.isValid() ) {
+ return m_project->numResourceGroups();
+ }
+- QObject *p = object( parent );
+- ResourceGroup *g = qobject_cast<ResourceGroup*>( p );
++ ResourceGroup *g = group( parent );
+ if ( g ) {
+ return g->numResources();
+ }
+@@ -1148,6 +1148,8 @@ QObject *ResourceItemModel::object( const QModelIndex &index ) const
+ {
+ QObject *o = 0;
+ if ( index.isValid() ) {
++ Q_ASSERT( m_project );
++ Q_ASSERT(m_project->resourceGroups().contains(static_cast<ResourceGroup*>(index.internalPointer())) || m_project->resourceList().contains(static_cast<Resource*>(index.internalPointer())));
+ o = static_cast<QObject*>( index.internalPointer() );
+ Q_ASSERT( o );
+ }
+diff --git a/plan/libs/models/kptschedulemodel.cpp b/plan/libs/models/kptschedulemodel.cpp
+index e3ce298..4d47ee5 100644
+--- a/plan/libs/models/kptschedulemodel.cpp
++++ b/plan/libs/models/kptschedulemodel.cpp
+@@ -171,6 +171,8 @@ void ScheduleItemModel::slotScheduleRemoved( const MainSchedule * )
+ void ScheduleItemModel::setProject( Project *project )
+ {
+ if ( m_project ) {
++ disconnect(m_project, SIGNAL(aboutToBeDeleted()), this, SLOT(projectDeleted()));
++
+ disconnect( m_project, SIGNAL(scheduleManagerChanged(ScheduleManager*)), this, SLOT(slotManagerChanged(ScheduleManager*)) );
+
+ disconnect( m_project, SIGNAL(scheduleManagerToBeAdded(const ScheduleManager*,int)), this, SLOT(slotScheduleManagerToBeInserted(const ScheduleManager*,int)) );
+@@ -197,6 +199,8 @@ void ScheduleItemModel::setProject( Project *project )
+ }
+ m_project = project;
+ if ( m_project ) {
++ connect(m_project, SIGNAL(aboutToBeDeleted()), this, SLOT(projectDeleted()));
++
+ connect( m_project, SIGNAL(scheduleManagerChanged(ScheduleManager*)), this, SLOT(slotManagerChanged(ScheduleManager*)) );
+
+ connect( m_project, SIGNAL(scheduleManagerToBeAdded(const ScheduleManager*,int)), this, SLOT(slotScheduleManagerToBeInserted(const ScheduleManager*,int)) );
+@@ -1074,10 +1078,17 @@ void ScheduleLogItemModel::slotScheduleRemoved( const MainSchedule *sch )
+ kDebug(planDbg())<<m_schedule<<sch;
+ }
+
++void ScheduleLogItemModel::projectDeleted()
++{
++ setProject(0);
++}
++
+ void ScheduleLogItemModel::setProject( Project *project )
+ {
+ kDebug(planDbg())<<m_project<<"->"<<project;
+ if ( m_project ) {
++ disconnect(m_project, SIGNAL(aboutToBeDeleted()), this, SLOT(projectDeleted()));
++
+ disconnect( m_project, SIGNAL(scheduleManagerChanged(ScheduleManager*)), this, SLOT(slotManagerChanged(ScheduleManager*)) );
+
+ disconnect( m_project, SIGNAL(scheduleManagerToBeRemoved(const ScheduleManager*)), this, SLOT(slotScheduleManagerToBeRemoved(const ScheduleManager*)) );
+@@ -1096,6 +1107,8 @@ void ScheduleLogItemModel::setProject( Project *project )
+ }
+ m_project = project;
+ if ( m_project ) {
++ connect(m_project, SIGNAL(aboutToBeDeleted()), this, SLOT(projectDeleted()));
++
+ connect( m_project, SIGNAL(scheduleManagerChanged(ScheduleManager*)), this, SLOT(slotManagerChanged(ScheduleManager*)) );
+
+ connect( m_project, SIGNAL(scheduleManagerToBeRemoved(const ScheduleManager*)), this, SLOT(slotScheduleManagerToBeRemoved(const ScheduleManager*)) );
+diff --git a/plan/libs/models/kptschedulemodel.h b/plan/libs/models/kptschedulemodel.h
+index c09d8fb..acc75b4 100644
+--- a/plan/libs/models/kptschedulemodel.h
++++ b/plan/libs/models/kptschedulemodel.h
+@@ -203,6 +203,8 @@ protected Q_SLOTS:
+
+ void slotLogInserted( MainSchedule*, int firstrow, int lastrow );
+
++ void projectDeleted();
++
+ protected:
+ void addLogEntry( const Schedule::Log &log, int row );
+
+diff --git a/plan/libs/models/kpttaskstatusmodel.cpp b/plan/libs/models/kpttaskstatusmodel.cpp
+index e0693b8..9fb3b37 100644
+--- a/plan/libs/models/kpttaskstatusmodel.cpp
++++ b/plan/libs/models/kpttaskstatusmodel.cpp
+@@ -126,6 +126,7 @@ void TaskStatusItemModel::setProject( Project *project )
+ {
+ clear();
+ if ( m_project ) {
++ disconnect(m_project, SIGNAL(aboutToBeDeleted()), this, SLOT(projectDeleted()));
+ disconnect( m_project, SIGNAL(localeChanged()), this, SLOT(slotLayoutChanged()) );
+ disconnect( m_project, SIGNAL(wbsDefinitionChanged()), this, SLOT(slotWbsDefinitionChanged()) );
+ disconnect( m_project, SIGNAL(nodeChanged(Node*)), this, SLOT(slotNodeChanged(Node*)) );
+@@ -140,6 +141,7 @@ void TaskStatusItemModel::setProject( Project *project )
+ m_project = project;
+ m_nodemodel.setProject( project );
+ if ( project ) {
++ connect(m_project, SIGNAL(aboutToBeDeleted()), this, SLOT(projectDeleted()));
+ connect( m_project, SIGNAL(localeChanged()), this, SLOT(slotLayoutChanged()) );
+ connect( m_project, SIGNAL(wbsDefinitionChanged()), this, SLOT(slotWbsDefinitionChanged()) );
+ connect( m_project, SIGNAL(nodeChanged(Node*)), this, SLOT(slotNodeChanged(Node*)) );
+--
+2.7.4
+
diff --git a/source/kde/patch/calligra/0070-Plan-Guard-against-trying-to-move-a-task-into-the-sa.patch b/source/kde/patch/calligra/0070-Plan-Guard-against-trying-to-move-a-task-into-the-sa.patch
new file mode 100644
index 00000000..debb62b7
--- /dev/null
+++ b/source/kde/patch/calligra/0070-Plan-Guard-against-trying-to-move-a-task-into-the-sa.patch
@@ -0,0 +1,50 @@
+From a9134500e4e599ba316617941bcd04f640ed3999 Mon Sep 17 00:00:00 2001
+From: Dag Andersen <danders@get2net.dk>
+Date: Tue, 23 Aug 2016 13:30:13 +0200
+Subject: [PATCH 70/80] Plan: Guard against trying to move a task into the same
+ porition
+
+QAbstractItemModel cannot handle this and it causes a crash (later)
+---
+ plan/libs/kernel/kptproject.cpp | 4 ++++
+ plan/libs/models/kptnodeitemmodel.cpp | 9 +++++++++
+ 2 files changed, 13 insertions(+)
+
+diff --git a/plan/libs/kernel/kptproject.cpp b/plan/libs/kernel/kptproject.cpp
+index 451e897..fdf43bc 100644
+--- a/plan/libs/kernel/kptproject.cpp
++++ b/plan/libs/kernel/kptproject.cpp
+@@ -1565,6 +1565,10 @@ bool Project::moveTask( Node* node, Node *newParent, int newPos )
+ Node *oldParent = node->parentNode();
+ int oldPos = oldParent->indexOf( node );
+ int i = newPos < 0 ? newParent->numChildren() : newPos;
++ if ( oldParent == newParent && i == oldPos ) {
++ // no need to move to where it already is
++ return false;
++ }
+ int newRow = i;
+ if ( oldParent == newParent && newPos > oldPos ) {
+ ++newRow; // itemmodels wants new row *before* node is removed from old position
+diff --git a/plan/libs/models/kptnodeitemmodel.cpp b/plan/libs/models/kptnodeitemmodel.cpp
+index e66277f..5581f8f 100644
+--- a/plan/libs/models/kptnodeitemmodel.cpp
++++ b/plan/libs/models/kptnodeitemmodel.cpp
+@@ -4036,6 +4036,15 @@ bool NodeItemModel::dropMimeData( const QMimeData *data, Qt::DropAction action,
+ if ( pos >= 0 && n->parentNode() == par && par->indexOf( n ) < pos ) {
+ --pos;
+ }
++ if ( n->parentNode() == par ) {
++ // avoid drop into the same position, QAbstractItemModel does not like it
++ int crow = par->indexOf( n );
++ if ( ( ( pos == -1 ) && ( crow == par->numChildren() - 1 ) ) || ( pos == crow ) ) {
++ delete cmd;
++ cmd = 0;
++ continue;
++ }
++ }
+ cmd->addCommand( new NodeMoveCmd( m_project, n, par, pos ) );
+ offset++;
+ }
+--
+2.7.4
+
diff --git a/source/kde/patch/calligra/calligra-2.9.11-gcc6_arm.patch b/source/kde/patch/calligra/calligra-2.9.11-gcc6_arm.patch
new file mode 100644
index 00000000..2b1271c0
--- /dev/null
+++ b/source/kde/patch/calligra/calligra-2.9.11-gcc6_arm.patch
@@ -0,0 +1,12 @@
+diff -up calligra-2.9.11/libs/flake/KoSnapStrategy.cpp.gcc6_arm calligra-2.9.11/libs/flake/KoSnapStrategy.cpp
+--- calligra-2.9.11/libs/flake/KoSnapStrategy.cpp.gcc6_arm 2016-02-02 13:53:15.000000000 -0600
++++ calligra-2.9.11/libs/flake/KoSnapStrategy.cpp 2016-02-08 09:12:39.452896965 -0600
+@@ -181,7 +181,7 @@ bool ExtensionSnapStrategy::snap(const Q
+ Q_ASSERT(isfinite(maxSnapDistance));
+
+ const qreal maxDistance = maxSnapDistance * maxSnapDistance;
+- qreal minDistances[2] = { HUGE_VAL, HUGE_VAL };
++ qreal minDistances[2] = { (qreal)HUGE_VAL, (qreal)HUGE_VAL };
+
+ QPointF snappedPoints[2] = { mousePosition, mousePosition };
+ QPointF startPoints[2];