How to create a wxBitmap on Macos

15 views
Skip to first unread message

gunter.ko...@gmail.com

unread,
Jun 8, 2022, 12:08:26 PM6/8/22
to wx-users
Dear all,

A complicated question (sorry for that) as I don't own a mac myself: In the following line 77 in my SvgBitmap.cpp I want to generate a bitmap of the size width x height that has 32 bit per pixel and a resolution that fits the screen:

  wxBitmap::operator=(wxBitmap(wxSize(width, height), 32, m_window->GetContentScaleFactor()));

Instead that line is reported to to result in:

Thread 0 Crashed::  Dispatch queue: com.apple.main-thread
0   libsystem_kernel.dylib                0x7ff81acf900e __pthread_kill + 10
1   libsystem_pthread.dylib               0x7ff81ad2f1ff pthread_kill + 263
2   libsystem_c.dylib                     0x7ff81ac7ad24 abort + 123
3   libwx_baseu-3.1.7.0.0.dylib              0x1113617ab wxFatalSignalHandler(int) + 33
4   libsystem_platform.dylib              0x7ff81ad44dfd _sigtramp + 29
5   CoreFoundation                        0x7ff81adc2ea8 _CFBundleCopyFindResources + 2654
6   wxmaxima                                 0x1100819d9 SvgBitmap::SetSize(int, int) + 105 (SvgBitmap.cpp:77)

Does this mean that my program has trashed the stack or done something else that inevitably has to cause a crash sooner or later - or did I fail to understand how to create a wxBitmap on macOs? The (in most other cases truly excellent) doxygen online manual isn't completely helpful in this case - or I somehow failed to hold it The Right Way...

Thanks a lot,
and kind regards,

    Gunter.

gunter.ko...@gmail.com

unread,
Jun 8, 2022, 12:12:39 PM6/8/22
to wx-users
Forgot an important piece of information: The class SvgBitmap is derived from the class wxBitmap.

Igor Korot

unread,
Jun 8, 2022, 12:25:55 PM6/8/22
to wx-u...@googlegroups.com
Hi, Gunter,

On Wed, Jun 8, 2022 at 11:12 AM gunter.ko...@gmail.com
<gunter.ko...@gmail.com> wrote:
>
> Forgot an important piece of information: The class SvgBitmap is derived from the class wxBitmap.

You also forgot to show the code you use to create it. ;-)

Thank you.
> --
> Please read https://www.wxwidgets.org/support/mlhowto.htm before posting.
> ---
> You received this message because you are subscribed to the Google Groups "wx-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to wx-users+u...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/wx-users/3406bb8c-d35c-4772-ada8-e9a75dba625bn%40googlegroups.com.

Vadim Zeitlin

unread,
Jun 8, 2022, 2:29:46 PM6/8/22
to wx-u...@googlegroups.com
On Wed, 8 Jun 2022 09:08:26 -0700 (PDT) gunter.ko...@gmail.com wrote:

g> A complicated question (sorry for that) as I don't own a mac myself: In the
g> following line 77 in my SvgBitmap.cpp I want to generate a bitmap of the
g> size width x height that has 32 bit per pixel and a resolution that fits
g> the screen:
g>
g> wxBitmap::operator=(wxBitmap(wxSize(width, height), 32,
g> m_window->GetContentScaleFactor()));
g>
g> Instead that line is reported to to result in:
g>
g> Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
g> 0 libsystem_kernel.dylib 0x7ff81acf900e __pthread_kill + 10
g> 1 libsystem_pthread.dylib 0x7ff81ad2f1ff pthread_kill + 263
g> 2 libsystem_c.dylib 0x7ff81ac7ad24 abort + 123
g> 3 libwx_baseu-3.1.7.0.0.dylib 0x1113617ab
g> wxFatalSignalHandler(int) + 33
g> 4 libsystem_platform.dylib 0x7ff81ad44dfd _sigtramp + 29
g> 5 CoreFoundation 0x7ff81adc2ea8
g> _CFBundleCopyFindResources + 2654
g> 6 wxmaxima 0x1100819d9
g> SvgBitmap::SetSize(int, int) + 105 (SvgBitmap.cpp:77)
g>
g> Does this mean that my program has trashed the stack or done something else
g> that inevitably has to cause a crash sooner or later - or did I fail to
g> understand how to create a wxBitmap on macOs?

Creating bitmaps under Mac works in the same way as anywhere else and is
not supposed to crash, of course. If the crash really happens at this line,
the most likely reason is that m_window is null or otherwise invalid.

Regards,
VZ

--
TT-Solutions: wxWidgets consultancy and technical support
http://www.tt-solutions.com/

Gunter Königsmann

unread,
Jun 8, 2022, 3:28:40 PM6/8/22
to wx-u...@googlegroups.com, Vadim Zeitlin
That is exactly the answer I needed. Thanks a lot,

Gunter.
Reply all
Reply to author
Forward
0 new messages