VCL OS X 10.1 Compatibility

12/20/2001

Problem

The VCL porting work done on OOo for OS X was broken by the 10.1 upgrade from Apple. Although there are separate build issues with the 10.1 toolchain, one of the most unhappy problems was with the Aqua VCL porting work. The svdem application which exercesied basic GUI elements would happily segfault somewhere inside of the GUI frameworks of OS X, indicating that it wouldn't be possible to display a GUI at all from the OOo code without bug fixing.

The Source of the Segfaults

NSQuickDrawView. This evil little thing allows Cocoa to use Carbon QuickDraw calls for drawing. Unfortunately, for 10.0.x the behaviour of this class was undocumented, and for 10.1 it changed. There were two major problems: visible region changes, drawing out of the bounds of the port, and apparently invalid handles.

In 10.1, the clipRgn and visRgn of an instance of the NSQuickDrawView object are set differently as a fix for clipping bugs in 10.0.x. Instead of being bounded by the screen size (?) they are now bounded by the initial visible area of the veiw when the view is created (?). Unfortunately, in OOo the view is created before the window is visible. This was addressed by adding initialization code to lockFocus in the VCLView class which initializes the visRgn and the clipRgn of the qdPort to the bounds of the view. Thus, instead of drawing in a small rectangle in the upper left, drawing takes place in the entire window.

Another problem involves drawing outside of the bounds of an offscreen graphics world. This apparently was the cause of several crashes early on for some sal UI elements which create offscreen graphics worlds and draw into them (e.g. ListItem).

Finally, the pen pixMap variable of ports generated by the QDView object seems to be unstable. If it is saved and restored in BeginGraphics and EndGraphics another set of segfaults will occur in the UI frameworks.

What lesson does this teach us? NSQDView is evil, and Apple is evil for not documenting all of its limitations :) It can be patched, and when patched will run on 10.1.

The Diffs

The diffs are from the OO638B tag and affect only source within the vcl module. To apply, download the gzipped version, unzip it, cd into your vcl directory and execute patch -p0 < vcl.122001.unified.diff

click here to download gzipped unified diffs

click here to view some diffs in your browser

These diffs contain the changes needed to prevent crashes on 10.1 as well as some extra debugging checks for valid ports. When the debug build is made, each call to EndGraphics() will also automatically flush the buffer. This is very helpful when stepping through code to see the visual results immediately.

The Results

When the above diffs are applied, rebuild the vcl module and the svtools module. Then, when running svdem.app you should see screens simlar to the following. There are obviously still drawing bugs which occur, but now svdem actually displays something meaningful and interactive instead of segfaulting. Always a good setp. These screens are from a TiBook 400 running OS X 10.1.0:

Main svdem Window

The following is the main window displayed after svdem is launched

Date Pulldown

The reusult of clicking on the date pulldown in the main svdem winodw

svdem Calendar Window

You can get this window by clicking on the Calendar button. I dig the German.