Thread and GUI

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7459
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Thread and GUI

Post by ONEEYEMAN »

doublemax
I feel s embarrassed! :oops:

Thank you.

I will test that tonight and report back,
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7459
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Thread and GUI

Post by ONEEYEMAN »

doublemax,
Everything works as it should.

However I got another memory leak:

Code: Select all

---------- Block 31768 at 0x1FABEFF0: 8 bytes ----------
  Leak Hash: 0x6D2F9F2A, Count: 1, Total 8 bytes
  Call Stack (TID 11696):
    ucrtbased.dll!malloc()
    (Module name unavailable)!DllUnregisterServer() + 0x23CD bytes
    (Module name unavailable)!0x5025EDCC()
    (Module name unavailable)!0x5025C3C9()
    (Module name unavailable)!0x50257550()
    (Module name unavailable)!0x5025BC4C()
    (Module name unavailable)!0x5025D67C()
    (Module name unavailable)!0x5025DC85()
    (Module name unavailable)!0x5025B739()
    c:\wxwidgets\include\wx\thrimpl.cpp (356):
wxbase314ud_vc_custom.dll!wxThread::CallEntry() + 0xF bytes
    c:\wxwidgets\src\msw\thread.cpp (551):
wxbase314ud_vc_custom.dll!wxThreadInternal::DoThreadStart() + 0x8
bytes
    c:\wxwidgets\src\msw\thread.cpp (583):
wxbase314ud_vc_custom.dll!wxThreadInternal::WinThreadStart() + 0x9
bytes
    ucrtbased.dll!register_onexit_function() + 0x49C bytes
    ucrtbased.dll!register_onexit_function() + 0x1E9 bytes
    KERNEL32.DLL!BaseThreadInitThunk() + 0x24 bytes
    ntdll.dll!RtlInitializeExceptionChain() + 0x8F bytes
    ntdll.dll!RtlInitializeExceptionChain() + 0x5A bytes
  Data:
    B4 F5 E6 1F    00 00 00 00                                   ??......


Visual Leak Detector detected 1 memory leak (44 bytes).
Largest number used: 432166 bytes.
Total allocations: 3034586 bytes.
Visual Leak Detector is now exiting.
Detected memory leaks!
Dumping objects ->
{167608} normal block at 0x1FABEFF0, 8 bytes long.
 Data: <        > B4 F5 E6 1F 00 00 00 00
Object dump complete.
The program '[5304] docview.exe' has exited with code 0 (0x0).
Can you look at the code itself - maybe something will jump up for you?
Try it if you absolutely have to...

Thank you.
User avatar
doublemax
Moderator
Moderator
Posts: 19115
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Thread and GUI

Post by doublemax »

I can't spot any obvious reason for the leak. Can you make a git bisect to find out which exact commit is responsible.
Use the source, Luke!
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7459
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Thread and GUI

Post by ONEEYEMAN »

doublemax,
After removing Delete() from the thread function everything works and there is no leaks.
I'll try to check Linux and Mac today but suspect everything will work there as well.

Thank you.
jpo234
Experienced Solver
Experienced Solver
Posts: 70
Joined: Tue Feb 25, 2020 11:34 am

Re: Thread and GUI

Post by jpo234 »

May I suggest Boost.Signals2 for this?
You call the signal in the non-GUI thread and in the GUI code you attach a lambda that calls CallAfter. Simple and clean.
Post Reply