Having exceptions that cause loss of 3D rotation

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
freedman
Veteran
Posts: 3439
Joined: Thu Mar 22, 2018 3:02 am
Location: Washington State, USA

Having exceptions that cause loss of 3D rotation

Post by freedman »

I'm trying to use a slot to trigger my macro to do this "self.on_color_to_refacing()". It works for a while but then I get an Exception and my mouse won't rotate in the 3D. If I change mouse modes and back everything is fine once again, for a while. I don't know what to do now. I have tried many different slots and they all do the same thing. The code I'm calling takes seconds to process so that's probably bad. :) Anyone have ideas.....

The goal is to trigger after an object modification and I don't want to trigger on recomputes.
Thanks

Here is the exception:

Code: Select all

09:23:13  Unhandled Base::Exception caught in GUIApplication::notify.
The error message is: Access violation
My code:

Code: Select all

  
    def offset_control(self):
        if not self.no_update.isChecked():     
            if self.latch == False:
                self.latch = True
                self.on_color_to_refacing()
                self.latch = False
 

    class DocObserver:
    	def slotCommitTransaction(self, logic):
        visCB.offset_control()
        

visCB = cbToolBox() 
do = visCB.DocObserver()
App.addDocumentObserver(do)   
Here is the slot info:

Code: Select all

  /** Called when an observed document commits a transaction */
    void slotCommitTransaction(const App::Document& Doc);
User avatar
mfro
Posts: 663
Joined: Sat Sep 23, 2017 8:15 am

Re: Having exceptions that cause loss of 3D rotation

Post by mfro »

freedman wrote: Tue Aug 16, 2022 4:43 pm... It works for a while but then I get an Exception and my mouse won't rotate in the 3D...
Something working for a while and later on an access error in Python suspiciously smells like the garbage collector is stealing away something you still require.
Cheers,
Markus
User avatar
onekk
Veteran
Posts: 6144
Joined: Sat Jan 17, 2015 7:48 am
Contact:

Re: Having exceptions that cause loss of 3D rotation

Post by onekk »

freedman wrote: Tue Aug 16, 2022 4:43 pm Here is the exception:

Code: Select all

09:23:13  Unhandled Base::Exception caught in GUIApplication::notify.
The error message is: Access violation

This resemble me some problems with Qt signals or slots, not properly managed.

But I'm not a Qt experts, try to search about Transactions, if I don0t remember wrong there are some consideration around made by some developers when someone was developing a WB that heavily use the mouse.

Sorry to not be more helpful.

Regards

Carlo D.
GitHub page: https://github.com/onekk/freecad-doc.
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.

Blog: https://okkmkblog.wordpress.com/
Post Reply