summaryrefslogtreecommitdiff
path: root/source/kde/patch/calligra/0068-Backport-Plan-Fix-task-module-load-and-save.patch
blob: ca6ae192489fa653f7c7e04fd139deaa787616d9 (plain)
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
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