Crash in ModelText

88 views
Skip to first unread message

Frode Nilsen

unread,
Nov 9, 2010, 9:16:01 AM11/9/10
to mode...@googlegroups.com
Hi,

I am currently testing your ModelText component, and "instantly" hit som
problems.

In the Form_Show event have this code:

tooledControl1.addTools();

tooledControl1.modelEdit.newDocument();


tooledControl1.modelEdit.domDocument.setTestIsReadonly(ReadOnly);

where tooledControl1 is an ModelText.ModelEditControl.TooledControl.

The ReadOnly method is like this:
private bool ReadOnly(ModelText.ModelDom.Nodes.IDomNode node)
{
if( node.nodeName == "ol" )
return false;
return true;
}


* the newDocument() method takes "forever"
* the component faults with an "Object reference not set to an instance
of an object"

Using VS 2101.

Any explanation?

sincerely
Frode Nilsen

Christopher Wells

unread,
Nov 9, 2010, 11:13:26 AM11/9/10
to ModelText
Hi Frode,


> the newDocument() method takes "forever"

I suspect that it's nearly instantaneous, but that what takes time is
the "Object reference not set to an instance of an object" exception
being thrown almost immediately afterwards: perhaps that's launching a
debugger, trying to load symbols etc.


> the component faults with an "Object reference not set to an instance of an object"

That's interesting.

Look at the definition of your ReadOnly predicate: you're saying that
every element is read-only unless it's a <ol> element.

A new/empty document is like <html><body><p></p></body></html>.

According to the ReadOnly predicate which you installed, all of these
elements are read-only.

The behaviour/effect of this predicate is described at
http://www.modeltext.com/html/apis/html/6d6425a8-2ea4-cad9-9af0-437b5f41af66.htm

When the predicate is true, theen the control tries to move the
insertion cursor until it's outside the read-only section.

With your predicate installed, the whole document is read-only: so the
control keep trying moves the cursor until there's an exception
(moving the cursor beyong the end of the document).

I can add a new line of code to avoid the exception: the control tries
to move the cursor, but stops trying when it reaches the edge of the
document.

If I do that, then the cursor eventually remains positioned inside you
entirely read-only document.

Any attempt to edit the document (e.g. by pressing a key like 'a' or
'b') would then result in a ...

throw new
DomException(DomException.Code.NO_MODIFICATION_ALLOWED_ERR);

... wich may be not what you want either.

What behaviour exactly are you trying to get by using the
setTestIsReadonly functionality?

The use case for which I developed it is when the user being given an
existing document or document template, some elements of which should
be editable and some elements not.


Regards,
Christopher.

Christopher Wells

unread,
Nov 11, 2010, 8:33:26 AM11/11/10
to ModelText
There's a new release (on the web site) which fixes both these
problems:

* Delay on opening a document, when the application is built for .NET
Framework 4
* Exception on opening the document, when the application-installed
'read-only' filter specifies that none of the document can be edited.

Regards,
Christopher.


On Nov 9, 5:13 pm, Christopher Wells <cwel...@gmail.com> wrote:
> Hi Frode,
>
> > the newDocument() method takes "forever"
>
> I suspect that it's nearly instantaneous, but that what takes time is
> the "Object reference not set to an instance of an object" exception
> being thrown almost immediately afterwards: perhaps that's launching a
> debugger, trying to load symbols etc.
>
> > the component faults with an "Object reference not set to an instance of an object"
>
> That's interesting.
>
> Look at the definition of your ReadOnly predicate: you're saying that
> every element is read-only unless it's a <ol> element.
>
> A new/empty document is like <html><body><p></p></body></html>.
>
> According to the ReadOnly predicate which you installed, all of these
> elements are read-only.
>
> The behaviour/effect of this predicate is described athttp://www.modeltext.com/html/apis/html/6d6425a8-2ea4-cad9-9af0-437b5...
> > Frode Nilsen- Hide quoted text -
>
> - Show quoted text -
Reply all
Reply to author
Forward
0 new messages