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

function embed error #6

Open
Wandrys-dev opened this issue May 1, 2021 · 5 comments
Open

function embed error #6

Wandrys-dev opened this issue May 1, 2021 · 5 comments
Assignees
Labels
bug Something isn't working question Further information is requested

Comments

@Wandrys-dev
Copy link

It seems that the embed function has a problem, as shown in the image below:
bug_embed

@Wandrys-dev
Copy link
Author

image

@apjanke apjanke self-assigned this May 1, 2021
@apjanke
Copy link
Member

apjanke commented May 1, 2021

Hmm. What version of Matlab are you running? Maybe Matlab's interface to the Handle Graphics system has changed.

The code in embed you're running in to is this:

      if ishandle(thing)
        cid = this.embedFigure(thing);
      elseif ischar(thing) || isstring(thing)
        cid = string(this.j.embed(java.io.File(thing)));
      else
        error('mailspoon:InvalidInput', 'Invalid type for thing: expected string or handle; got a %s', class(thing));
      end

I thought that the thing returned by figure would answer "true" to ishandle(fig), but maybe that's no longer true?

Thanks for the bug report!

@Wandrys-dev
Copy link
Author

That could be it. I am using MATLAB version R2021a

@apjanke
Copy link
Member

apjanke commented May 2, 2021

Okay! I'll install R2021a and see if I can reproduce.

@apjanke
Copy link
Member

apjanke commented May 6, 2021

Okay, here's a weird thing. I'm now running Matlab R2021a on macOS 10.14.

>> ver
-----------------------------------------------------------------------------------------------------
MATLAB Version: 9.10.0.1649659 (R2021a) Update 1
MATLAB License Number: 973906
Operating System: Mac OS X  Version: 10.14.6 Build: 18G9028 
Java Version: Java 1.8.0_202-b08 with Oracle Corporation Java HotSpot(TM) 64-Bit Server VM mixed mode
-----------------------------------------------------------------------------------------------------
MATLAB                                                Version 9.10        (R2021a)
Database Toolbox                                      Version 10.1        (R2021a)
Financial Toolbox                                     Version 6.1         (R2021a)
Optimization Toolbox                                  Version 9.1         (R2021a)
Parallel Computing Toolbox                            Version 7.4         (R2021a)
Signal Processing Toolbox                             Version 8.6         (R2021a)
Statistics and Machine Learning Toolbox               Version 12.1        (R2021a)
>> 

Here's my repro code:

function mailspoon_figure_embed_test

e = mailspoon.HtmlEmail;

fig = figure('Visible','off');
surf(peaks)
fig_cid = e.embed(fig);

end

And it works just fine:

>> mailspoon_figure_embed_test
>> 

For me, this Figure thing responds true to ishandle():

>> dbstop in mailspoon.HtmlEmail at 61
>> mailspoon_figure_embed_test
61        if ishandle(thing)
K>> dbstack
> In mailspoon/HtmlEmail/embed (line 61)
In mailspoon_figure_embed_test (line 7)
K>> thing
thing = 
  Figure (4) with properties:

      Number: 4
        Name: ''
       Color: [0.9400 0.9400 0.9400]
    Position: [1000 918 560 420]
       Units: 'pixels'

  Show all properties
K>> ishandle(thing)
ans =
  logical
   1
K>> 

So... ¯\(ツ)/¯?

Based on your screenshots, it looks like you're using this inside a Live Script or notebook context. Maybe there's something going on there?

@apjanke apjanke added bug Something isn't working question Further information is requested labels May 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants