Jump to content

(solved)propRules strange crash


Recommended Posts

Problem resolved

I recently created a customized version of my Vanishing Point effect for user 'Woodsy'. He noticed a strange crash which also applies to the published version.

The plugin runs and renders fine BUT crashes on re-opening, Crashing Pdn (both 3.5.11 and 4.0.16) - relevant part of the report below.
Now, If I disable the propRules, (particularly the one that greys out a DoubleVector control from a Boolean control), then no crashes.
The strange thing is that with the rules active it runs perfectly first time and only crashes when re-opened.


To recreate the problem run the current version of my Vanishing Point plugin, uncheck the 'Draw line 2' box, and render.No crash at this point.
Now, re-open the plugin and it crashes Pdn.

Is this a problem with my code or Pdn's?
Either way I guess I'll have to update my pack again :-(

 

Here is my PropertyCollection code. The idea is to grey out irrelevant controls if the 2nd line is not required... which it does.

Spoiler

 protected override PropertyCollection OnCreatePropertyCollection()
        {
            List<Property> props = new List<Property>();


            props.Add(new DoubleVectorProperty(PropertyNames.VanP, Pair.Create(0.0, -1.0), Pair.Create(-10.0, -10.0), Pair.Create(+10.0, +10.0)));
            props.Add(new BooleanProperty(PropertyNames.Linesthin, true));
            props.Add(new DoubleVectorProperty(PropertyNames.End1, Pair.Create(-1.0, 1.0), Pair.Create(-2.0, -2.0), Pair.Create(+2.0, +2.0)));
            props.Add(new Int32Property(PropertyNames.Line1W, 5, 1, 500));
            props.Add(new DoubleProperty(PropertyNames.E1ang, 0, -180, 180));
            props.Add(new BooleanProperty(PropertyNames.End2bool, true));
            props.Add(new DoubleVectorProperty(PropertyNames.End2, Pair.Create(1.0, 1.0), Pair.Create(-2.0, -2.0), Pair.Create(+2.0, +2.0)));
            props.Add(new Int32Property(PropertyNames.Line2W, 5, 1, 500));
            props.Add(new DoubleProperty(PropertyNames.E2ang, 0, -180, 180));
           // props.Add(new Int32Property(PropertyNames.LineCol, ColorBgra.ToOpaqueInt32(ColorBgra.FromBgra(EnvironmentParameters.PrimaryColor.B, EnvironmentParameters.PrimaryColor.G, EnvironmentParameters.PrimaryColor.R, 255)), 0, 0xffffff));
            props.Add(new Int32Property(PropertyNames.Opacity, 255, 0, 255));
            props.Add(new DoubleProperty(PropertyNames.Angle, 0, -180, +180));//new
            List<PropertyCollectionRule> propRules = new List<PropertyCollectionRule>();

            propRules.Add(new ReadOnlyBoundToBooleanRule(PropertyNames.End2, PropertyNames.End2bool, true));//NOTE:It is the double vector rules which seem to cause the crash
            propRules.Add(new ReadOnlyBoundToBooleanRule(PropertyNames.Line2W, PropertyNames.End2bool, true));
            propRules.Add(new ReadOnlyBoundToBooleanRule(PropertyNames.E2ang, PropertyNames.End2bool, true));
            propRules.Add(new ReadOnlyBoundToBooleanRule(PropertyNames.E1ang, PropertyNames.Linesthin, true));
            propRules.Add(new ReadOnlyBoundToBooleanRule(PropertyNames.E2ang, PropertyNames.Linesthin, true));
            return new PropertyCollection(props, propRules);// grey out End2 and Line2W if only End1 and grey out both end angles if using a simple line.

        }

 

Here is the crash

Spoiler

Exception details:

PaintDotNet.ReadOnlyException: This property is read only

   at PaintDotNet.PropertySystem.Property.VerifyNotReadOnly() in D:\src\pdn\src\Base\PropertySystem\Property.cs:line 387

   at PaintDotNet.PropertySystem.Property.SetValueCore(Object value) in D:\src\pdn\src\Base\PropertySystem\Property.cs:line 233

   at PaintDotNet.IndirectUI.DoubleVectorPanAndSliderPropertyControl.OnPanControlPositionChanged(Object sender, EventArgs e) in D:\src\pdn\src\PaintDotNet\IndirectUI\DoubleVectorPanAndSliderPropertyControl.cs:line 231

   at PaintDotNet.EventHandlerExtensions.Raise(EventHandler handler, Object sender, EventArgs e) in D:\src\pdn\src\Base\EventHandlerExtensions.cs:line 27

   at PaintDotNet.Controls.PanControl.set_Position(PointF value) in D:\src\pdn\src\PaintDotNet\Controls\PanControl.cs:line 150

   at PaintDotNet.IndirectUI.DoubleVectorPanAndSliderPropertyControl.OnPropertyValueChanged() in D:\src\pdn\src\PaintDotNet\IndirectUI\DoubleVectorPanAndSliderPropertyControl.cs:line 216

   at PaintDotNet.IndirectUI.PropertyControl.OnLoad(EventArgs e) in D:\src\pdn\src\Core\IndirectUI\PropertyControl.cs:line 114

   at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)

   at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)

   at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)

   at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)

   at System.Windows.Forms.Control.CreateControl()

   at System.Windows.Forms.Control.WmShowWindow(Message& m)

   at System.Windows.Forms.Control.WndProc(Message& m)

   at System.Windows.Forms.Form.WmShowWindow(Message& m)

   at PaintDotNet.PdnBaseForm.WndProc(Message& m) in D:\src\pdn\src\Core\PdnBaseForm.cs:line 1696

   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

 

 

Red ochre Plugin pack.............. Diabolical Drawings ................Real Paintings

 

PdnForumSig2.jpg

Link to comment
Share on other sites

I question the following code:

propRules.Add(new ReadOnlyBoundToBooleanRule(PropertyNames.E2ang, PropertyNames.End2bool, true));
. . .
propRules.Add(new ReadOnlyBoundToBooleanRule(PropertyNames.E2ang, PropertyNames.Linesthin, true));

I don't know if it might result in a crash, but I don't believe it does anything useful. I've experimented with that sort of thing, and concluded it uses something like the last checkbox that changed to control the enabling of E2ang, not some logical ANDing or ORing of End2bool and Linesthin. There doesn't seem to be any coordination between the read-only control of End2bool and Linesthin.

  • Upvote 1
Link to comment
Share on other sites

Many thanks for taking a look MJW.

 

My Mistake!:roll:
Somehow I have been working on an early prototype version of Vanishing Point in Visual studio.
The published version in my pack does NOT crash. (Phew!)... the published version uses much simpler rules.
Sorry for the panic. Now to try and find the correct source code and update Woodsy's version.

 

Red ochre Plugin pack.............. Diabolical Drawings ................Real Paintings

 

PdnForumSig2.jpg

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...