Why is this script crashing FreeCAD?

Need help, or want to share a macro? Post here!
Post Reply
KAKM
Posts: 85
Joined: Tue May 04, 2021 12:17 am

Why is this script crashing FreeCAD?

Post 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)
Attachments
Apple Crash Report.txt
(139.8 KiB) Downloaded 9 times
FreeCAD.log
(16.42 KiB) Downloaded 9 times
chrisb
Veteran
Posts: 43422
Joined: Tue Mar 17, 2015 9:14 am

Re: Why is this script crashing FreeCAD?

Post 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.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
KAKM
Posts: 85
Joined: Tue May 04, 2021 12:17 am

Re: Why is this script crashing FreeCAD?

Post 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?
chrisb
Veteran
Posts: 43422
Joined: Tue Mar 17, 2015 9:14 am

Re: Why is this script crashing FreeCAD?

Post 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.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
Jee-Bee
Veteran
Posts: 2466
Joined: Tue Jun 16, 2015 10:32 am
Location: Netherlands

Re: Why is this script crashing FreeCAD?

Post 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 ...
KAKM
Posts: 85
Joined: Tue May 04, 2021 12:17 am

Re: Why is this script crashing FreeCAD?

Post 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.
Post Reply