Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial license get during load #20

Open
DanRathbun opened this issue Oct 15, 2020 · 1 comment
Open

Initial license get during load #20

DanRathbun opened this issue Oct 15, 2020 · 1 comment

Comments

@DanRathbun
Copy link

At the bottom of the Licenseing tutorial module ...
"master/examples/99_license/ex_hello_license/main.rb"

    # Fetching a license here so that it will be checked by SketchUp during
    # startup. This will include the extension in the dialog that warns about
    # missing licenses.
    ext_id = '6cce9800-40b0-4dd9-9671-8d55a05ae1e8'
    ext_lic = Sketchup::Licensing.get_extension_license(ext_id)

This is a bit contradictory to the text in the self.create_cube method.

How about wrapping it within an init method ?

    def self.init
      # Fetching a license here so that it will be checked by SketchUp during
      # startup. This will include the extension in the dialog that warns about
      # missing licenses.
      ext_id = '6cce9800-40b0-4dd9-9671-8d55a05ae1e8'
      ext_lic = Sketchup::Licensing.get_extension_license(ext_id)
    end

    self.init()

... or don't assign the results to local variables?

    Sketchup::Licensing.get_extension_license(
      '6cce9800-40b0-4dd9-9671-8d55a05ae1e8'
    )

?

@DanRathbun
Copy link
Author

DanRathbun commented Aug 28, 2021

Yes, looking at this again after a long time, ... the latter would be much better.

There is no point in assigning the results to local variables within the submodule as they are never used.
All we care about is that the Extension Manager gets a chance to check the licensing during the load cycle.


Also in the "ex_hello_license/main.rb" file, It is not necessary to assign local variables.

Instance variables can also be seen. The example has a blocking message box that would allow the variables to exist whilst the modal window is open.
Perhaps:

      unless Sketchup::Licensing.get_extension_license(
        '6cce9800-40b0-4dd9-9671-8d55a05ae1e8'
      ).licensed?
        UI::messagebox('Could not obtain a valid license.')
        return
      end

... or ...

      ext_id = '6cce9800-40b0-4dd9-9671-8d55a05ae1e8'
      license = Sketchup::Licensing.get_extension_license(ext_id)
      bailout = license.licensed?
      ex_id = license = nil
      GC.start
      if bailout
        UI::messagebox('Could not obtain a valid license.')
        return
      end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant