Sorry to send all these grumpy mails ...

If I use the original construct for MathedIter::GetInset I get the following
very wrong result for p in MathParInset::Metrics:


(gdb) run
Starting program: /usr/src/lyx/lyx-1_0_x/src/lyx

Breakpoint 1, MathParInset::Metrics (this=0x12045d3c0) at math_draw.C:170
170               if (MathIsInset(cx)) {
(gdb) list
165                 mathed_string_height(data.FCode(), size, s, ls, asc, des);
166                 if (asc > ascent) ascent = asc;
167                 if (des > descent) descent = des;
168                 limits = false;
169             } else
170               if (MathIsInset(cx)) {
171                   MathedInset *p = data.GetInset();
172                   p->SetStyle(size);
173                   p->Metrics();
174                   if (cx==LM_TC_UP) {
(gdb) print cx
$1 = 8 '\b'
(gdb) next
171                   MathedInset *p = data.GetInset();
(gdb) print data
$2 = {<MathedIter> = {flags = 0, fcode = -1, pos = 0, row = 0, col = 0,
    ncols = 1, array = 0x12045cef0, stck = {fcode = 14928, x = 1,
      y = 536856360, pos = 1, row = 0, col = 0},
    _vptr. = 0x120231df8 <MathedXIter virtual table>}, size = 1, x = 0, y = 0,
  p = 0x12045d3c0, sx = 0, sw = 0, limits = false, s_type = 0, crow = 0x0}
(gdb) next
172                   p->SetStyle(size);
(gdb) print p
$3 = (class MathedInset *) 0x10
                           ^^^^
See here ? Of cours we crash when calling a member function of this "object" at
address 0x10 :-(

(gdb) cont
Continuing.

Program received signal SIGSEGV, Segmentation fault.
0x12010a50c in MathParInset::Metrics (this=0x12045d3c0) at math_draw.C:172
172                   p->SetStyle(size);


If I do the same with the reinterpret_cast alternative I sent before, I get

(gdb) print data
$2 = {<MathedIter> = {flags = 0, fcode = -1, pos = 0, row = 0, col = 0, ncols = 1, 
array = 0x12045cde0, stck = {fcode = 14864, x = 1,
      y = 536856344, pos = 1, row = 0, col = 0}, _vptr. = 0x120231db8 <MathedXIter 
virtual table>}, size = 1, x = 0, y = 0,
  p = 0x12045d2b0, sx = 0, sw = 0, limits = false, s_type = 0, crow = 0x0}
(gdb) next
172                   p->SetStyle(size);
(gdb) print p
$3 = (class MathedInset *) 0x12045cea1

Almost correct copy :-?

Greetings,
Jochen
-----------------------------------------------------------------------
  Jochen K"upper

  Heinrich-Heine-Universit"at D"usseldorf   [EMAIL PROTECTED]
  Institut f"ur Physikalische Chemie I
  Universit"atsstr. 1, Geb 26.43 Raum 02.29    phone ++49-211-8113681
  40225 D"usseldorf                            fax   ++49-211-8115195
  Germany             http://www-public.rz.uni-duesseldorf.de/~jochen
-----------------------------------------------------------------------

Reply via email to