View Issue Details

IDProjectCategoryView StatusLast Update
0023254LazarusWidgetsetpublic2012-11-01 13:07
ReporterJonas MaebeAssigned ToMaxim Ganetsky 
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
PlatformDarwinOSMac OS XOS Version10.6.8
Product Version1.1 (SVN)Product Build38335 
Target VersionFixed in Version1.1 (SVN) 
Summary0023254: Correct some typing issues for upcoming FPC 2.7.1 trunk commit
DescriptionThe univint interfaces (MacOSAll) in FPC trunk will soon be updated. The primary change is that the headers were updated to the Mac OS X 10.8 SDK, but in addition a number of types that used to be simply pointers to longint have been changed to be pointers to different opaque records. As a result, the compiler will now complain when such types are mixed.

I've attached a patch to fix these issues in Lazarus. Regarding the HIObject/ControlRef, see http://lists.apple.com/archives/carbon-dev/2007/Jan/msg00665.html (on short: it's completely safe to cast those types to each other, but they are different and also in C require typecasts).

There is one "major" change, in carbonobject.inc:

- Target := GetWindowEventTarget(Widget.Widget)
+ Target := GetWindowEventTarget(TCarbonWindow(Widget).Window)

I think the original code was wrong: GetWindowEventTarget needs a WindowRef, and as far as I can tell the windowref of a TCarbonWindow is stored in its fwindowref field, which is accessible via its Window property. But Maybe I'm wrong and the parameter has to be changed into WindowRef(Widget.Widget) instead.
TagsNo tags attached.
Fixed in Revision39214
LazTarget-
WidgetsetCarbon
Attached Files
  • carbontypes.patch (3,358 bytes)
    Index: lcl/interfaces/carbon/carbonwscontrols.pp
    ===================================================================
    --- lcl/interfaces/carbon/carbonwscontrols.pp	(revision 38335)
    +++ lcl/interfaces/carbon/carbonwscontrols.pp	(working copy)
    @@ -138,7 +138,7 @@
        (AObject.OwnerControl.GetAccessibleObject() = AObject) then
       begin
         lControlHandle := TCarbonControl(TWinControl(AObject.OwnerControl).Handle);
    -    AHIObject := lControlHandle.Widget;
    +    AHIObject := HIObjectRef(lControlHandle.Widget);
         AID64 := 0;
       end
       else
    @@ -147,7 +147,7 @@
         // If this is an internal sub-element, then simply represent it with the
         // memory address of the object
         AID64 := UInt64(PtrInt(AObject));
    -    AHIObject := lControlHandle.Widget;
    +    AHIObject := HIObjectRef(lControlHandle.Widget);
       end;
     end;
     
    Index: lcl/interfaces/carbon/carbonclipboard.pp
    ===================================================================
    --- lcl/interfaces/carbon/carbonclipboard.pp	(revision 38335)
    +++ lcl/interfaces/carbon/carbonclipboard.pp	(working copy)
    @@ -124,7 +124,7 @@
     
     function GetImageFromPasteboard(Pasteboard: PasteboardRef; ID: PasteboardItemID; UTI: CFStringRef): CGImageRef;
     var
    -  data  : CGImageRef;
    +  data  : CFDataRef;
       prov  : CGImageSourceRef;
     begin
       PasteboardCopyItemFlavorData(PasteBoard, ID, UTI, Data{%H-});
    Index: lcl/interfaces/carbon/carbonobject.inc
    ===================================================================
    --- lcl/interfaces/carbon/carbonobject.inc	(revision 38335)
    +++ lcl/interfaces/carbon/carbonobject.inc	(working copy)
    @@ -1515,7 +1515,7 @@
         Target := GetControlEventTarget(Widget.Widget)
       else
       if Widget is TCarbonWindow then
    -    Target := GetWindowEventTarget(Widget.Widget)
    +    Target := GetWindowEventTarget(TCarbonWindow(Widget).Window)
       else
         Exit;
     
    Index: lcl/interfaces/carbon/carboncalendarview.pas
    ===================================================================
    --- lcl/interfaces/carbon/carboncalendarview.pas	(revision 38335)
    +++ lcl/interfaces/carbon/carboncalendarview.pas	(working copy)
    @@ -1004,7 +1004,7 @@
         Result := SetEventParameter( event, EventParamNamePtr(BounName)^, typeQDRectangle,	sizeof( Rect ), @inBounds );
         if Result <> noErr then Exit;
     
    -    Result := HIObjectCreate( kCalendarViewClassID, event, outControl );
    +    Result := HIObjectCreate( kCalendarViewClassID, event, HIObjectRef(outControl) );
         if Result <> noErr then Exit;
     
         // Get the content root
    @@ -1056,7 +1056,7 @@
     
     function isValidCalendarControl(Calendar: ControlRef): Boolean;
     begin
    -  Result := Assigned(Calendar) and HIObjectIsOfClass(Calendar, kCalendarViewClassID);
    +  Result := Assigned(Calendar) and HIObjectIsOfClass(HIObjectRef(Calendar), kCalendarViewClassID);
     end;
     
     function CalendarGetDate(Calendar: ControlRef; var Date: CFGregorianDate): Boolean;
    Index: lcl/interfaces/carbon/carbonproc.pp
    ===================================================================
    --- lcl/interfaces/carbon/carbonproc.pp	(revision 38335)
    +++ lcl/interfaces/carbon/carbonproc.pp	(working copy)
    @@ -667,7 +667,7 @@
       Result := nil;
     
       if OSError(
    -    HIObjectCreate(CustomControlClassID, nil, Result),
    +    HIObjectCreate(CustomControlClassID, nil, HIObjectRef(Result)),
         SName, 'HIObjectCreate') then Exit;
     
       Features := kHIViewFeatureAllowsSubviews;
    
    carbontypes.patch (3,358 bytes)

Activities

2012-10-31 23:00

 

carbontypes.patch (3,358 bytes)
Index: lcl/interfaces/carbon/carbonwscontrols.pp
===================================================================
--- lcl/interfaces/carbon/carbonwscontrols.pp	(revision 38335)
+++ lcl/interfaces/carbon/carbonwscontrols.pp	(working copy)
@@ -138,7 +138,7 @@
    (AObject.OwnerControl.GetAccessibleObject() = AObject) then
   begin
     lControlHandle := TCarbonControl(TWinControl(AObject.OwnerControl).Handle);
-    AHIObject := lControlHandle.Widget;
+    AHIObject := HIObjectRef(lControlHandle.Widget);
     AID64 := 0;
   end
   else
@@ -147,7 +147,7 @@
     // If this is an internal sub-element, then simply represent it with the
     // memory address of the object
     AID64 := UInt64(PtrInt(AObject));
-    AHIObject := lControlHandle.Widget;
+    AHIObject := HIObjectRef(lControlHandle.Widget);
   end;
 end;
 
Index: lcl/interfaces/carbon/carbonclipboard.pp
===================================================================
--- lcl/interfaces/carbon/carbonclipboard.pp	(revision 38335)
+++ lcl/interfaces/carbon/carbonclipboard.pp	(working copy)
@@ -124,7 +124,7 @@
 
 function GetImageFromPasteboard(Pasteboard: PasteboardRef; ID: PasteboardItemID; UTI: CFStringRef): CGImageRef;
 var
-  data  : CGImageRef;
+  data  : CFDataRef;
   prov  : CGImageSourceRef;
 begin
   PasteboardCopyItemFlavorData(PasteBoard, ID, UTI, Data{%H-});
Index: lcl/interfaces/carbon/carbonobject.inc
===================================================================
--- lcl/interfaces/carbon/carbonobject.inc	(revision 38335)
+++ lcl/interfaces/carbon/carbonobject.inc	(working copy)
@@ -1515,7 +1515,7 @@
     Target := GetControlEventTarget(Widget.Widget)
   else
   if Widget is TCarbonWindow then
-    Target := GetWindowEventTarget(Widget.Widget)
+    Target := GetWindowEventTarget(TCarbonWindow(Widget).Window)
   else
     Exit;
 
Index: lcl/interfaces/carbon/carboncalendarview.pas
===================================================================
--- lcl/interfaces/carbon/carboncalendarview.pas	(revision 38335)
+++ lcl/interfaces/carbon/carboncalendarview.pas	(working copy)
@@ -1004,7 +1004,7 @@
     Result := SetEventParameter( event, EventParamNamePtr(BounName)^, typeQDRectangle,	sizeof( Rect ), @inBounds );
     if Result <> noErr then Exit;
 
-    Result := HIObjectCreate( kCalendarViewClassID, event, outControl );
+    Result := HIObjectCreate( kCalendarViewClassID, event, HIObjectRef(outControl) );
     if Result <> noErr then Exit;
 
     // Get the content root
@@ -1056,7 +1056,7 @@
 
 function isValidCalendarControl(Calendar: ControlRef): Boolean;
 begin
-  Result := Assigned(Calendar) and HIObjectIsOfClass(Calendar, kCalendarViewClassID);
+  Result := Assigned(Calendar) and HIObjectIsOfClass(HIObjectRef(Calendar), kCalendarViewClassID);
 end;
 
 function CalendarGetDate(Calendar: ControlRef; var Date: CFGregorianDate): Boolean;
Index: lcl/interfaces/carbon/carbonproc.pp
===================================================================
--- lcl/interfaces/carbon/carbonproc.pp	(revision 38335)
+++ lcl/interfaces/carbon/carbonproc.pp	(working copy)
@@ -667,7 +667,7 @@
   Result := nil;
 
   if OSError(
-    HIObjectCreate(CustomControlClassID, nil, Result),
+    HIObjectCreate(CustomControlClassID, nil, HIObjectRef(Result)),
     SName, 'HIObjectCreate') then Exit;
 
   Features := kHIViewFeatureAllowsSubviews;
carbontypes.patch (3,358 bytes)

Maxim Ganetsky

2012-10-31 23:16

developer   ~0063587

Applied, thanks. Let's see if there will be complaints. ;)

Jonas Maebe

2012-11-01 13:07

reporter   ~0063604

Thanks, the changes have been committed to FPC trunk.

Issue History

Date Modified Username Field Change
2012-10-31 23:00 Jonas Maebe New Issue
2012-10-31 23:00 Jonas Maebe File Added: carbontypes.patch
2012-10-31 23:00 Jonas Maebe Widgetset => Carbon
2012-10-31 23:16 Maxim Ganetsky Fixed in Revision => 39214
2012-10-31 23:16 Maxim Ganetsky LazTarget => -
2012-10-31 23:16 Maxim Ganetsky Status new => resolved
2012-10-31 23:16 Maxim Ganetsky Fixed in Version => 1.1 (SVN)
2012-10-31 23:16 Maxim Ganetsky Resolution open => fixed
2012-10-31 23:16 Maxim Ganetsky Assigned To => Maxim Ganetsky
2012-10-31 23:16 Maxim Ganetsky Note Added: 0063587
2012-11-01 13:07 Jonas Maebe Status resolved => closed
2012-11-01 13:07 Jonas Maebe Note Added: 0063604