• Login
sketchucation logo sketchucation
  • Login
🔌 Quick Selection | Try Didier Bur's reworked classic extension that supercharges selections in SketchUp Download

State of Observers Redux — 18 August 2011

Scheduled Pinned Locked Moved Developers' Forum
30 Posts 4 Posters 5.3k Views 4 Watching
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    thomthom
    last edited by 12 Sept 2010, 15:45

    aiaiai... sigh


    Ugh.png

    Thomas Thomassen — SketchUp Monkey & Coding addict
    List of my plugins and link to the CookieWare fund

    1 Reply Last reply Reply Quote 0
    • T Offline
      thomthom
      last edited by 18 Aug 2011, 21:57

      Update to include SU 8.0 M1
      http://www.thomthom.net/software/sketchup/observers/

      Thomas Thomassen — SketchUp Monkey & Coding addict
      List of my plugins and link to the CookieWare fund

      1 Reply Last reply Reply Quote 0
      • D Offline
        Dan Rathbun
        last edited by 18 Aug 2011, 22:19

        You have that the AppObserver::onQuit is working...

        It's is bugged in v8 (at least. And I did report a bug last beta cycle.)

        It does not wait until the callbacks return, before shutting down the application.
        Trying to use the callback to save plugin settings, and so forth, often fails for me.

        Also, trying to dettach the observer itself from within onQuit causes a GPF (if I remember right.)
        In addition coders should NOT open any "owned" windows (like WebDialogs and messageboxes,) during the callback, until they fix the 'non-blocking' issue.


        Can't remember if v7 had any of these problems.

        I'm not here much anymore.

        1 Reply Last reply Reply Quote 0
        • T Offline
          thomthom
          last edited by 19 Aug 2011, 07:19

          @dan rathbun said:

          You have that the AppObserver::onQuit is working...

          It's is bugged in v8 (at least. And I did report a bug last beta cycle.)

          Ok - I'll add that. Never used it. All the observers I've not tried and not heard any reports on I assume is working.

          @dan rathbun said:

          InstanceObserver

          @dan rathbun said:

          what about Groups?

          Groups and Images all are listed in model.definition.

          @dan rathbun said:

          (Note how I changed the example, from UI.messagebox to puts.

          I wish the docs would do that. Messageboxes are double plus ungood - especially in observer events.

          Thomas Thomassen — SketchUp Monkey & Coding addict
          List of my plugins and link to the CookieWare fund

          1 Reply Last reply Reply Quote 0
          • T Offline
            thomthom
            last edited by 19 Aug 2011, 07:43

            Dan, how do you test AppObserver::onQuit ?

            If I had a test case that illustrates the symptoms I could quickly run it on SU 6-8.

            Thomas Thomassen — SketchUp Monkey & Coding addict
            List of my plugins and link to the CookieWare fund

            1 Reply Last reply Reply Quote 0
            • D Offline
              Dan Rathbun
              last edited by 19 Aug 2011, 13:48

              @thomthom said:

              Dan, how do you test AppObserver::onQuit

              Tough one... as it DOES fire. (It just doesn't wait for the callback to finish.)
              Well I first found it because I wanted to save the pos & size of several windows using Win32API calls.
              But it wasn't working.

              So I tried putting a debug popup messagebox inside onQuit(), thinking the shutdown process should stop, until I clicked "OK". But it DIDN'T stop, the messagebox came up, but everything else shutdown. And when I closed the messagebox, it's owner (the Sketchup App window,) no longer existed, so Windows poped up the VS Just in Time debugger query box (you know.. "DO want Debug now?")

              So next I tried, to open a WebDialog.. and that made things even worse. (I got a post-shutdown BugSplat!) They were either GPF or "Unhandled Win32 Exception".)

              I was trying to call a method that saved a whole bunch of data into the Registry, and that method may have called another method as well. Anyway, I even tried "lean" the process way down, putting all statements inside the onQuit(), and removing every extra reference assignment I could. But Sketchup just would not wait. It seemed to be processing all the onQuit callbacks, in the Ruby thread, but at the same time, cleaning up the main App thread, and disposing of all it's child windows.

              Perhaps it's a unique thing because I want to save window object data, ...that most other plugins would not encounter.

              I plan to try using Ruby define_finalizer, and see if that works for me.

              As far as testing.. I'll have to think more on this... perhaps a trace function.

              I'm not here much anymore.

              1 Reply Last reply Reply Quote 0
              • D Offline
                Dan Rathbun
                last edited by 19 Aug 2011, 13:50

                @thomthom said:

                @dan rathbun said:

                InstanceObserver

                @dan rathbun said:

                what about Groups?

                Groups and Images all are listed in model.definition.

                I don't have a Mac to test this InstanceObserver workaround.

                (And I fixed the example. I don't know why, but every single time I go to write an initialize() method, I forget to put def in front of it!)

                I'm not here much anymore.

                1 Reply Last reply Reply Quote 0
                • D Offline
                  Dan Rathbun
                  last edited by 19 Aug 2011, 13:51

                  InstanceObserver

                  I'm wonding if you can do this

                  #
                  class InstSpy < Sketchup;;InstanceObserver
                  
                    if RUBY_PLATFORM =~ /(darwin)/
                      def onQuit()
                        Sketchup.active_model.definitions.instances.each{|i|
                          i.remove_observer(self)
                        }
                        # what about Groups?
                      end
                    end #if
                  
                    def initialize(*args)
                      Sketchup.add_observer(self) if RUBY_PLATFORM =~ /(darwin)/
                    end
                  
                    # define your Instance callbacks;
                   
                    def onOpen(instance)
                      puts("onOpen; " + instance.to_s)
                    end
                  
                    def onClose(instance)
                      puts("onClose; " + instance.to_s)
                    end
                  
                  end # class
                  
                  

                  (Note how I changed the example, from UI.messagebox to puts.

                  I'm not here much anymore.

                  1 Reply Last reply Reply Quote 0
                  • T Offline
                    thomthom
                    last edited by 19 Aug 2011, 14:17

                    In TT_Lib2 I got a function TT.debug that outputs a string to any system debugger, like DebugView. That can probably be used to track onQuit.

                    Thomas Thomassen — SketchUp Monkey & Coding addict
                    List of my plugins and link to the CookieWare fund

                    1 Reply Last reply Reply Quote 0
                    • T Offline
                      thomthom
                      last edited by 2 Aug 2012, 11:58

                      Added public bug tracker to the BitBucket repo:
                      https://bitbucket.org/thomthom/sketchup-observers/issues?status=new&status=open

                      People can add reports of broken observer events there.

                      Thomas Thomassen — SketchUp Monkey & Coding addict
                      List of my plugins and link to the CookieWare fund

                      1 Reply Last reply Reply Quote 0
                      • 1
                      • 2
                      • 2 / 2
                      • First post
                        Last post
                      Buy SketchPlus
                      Buy SUbD
                      Buy WrapR
                      Buy eBook
                      Buy Modelur
                      Buy Vertex Tools
                      Buy SketchCuisine
                      Buy FormFonts

                      Advertisement