32/64 bit issue with call aPanel.beginSheetWithPrintInfo_modalForWindow_delegate_didEndSelector_contextInfo_

Issue #192 closed
Marc Van Olmen
created an issue

just converted my app for the first time to 64-bit.

And saw this issue with contextInfo only being 32-bit value:

# We must init a NSPrintPanel() so that we can embed an AccessoryView

aPanel = printOperation.printPanel().init()
aPanel.setOptions_(
            AppKit.NSPrintPanelShowsCopies |
            AppKit.NSPrintPanelShowsPageRange |
            AppKit.NSPrintPanelShowsPreview)


aPanel.beginSheetWithPrintInfo_modalForWindow_delegate_didEndSelector_contextInfo_(
                printOperation.printInfo(),
                senderWindow(),
                self._printHandler,
                'printPanelDidEnd:returnCode:contextInfo:',
                4294967296)   # this number 1 << 32 (so 1 bit over 32)

in the call back i print, that number thats I receive

def printPanelDidEnd_returnCode_contextInfo_(self, printPanel, returnCode, ctx):
        Foundation.NSLog(str(ctx))

# what gets printed.
2017-06-08 08:08:02.762770-0400 Checkout[38077:6099389] 0

Comments (6)

  1. Ronald Oussoren repo owner

    To verify: what's the result of NSPrintPanel.beginSheetWithPrintInfo_modalForWindow_delegate_didEndSelector_contextInfo_.__metadata__()?

    Is printPanelDidEnd_returnCode_contextInfo_ decorated with "@selectorFor(NSPrintPanal.beginSheetWithPrintInfo_modalForWindow_delegate_didEndSelector_contextInfo_)"?

    What's the result of printPanelDidEnd_returnCode_contextInfo_.__metadata__()?

  2. Marc Van Olmen reporter

    i added the @objc.selectorFor here the info:

    class TemplatePrintReturnHandler(Foundation.NSObject):
    
        def initWithTemplateObject_(self, templateObject):
            self = super(TemplatePrintReturnHandler, self).init()
            if self:
                self.templateObject = templateObject
            return self
    
        @objc.selectorFor(AppKit.NSPrintPanel.beginSheetWithPrintInfo_modalForWindow_delegate_didEndSelector_contextInfo_)
        def printPanelDidEnd_returnCode_contextInfo_(self, printPanel, returnCode, ctx):
            Foundation.NSLog(str(ctx))
            Foundation.NSLog(str(AppKit.NSPrintPanel.beginSheetWithPrintInfo_modalForWindow_delegate_didEndSelector_contextInfo_.__metadata__()))
            Foundation.NSLog(str(TemplatePrintReturnHandler.printPanelDidEnd_returnCode_contextInfo_.__metadata__()))
            templateObject = self.templateObject
            self.templateObject = None  # I will get deallocated.
            if hasattr(templateObject, 'printPanelDidEnd_returnCode_contextInfo_'):
                templateObject.printPanelDidEnd_returnCode_contextInfo_(
                    printPanel, returnCode, ctx)
    
        printPanelDidEnd_returnCode_contextInfo_ = \
            AppHelper.endSheetMethod(printPanelDidEnd_returnCode_contextInfo_)
    

    this is the output

    2017-06-11 10:14:39.499132-0400 Checkout[48982:7637010] 0
    2017-06-11 10:14:39.499281-0400 Checkout[48982:7637010] {'classmethod': False, 'hidden': False, 'retval': {'_template': True, 'type': 'v'}, 'arguments': ({'_template': True, 'type': '@'}, {'_template': True, 'type': ':'}, {'_template': True, 'type': '@'}, {'_template': True, 'type': '@'}, {'_template': True, 'type': '@'}, {'sel_of_type': 'v@:@q^v', 'type': ':'}, {'_template': True, 'null_accepted': True, 'type': '^v'})}
    2017-06-11 10:14:39.499357-0400 Checkout[48982:7637010] {'classmethod': False, 'hidden': False, 'retval': {'_template': True, 'type': 'v'}, 'arguments': ({'_template': True, 'type': '@'}, {'_template': True, 'type': ':'}, {'_template': True, 'type': '@'}, {'_template': True, 'type': 'i'}, {'_template': True, 'type': 'i'})}
    

    but when I remove the

        printPanelDidEnd_returnCode_contextInfo_ = \
            AppHelper.endSheetMethod(printPanelDidEnd_returnCode_contextInfo_)
    

    it works fine

    The output is the following

    2017-06-11 10:17:03.339558-0400 Checkout[49429:7641930] 4294967296
    2017-06-11 10:17:03.339697-0400 Checkout[49429:7641930] {'classmethod': False, 'hidden': False, 'retval': {'_template': True, 'type': 'v'}, 'arguments': ({'_template': True, 'type': '@'}, {'_template': True, 'type': ':'}, {'_template': True, 'type': '@'}, {'_template': True, 'type': '@'}, {'_template': True, 'type': '@'}, {'sel_of_type': 'v@:@q^v', 'type': ':'}, {'_template': True, 'null_accepted': True, 'type': '^v'})}
    2017-06-11 10:17:03.339784-0400 Checkout[49429:7641930] {'classmethod': False, 'hidden': False, 'retval': {'_template': True, 'type': 'v'}, 'arguments': ({'_template': True, 'type': '@'}, {'_template': True, 'type': ':'}, {'_template': True, 'type': '@'}, {'_template': True, 'type': 'q'}, {'null_accepted': True, 'type': '^v'})}
    
  3. Log in to comment