Page 1 of 1

Why is this script crashing FreeCAD?

Posted: Fri May 20, 2022 1:36 am
by KAKM
When I run the line

Code: Select all

recorder=TutorialUi.make_recorder()
FreeCAD immediately crashes. This is the only line in the script I modified between being able to run that command with an error and it crashing when I run that command:

Code: Select all

ActionRecorder.handle_filter(event,self.newItem)
Any ideas why it's crashing?

The log file didn't seem helpful, and I don't have a clue how to make sense of the system-provided crash report, but they're attached just in case.

The relevant code:

Code: Select all

class ActionRecorder(QtCore.QObject):
    '''
    Records user inputs to put into steps of tutorial using Qt event filter
    '''
    class PassCommand(QtCore.QObject):
        newItem=QtCore.Signal(dict)
    
    def __init__(self, parent=None):
        super(ActionRecorder,self).__init__(parent)
        signal=self.PassCommand()
        self.newItem=signal.newItem
        signal.newItem.connect(CommandSelection.add_command)
        print("init instance")
        
    def __del__(self):
        print("delete instance")
        
    def eventFilter(self, obj, event):
        '''
        Listens in to user input, copies & sends on to be saved as steps
        The name of this function needs to be _exactly_ what it currently is
        and have as little functionality as possible or it won't work.
        '''
        events = [QtCore.QEvent.Shortcut,QtCore.QEvent.KeyPress,
                  QtCore.QEvent.KeyRelease,QtCore.QEvent.MouseButtonDblClick,
                  QtCore.QEvent.MouseButtonPress,QtCore.QEvent.MouseButtonRelease,
                  ]
        if event.type() in events:
            #Keeping eventFilter lightweight
            ActionRecorder.handle_filter(event,self.newItem)
        #keeps events from getting eaten by filter
        return False
        
def make_recorder():
    recorder=ActionRecorder()
    QtWidgets.QApplication.instance().installEventFilter(recorder)
    print("Recorder installed")
    return recorder
FreeCAD Info:
OS: macOS 10.15
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.24291 (Git)
Build type: Release
Branch: (HEAD detached at 0.19.2)
Hash: 7b5e18a0759de778b74d3a5c17eba9cb815035ac
Python version: 3.8.8
Qt version: 5.12.9
Coin version: 4.0.0
OCC version: 7.4.0
Locale: English/United States (en_US)

Re: Why is this script crashing FreeCAD?

Posted: Fri May 20, 2022 5:22 am
by chrisb
I can't help with the matter, but would recommend to retry with the latest 0.20 version, because bugs and crashes will no longer be removed from 0.19.

Re: Why is this script crashing FreeCAD?

Posted: Fri May 20, 2022 8:09 pm
by KAKM
I was under the impression that 0.20 hadn't actually been released yet. I tried updating via homebrew, but that only takes me to 0.19.3. How do I install 0.20 in a way that plays nicely with my homebrew?

Re: Why is this script crashing FreeCAD?

Posted: Fri May 20, 2022 10:28 pm
by chrisb
KAKM wrote: Fri May 20, 2022 8:09 pm How do I install 0.20 in a way that plays nicely with my homebrew?
I'm not familiar with the homebrew stuff. I use the precompiled FreeCAD from the weekly builds.

Re: Why is this script crashing FreeCAD?

Posted: Sat May 21, 2022 12:20 pm
by Jee-Bee
There is a FreeCAD-pre cask available but this one conflicts with the default one(according to: https://formulae.brew.sh/cask/freecad#default).
What you can try is: https://github.com/FreeCAD/homebrew-freecad but i don't know what versions are available ...

Re: Why is this script crashing FreeCAD?

Posted: Mon May 23, 2022 1:38 am
by KAKM
Downloading the .dmg from the homebrew page seems to have worked. I'll find out later if that caused any issues.

0.20 did indeed fix the crashing.