GNOME Bugzilla – Bug 137964
Planner crashes when saving file.
Last modified: 2004-12-22 21:47:04 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 :(
Created attachment 25894 [details] Ids the file that crashes planner
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.
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
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.
Thanks, I just commited a variant of this. We might want to GError-ify these code paths later.
Philippe, do you know which version of planner the file was saved with?
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.
Do you mean that you erased them from the file with a text editor?
Yes, this is what I did, with text editor as the tasks would not let me unlink them.
This is related to the old broken scheduler, closing.