Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic SaveToStream problem (Read 3702 times)
jstraylor
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 50
Joined: Dec 28th, 2006
SaveToStream problem
Jun 28th, 2007 at 3:46pm
Print Post  
Good Day all,

I am having a problem with the SaveToStream method on the flowchart and thought that someone might have some insight.

What we are doing is creating a memory stream to hold a copy of the current flowchart and its objects while we display an older version of the same chart in the flowchart.  (We save the older version of the chart as a stream to the database, and restore it from the database - works like a charm).

The issue is that if we add a box node (haven't tried with arrow noded) to the current flowchart and try to save it again to the memory stream we get an ArgumentException errror.  This happens whether we reuse the previous stream, or create a new stream.  The error seems to be coming from deep inside the flowchart component as can be seen by the stack trace that follows the save code.

Order of operation -
Load a flowchart (from datatables, drawn completely in code).
Select a previous version of the chart from a menu.
Save the current (editable) chart to a memory stream.
Read the previous version from the database (varbinary, converted to a stream).
Display the previous version.
Restore the current version from the memory stream.
Add a box node to the current version.
Attempt to save the current version to the memory stream with fc.SaveToStream


[code]
m_CurrentMemoryStream.Position = 0

fc.SaveToStream(m_CurrentMemoryStream)

m_CurrentMemoryStream.Position = 0
[/code]

Get the following stack trace.
[code]
   at System.Drawing.Font.GetHeight(Graphics graphics)
   at System.Drawing.Font.get_SizeInPoints()
   at MindFusion.Diagramming.WinForms.PersistContext.SaveFont(Font font)
   at MindFusion.Diagramming.WinForms.ChartObject.SaveTo(BinaryWriter writer, PersistContext ctx)
   at MindFusion.Diagramming.WinForms.Node.SaveTo(BinaryWriter writer, PersistContext ctx)
   at MindFusion.Diagramming.WinForms.Box.SaveTo(BinaryWriter writer, PersistContext ctx)
   at MindFusion.Diagramming.WinForms.Box.xcdea37b6f24be9f2(BinaryWriter xbdfb620b7167944b, PersistContext x1022c74c62bcda5c)
   at MindFusion.Diagramming.WinForms.PersistContext.SaveObject(IPersists obj)
   at MindFusion.Diagramming.WinForms.PersistContext.WriteReferencedObjects()
   at MindFusion.Diagramming.WinForms.FlowChart.SaveToStream(Stream stream, Boolean clearDirty)
   at MindFusion.Diagramming.WinForms.FlowChart.SaveToStream(Stream stream)
   at JunoCommon.ucRFDSEdit.tscboRFDS_SelectedIndexChanged(Object sender, EventArgs e) in d:\My Documents\Visual Studio 2005\Projects\JunoClient\JunoCommon\UserControls\ucRFDSEdit.vb:line 2809
   [/code]
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: SaveToStream problem
Reply #1 - Jun 28th, 2007 at 4:10pm
Print Post  
Good day,

Apparently the Font.SizeInPoints property getter calls the Font.GetHeight(Graphics) method with some invalid Graphics object, though I don't know where it gets that Graphics from. What happens if you access the Box.Font.SizeInPoints property just after adding the box?

Stoyan
  
Back to top
 
IP Logged
 
jstraylor
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 50
Joined: Dec 28th, 2006
Re: SaveToStream problem
Reply #2 - Jun 28th, 2007 at 5:00pm
Print Post  
Checking the SizeInPoints property right after the add returns a 2.25.

Further testing -
ONLY adding box nodes causes the problem, arrows do not.
Deleting a node does NOT cause the problem.
Adding nodes BEFORE the first save to a stream does NOT cause the problem.

It seems to be related ONLY to adding a box node to a chart that was restored from a stream and then had another box node placed on it (code, from a drag & drop operation, NOT drawn by the user) before we try to save to a stream again.

If you need a file or two, or the box add code from the drag and drop event please let me know.

Jeff
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: SaveToStream problem
Reply #3 - Jun 28th, 2007 at 6:03pm
Print Post  
What happens if you set the box.Font to a new Font instance after drag-and-drop?

Stoyan
  
Back to top
 
IP Logged
 
jstraylor
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 50
Joined: Dec 28th, 2006
Re: SaveToStream problem
Reply #4 - Jun 29th, 2007 at 10:32am
Print Post  
Setting the font in my box creation routine (drag and drop) does NOT help the problem.

I've been trying to determine if it is something that I am doing wrong, but I can't seem to find anything strange.  I even inserted code to clear the flowchart before reloading from the stream and that does not help either.  (I didn't expect it to help, I assumed that the flowchart cleared itself when loading from a stream).

Any other thoughts??
  
Back to top
 
IP Logged
 
jstraylor
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 50
Joined: Dec 28th, 2006
Re: SaveToStream problem
Reply #5 - Jun 29th, 2007 at 10:34am
Print Post  
Another, possibly useful, bit of information --

We do a lot of additional graphics operations, such as loading images on top of the boxes and doing gradient shading of some of the boxes.  I will attempt to add a simpler box that does not contain those elements to see if we can eliminate the issue.

Jeff
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: SaveToStream problem
Reply #6 - Jun 29th, 2007 at 10:57am
Print Post  
Could you save the memory stream that you get at this point -

Quote:
Restore the current version from the memory stream.


into a file and email it to support@mindfusion.eu? If you use Tag objects from your custom type, you might have to clear them first, or otherwise we won't be able to load the diagram.

Thanks,
Stoyan
  
Back to top
 
IP Logged
 
jstraylor
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 50
Joined: Dec 28th, 2006
Re: SaveToStream problem
Reply #7 - Jun 29th, 2007 at 1:52pm
Print Post  
On its way.
  
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: SaveToStream problem
Reply #8 - Jul 3rd, 2007 at 12:17pm
Print Post  
I'm trying to reproduce this problem here, but to no avail so far. Can you also post the code you are using when creating the box?

Thank you,
Meppy
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint