[Mono-list] TextIter, TextBuffer issue

Josef El-Rayes j.el-rayes@daemon.li
Sat, 22 Feb 2003 19:32:06 +0100


hi!

today i noticed some strange behaviour of TextIter.
I did not know that an TextIter object has to be created by
initialising it with the return value of the StartIter method from
TextBuffer.

i declared a TextIter variable with 'TextIter ti' and initialized it with
new. (TextIter ti = new TextIter();) The compiler did not complain so i
thought this is okay (to call it with standard constructor).

as i wanted to access the TextIter Property 'LineIndex' i got a
System.NullReferenceException. This was a bit confusing because i thought i
should get something like '0'. 
I thought maybe the field which is returned by get part of this property
doesnt get initalised so i did a 'ti.LineIndex = 0;' before i did the get
but that did not change anything.

after quite some time, with the help of Johannes and rapha in #mono, we
found out that TextBuffer can not be called with standard constructor
(although this is allowed by compiler) because TextIter needs some input
from TextBuffer (this is how it is implemented in Gtk+).

now i ask myself to question:

- is it possible to change constructors of TextIter so it is not possible to
call it with standardconstructor, but call it with an textbuffer object, so
it works correctly and not get such a strange behaviour.

- is it really necessary to have a seperate TextIter object when it is so
thightly bound with TextBuffer? Why cant this TextIter get integrated in the
TextBuffer class - which would also fix this mssbehaviour.

i have to admit i am new to gtk# and i know that it is not easy to get some
OOP into C code. i also want to add that i appreciate your work.

greets, josef
-- 
www: http://www.daemon.li
nic-hdl: JER1080312-NICAT
FreeBSD PortMaintainer 
Student of ComputerScience