After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 137964 - Planner crashes when saving file.
Planner crashes when saving file.
Status: RESOLVED FIXED
Product: planner
Classification: Other
Component: General
unspecified
Other Linux
: Normal normal
: ---
Assigned To: planner-maint
planner-maint
Depends on:
Blocks:
 
 
Reported: 2004-03-22 20:02 UTC by Philippe Bechamp
Modified: 2004-12-22 21:47 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Ids the file that crashes planner (16.35 KB, text/plain)
2004-03-22 20:03 UTC, Philippe Bechamp
  Details
Patch to mrp-old-xml.c to make it more graceful and not create null assignments. (1.79 KB, patch)
2004-03-26 23:54 UTC, Lincoln Phipps
none Details | Review

Description Philippe Bechamp 2004-03-22 20:02:50 UTC
Planner crashes when saving file. File was created with previous version of
Mr.Project and crashed then. It has succesfully been saved with Planner
since but has now started crashing planner too :(
Comment 1 Philippe Bechamp 2004-03-22 20:03:39 UTC
Created attachment 25894 [details]
Ids the file that crashes planner
Comment 2 Lincoln Phipps 2004-03-25 02:59:41 UTC
Which version of MrProject or Planner was it saved with ? The 
problem seems to be that you have 41 tasks defined but the 
planner (XML) file shows a resource assigment to task 
number 42 and 43. 

Could you remember if your project ever had 43 tasks and 
you deleted two of these (and the MrProject/Planner didn't delete 
the assignment) or should your project actually have 43 tasks 
and MrProject/Planner never saved the tasks 42 and 43 ? 

To try and repair your file do this: Edit it using any 
suitable/nice editor (its just XML) and remove the two lines 
towards the bottom of the file which are like this....

<allocation task-id="43" resource-id="2" units="100" />

and 

<allocation task-id="42" resource-id="2" units="100" />

Save this to a new file name. You'll now be able to open 
this in Planner 0.11 and Save OK.

Again if you can try and tell us if it was 43 tasks or 41
tasks and if you originally had 43 tasks or now then 
that'll help pin down what went wrong.

Merci.
Comment 3 Lincoln Phipps 2004-03-26 23:48:39 UTC
The following patch to mrp-old-xml.c does NOT fix the root cause of the original
corruption (which may NEVER be known) but it repairs the file because it makes
Planner adapt to the missing task in the assignment. This way at least the user
is able to use the file.

(I'll also attach the diff file.)

Index: libplanner/mrp-old-xml.c
===================================================================
RCS file: /cvs/gnome/planner/libplanner/mrp-old-xml.c,v
retrieving revision 1.3
diff -u -b -B -p -r1.3 mrp-old-xml.c
--- libplanner/mrp-old-xml.c	25 Mar 2004 23:19:20 -0000	1.3
+++ libplanner/mrp-old-xml.c	26 Mar 2004 23:45:04 -0000
@@ -469,6 +473,8 @@ old_xml_read_assignment (MrpParser *pars
 	MrpAssignment *assignment;
 	MrpTask       *task;
 	MrpResource   *resource;
+	gint          error = 0;
+	gchar         *errortext = "";
 
 	if (strcmp (tree->name, "allocation")){
 		/*g_warning ("Got %s, expected 'allocation'.", tree->name);*/
@@ -484,14 +490,22 @@ old_xml_read_assignment (MrpParser *pars
 	resource = g_hash_table_lookup (parser->resource_hash,
 					GINT_TO_POINTER (resource_id));
 	
+	if ((!task) && (!resource)) {
+		errortext = g_strdup_printf("No TASK ID %d or RESOURCE ID %d in this
assignment",task_id, resource_id);
+		error = 1;
+	} else {
 	if (!task) {
-		g_print ("NO TASK FROM HASH\n");
+			errortext = g_strdup_printf("No TASK ID %d could be found to assign the
RESOURCE ID %d",task_id, resource_id);
+			error = 1;
 	}
 
 	if (!resource) {
-		g_print ("NO RESOURCE FROM HASH\n");
+			errortext = g_strdup_printf ("No RESOURCE ID %d could be found to assign to
TASK ID %d", resource_id, task_id);
+			error = 1;
+		}
 	}
 
+	if (error == 0) {
 	assignment = g_object_new (MRP_TYPE_ASSIGNMENT,
 				   "task", task,
 				   "resource", resource,
@@ -497,8 +511,11 @@ old_xml_read_assignment (MrpParser *pars
 				   "resource", resource,
 				   "units", assigned_units,
 				   NULL);
-
 	parser->assignments = g_list_prepend (parser->assignments, assignment);
+	} else {
+		g_print ("Error in assignment. Possible corrupt file due to %s \n", errortext);
+		g_free (errortext);
+	}
 }
 
 static void
Comment 4 Lincoln Phipps 2004-03-26 23:54:11 UTC
Created attachment 25993 [details] [review]
Patch to mrp-old-xml.c to make it more graceful and not create null assignments.

Basically keeps going and does g_print() of the error. At least it won't
segfault on the user. This should patch fine, though hunks may be out by a few
lines.
Comment 5 Richard Hult 2004-03-29 15:28:33 UTC
Thanks, I just commited a variant of this.

We might want to GError-ify these code paths later.
Comment 6 Richard Hult 2004-04-04 23:37:12 UTC
Philippe, do you know which version of planner the file was saved with?
Comment 7 Philippe Bechamp 2004-04-06 17:29:57 UTC
Hi,

Yes, it was the version previous to this one, that is the last versionof Mr.
Project, which I believe was 0.10. (The one included by defaultin Fedora).

I'm sorry, I neglected to follow up on this bug :(I any case, I did try the
solution you proposed, manually changing thenumber of tasks in XML. It seems to
work although I haven't worked aloton the project file since. The exact previous
bug is no longer happening though.

In response to the following question :

Could you remember if your project ever had 43 tasks and you deleted two of
these (and the MrProject/Planner didn't delete the assignment) or should your
project actually have 43 tasks and MrProject/Planner never saved the tasks 42
and 43 ?

Answer: Yes, I believe this is exactly the case. A task or two in version 0.10
was crashing the app. so I manually did erase them. I didn't update the number
of tasks as suggested in the possible fixthough.

Thanks guys, sorry for not following up faster. If you need anything,let me know.
Comment 8 Richard Hult 2004-04-06 21:47:29 UTC
Do you mean that you erased them from the file with a text editor?

Comment 9 Philippe Bechamp 2004-04-06 22:12:16 UTC
Yes, this is what I did, with text editor as the tasks would not let me unlink 
them. 
Comment 10 Richard Hult 2004-10-01 19:10:56 UTC
This is related to the old broken scheduler, closing.