Opened 6 years ago

Closed 6 years ago

#58390 closed defect (fixed)

qt53-qtbase 32bit: error: no viable conversion from 'CGRect' to 'NSRect'

Reported by: kencu (Ken) Owned by: kencu (Ken)
Priority: Normal Milestone:
Component: ports Version:
Keywords: Cc: MarcusCalhoun-Lopez (Marcus Calhoun-Lopez), michaelld (Michael Dickens)
Port: qt53-qtbase

Description

qt53-qtbase port fails to build on 10.6.8 in 32bit mode. Perhaps all 32bit builds will fail - I haven't tried to build it +universal yet or 32bit on any other systems.

This is the error:

styles/qmacstyle_mac.mm:3672:87: error: no viable conversion from 'CGRect' to 'NSRect' (aka '_NSRect')
                    pushButtonFocusRingPath = [NSBezierPath bezierPathWithRoundedRect:focusRect xRadius:4 yRadius:4];
                                                                                      ^~~~~~~~~

It seemed to be an inconsistency between the 64 bit build (which succeeds), and the 32 bit build with respect to the definitions in the Foundation classes.

I first fixed it with a simple patch:

--- ./src/widgets/styles/qmacstyle_mac.mm.orig	2019-04-25 14:12:12.000000000 -0700
+++ ./src/widgets/styles/qmacstyle_mac.mm	2019-04-25 14:17:29.000000000 -0700
@@ -3667,9 +3667,9 @@
 
                 NSBezierPath *pushButtonFocusRingPath;
                 if (bdi.kind == kThemeBevelButton)
-                    pushButtonFocusRingPath = [NSBezierPath bezierPathWithRect:focusRect];
+                    pushButtonFocusRingPath = [NSBezierPath bezierPathWithRect:NSRectFromCGRect(focusRect)];
                 else
-                    pushButtonFocusRingPath = [NSBezierPath bezierPathWithRoundedRect:focusRect xRadius:4 yRadius:4];
+                    pushButtonFocusRingPath = [NSBezierPath bezierPathWithRoundedRect:NSRectFromCGRect(focusRect) xRadius:4 yRadius:4];
                 qt_drawFocusRingOnPath(cg, pushButtonFocusRingPath);
             }

which does work, but this just seems like an odd thing to have to do, and in the end, most likely the wrong approach.

Looking around, 32 bit builds of qt and other software have been having issues like this for a long time, eg this fix from michael from many years ago for qt4 34902, and many other similar references out there:

  1. <https://stackoverflow.com/questions/3538347/how-come-nsrect-and-cgrect-are-incompatible-types>
  2. <https://bugs.webkit.org/show_bug.cgi?id=93397>
  3. <https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/Cocoa64BitGuide/64BitChangesCocoa/64BitChangesCocoa.html>

It looks like what we really want to do to fix 32bit builds of qt is to define -DNS_BUILD_32_LIKE_64 everywhere.

In fact, thinking about it, AFAICT, that means everywhere that qt builds. i.e. it should be embedded in the mkspecs for all 32 bit builds, and used for everything that builds 32bit against 32 bit qt, otherwise there will be trouble.

I haven't really thought about +universal builds yet -- but it would seem that they need it too...

Does this seem like the right approach?

Change History (1)

comment:1 Changed 6 years ago by ken-cunningham-webuse

Resolution: fixed
Status: assignedclosed

In 55f9ca7ab743910988d3c31de22d35cc7fe903cf/macports-ports (master):

qt53-qtbase: fix 32bit build

build with 64 bit compatible structures even when building 32 bit
this is how qt53 is written
placed in clang-mac.conf so this will be available for +universal as well
this does not change 64bit bit builds, so no revbump required

closes: #58390

Note: See TracTickets for help on using tickets.