Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Failure to create pattern bitmap with CM3

1 view
Skip to first unread message

Parzival Herzog

unread,
Mar 10, 2003, 9:05:05 PM3/10/03
to
I am testing out the Trestle and VBT sample programs with CM3 5.1.8,
under Windows 2000. Some of these programs , e.g. "Calculator"
work, but quit a few other crash. Al the ones I have investigated
do so while attempting to allocate a patterned brush.

Here is the traceback:

***
*** runtime error:
*** <*ASSERT*> failed.
*** file "..\src\winvbt\WinContext.m3", line 165
***

Stack trace:
FP PC Procedure
--------- --------- -------------------------------
0x4e6f88c 0x5118fc PushPixmap + 0x2e8 in ..\src\winvbt\WinContext.m3
0x4e6f94c 0x51c5dc PixmapCom + 0x714 in ..\src\winvbt\WinPaint.m3
0x4e6fda8 0x51ab33 PaintBatch + 0x1f3 in ..\src\winvbt\WinPaint.m3
0x4e6fe10 0x516675 PaintBatchVBT + 0xdd in ..\src\winvbt\WinTrestle.m3
0x4e6fe50 0x515515 WindowProc + 0x3f5 in ..\src\winvbt\WinTrestle.m3
0x4e6fe70 0x77e3a2b8 <???>
0x4e6fefc 0x77e145b1 <???>
0x4e6ff50 0x77e15b1d <???>
0x4e6ff88 0x374f5e RunThread + 0x106 in ..\src\thread\WIN32\ThreadWin32.m3
0x4e6ffb4 0x374def ThreadBase + 0x3a in ..\src\thread\WIN32\ThreadWin32.m3
......... ......... ... more frames ...


*** Note to Olaf: top of the list in what I would like to change is
1) No more hex offsets, I want source line numbers.
2) Get the entire traceback.
***

The problem code is reproduced below. Has anyone encountered this,
or have a fix, or know what's happening?

Related question: I seem to recall that CM3 had mapped checked runtime
errors to exceptions. Is this true? Where are these exceptions documented?

PROCEDURE PushPixmap (hdc : WinDef.HDC;
st : WinScreenType.T;
op : PaintPrivate.PaintOp;
pm : PaintPrivate.Pixmap;
delta: Point.T): T =
VAR
ctxt : T;
pst : WinScreenType.T;
color: WinDef.COLORREF;
brush: WinDef.HBRUSH;
oldOrg: WinDef.POINT;
status: WinDef.BOOL;
BEGIN
ctxt.hdc := hdc;

(* If the pixmap is solid, then we can treat the texture as a tint. *)
IF pm = WinScrnPixmap.SolidPixmap THEN
RETURN PushTint (hdc, st, op);
END;

WITH dom = WinScrnPixmap.PixmapDomain (st, pm) DO
IF NOT Rect.IsEmpty (dom) THEN
delta := Point.T {(delta.h + dom.west) MOD (dom.east - dom.west),
(delta.v + dom.north) MOD (dom.south - dom.north)};
IF st.depth = 24 THEN
INC (delta.h); (* John Karnak 21-Jul-1998 *)
END;
END;
END;

(* pm < 0 indicates that the pixmap does not belong to st,
but to st.bits, the monochrome screentype associated with st. *)
IF pm < 0 THEN
pm := WinScrnPixmap.SolidPixmap - pm;
pst := st.bits;
ELSE
pst := st;
END;

IF op >= 0 AND st.optable # NIL AND op < NUMBER(st.optable^) AND
pst.pmtable # NIL AND pm < NUMBER (pst.pmtable^) THEN
WITH tbl = st.optable[op] DO
ctxt.rop2 := WinGDI.SetROP2 (hdc, tbl.rop2);
<* ASSERT ctxt.rop2 # 0 *>
----- problem is here:
brush := WinGDI.CreatePatternBrush (pst.pmtable[pm].hbmp);
----- assertion fails:
<* ASSERT brush # NIL *>

status := WinGDI.SetBrushOrgEx(hdc, delta.h, delta.v, ADR(oldOrg));
<* ASSERT status = True *>

ctxt.brush := WinGDI.SelectObject (hdc, brush);
<* ASSERT ctxt.brush # NIL *>

(* In Windows, '0' pixels of the bitmap in the pattern brush are
drawn in the current text color, so the text color should be
"tbl.bop.col". '1' pixels are drawn in the current background color,
so this color should be "tbl.fop.col". Counterintuive? Well, after
all, this is Windows! *)
color := WinGDI.SetTextColor (hdc, tbl.bop.col);
<* ASSERT color # WinGDI.CLR_INVALID *>
color := WinGDI.SetBkColor (hdc, tbl.fop.col);
<* ASSERT color # WinGDI.CLR_INVALID *>
END;
ELSE
ctxt.rop2 := WinGDI.SetROP2 (hdc, WinGDI.R2_NOP);
<* ASSERT ctxt.rop2 # 0 *>
END;
RETURN ctxt;
END PushPixmap;


0 new messages