SetBackground UnRef causing exception

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.
PB
Part Of The Furniture
Part Of The Furniture
Posts: 4182
Joined: Sun Jan 03, 2010 5:45 pm

Re: SetBackground UnRef causing exception

Post by PB »

GDI handles can also leak outside obvious painting code, e.g. allocating wxFont, wxBitmap, wxIcon etc. to pass it to a control....
Telemotive
Earned a small fee
Earned a small fee
Posts: 10
Joined: Thu Sep 07, 2017 7:59 am

Re: SetBackground UnRef causing exception

Post by Telemotive »

doublemax wrote:I think it's safe to say that there is no memory leak in that paint event code. Also, the number of handles seems almost constant after the window has been shown once. Just to be sure: How is the paint event handler connected?
What do you mean with connected?
We just overwrote the wxPanel onPaint() method:

Code: Select all

class SettingsGridPanel : public wxPanel
doublemax wrote:I assume the settings window is opened above the main window? Does that have any custom paint code? Showing and hiding the settings window will also cause a paint event in the underlying window. Maybe the problem lies there. If yes, you should also see the problem if you just move a window from another application over your main window, so that lots of paint events are generated.
Yea, our application has one small window for main settings, a button to open an advanced settings dialog and a button to start the test.
The test progress is shown in another two windows, one dialog with a progress bar and a label telling the current test step.
The second window shows test logs and further test details.

I tried as you told me but no paint event entered the onPaint() code i previously posted here.
When I resize the windows a onPaint() event reaches my code.
Telemotive
Earned a small fee
Earned a small fee
Posts: 10
Joined: Thu Sep 07, 2017 7:59 am

Re: SetBackground UnRef causing exception

Post by Telemotive »

PB wrote:GDI handles can also leak outside obvious painting code, e.g. allocating wxFont, wxBitmap, wxIcon etc. to pass it to a control....
Thanks, but I already checked our usages of wxFont, wxBitmap, wxIcon etc. and did not find any issues.
User avatar
eranon
Can't get richer than this
Can't get richer than this
Posts: 867
Joined: Sun May 13, 2012 11:42 pm
Location: France
Contact:

Re: SetBackground UnRef causing exception

Post by eranon »

Did you try to do a dynamic code analysis through tools like BoundsChecker, Dr. Memory, Purify... https://en.wikipedia.org/wiki/Dynamic_program_analysis?
[Ind. dev. - wxWidgets 3.0/3.1 under "Win 7 64-bit, TDM64-GCC" + "OS X 10.9, LLVM Clang"]
Telemotive
Earned a small fee
Earned a small fee
Posts: 10
Joined: Thu Sep 07, 2017 7:59 am

Re: SetBackground UnRef causing exception

Post by Telemotive »

eranon wrote:Did you try to do a dynamic code analysis through tools like BoundsChecker, Dr. Memory, Purify... https://en.wikipedia.org/wiki/Dynamic_program_analysis?
Hey,

we already use Dr. Memory and I have also checked the reported leaks, but I am not able to identify the source.
Maybe you can help me:

This one appears on application start

Code: Select all

Error #1: GDI USAGE ERROR: DC 0xffffffffc6011cf1 that contains selected object being deleted
         system call NtGdiDeleteObjectApp
             <system call>
         GDI32.dll!GetRandomRgn
             ??:0
         wxDC::~wxDC        
             c:\sspandl\develop_1_5_1\funktionstester\externallibs\wx2017_x64\src\msw\dc.cpp(314):
         wxNotebook::OnPaint
             c:\sspandl\develop_1_5_1\funktionstester\externallibs\wx2017_x64\src\msw\notebook.cpp(957):
         wxEvtHandler::ProcessEventIfMatches
             c:\sspandl\develop_1_5_1\funktionstester\externallibs\wx2017_x64\src\common\event.cpp(1239):
         wxEventHashTable::HandleEvent
             c:\sspandl\develop_1_5_1\funktionstester\externallibs\wx2017_x64\src\common\event.cpp(907):
         wxRegion::~wxRegion
             c:\sspandl\develop_1_5_1\funktionstester\externallibs\wx2017_x64\src\msw\region.cpp(144):
         wxEvtHandler::ProcessEvent
             c:\sspandl\develop_1_5_1\funktionstester\externallibs\wx2017_x64\src\common\event.cpp(1301):
         wxWindow::HandlePaint
             c:\sspandl\develop_1_5_1\funktionstester\externallibs\wx2017_x64\src\msw\window.cpp(4607):
         wxWindow::MSWWindowProc
             c:\sspandl\develop_1_5_1\funktionstester\externallibs\wx2017_x64\src\msw\window.cpp(2747):
         UxTheme.dll!?          
             ??:0
         UxTheme.dll!?          
             ??:0
         UxTheme.dll!?          
             ??:0
         wxWndProc          
             c:\sspandl\develop_1_5_1\funktionstester\externallibs\wx2017_x64\src\msw\window.cpp(2618):
         USER32.dll!TranslateMessageEx
             ??:0
         USER32.dll!SetWindowTextW
             ??:0
         USER32.dll!IsDialogMessageW
             ??:0
         ntdll.dll!KiUserCallbackDispatcher
             ??:0
         wxWindow::MSWProcessMessage
             c:\sspandl\develop_1_5_1\funktionstester\externallibs\wx2017_x64\src\msw\window.cpp(2407):
         wxFrame::MSWDoTranslateMessage
             c:\sspandl\develop_1_5_1\funktionstester\externallibs\wx2017_x64\src\msw\frame.cpp(825):
         Note: DC was allocated here:
                    system call NtGdiCreateCompatibleDC 
             <system call>
                    GDI32.dll!CreateCompatibleDC
             ??:0
                    wxMemoryDC::CreateCompatible
                        c:\sspandl\develop_1_5_1\funktionstester\externallibs\wx2017_x64\src\msw\dcmemory.cpp(74):
                    wxNotebook::OnPaint
                        c:\sspandl\develop_1_5_1\funktionstester\externallibs\wx2017_x64\src\msw\notebook.cpp(927):
                    wxEvtHandler::ProcessEventIfMatches
                        c:\sspandl\develop_1_5_1\funktionstester\externallibs\wx2017_x64\src\common\event.cpp(1239):
                    wxEventHashTable::HandleEvent
                        c:\sspandl\develop_1_5_1\funktionstester\externallibs\wx2017_x64\src\common\event.cpp(907):
                    wxRegion::~wxRegion
                        c:\sspandl\develop_1_5_1\funktionstester\externallibs\wx2017_x64\src\msw\region.cpp(144):
                    wxEvtHandler::ProcessEvent
                        c:\sspandl\develop_1_5_1\funktionstester\externallibs\wx2017_x64\src\common\event.cpp(1301):
                    wxWindow::HandlePaint
                        c:\sspandl\develop_1_5_1\funktionstester\externallibs\wx2017_x64\src\msw\window.cpp(4607):
                    wxWindow::MSWWindowProc
                        c:\sspandl\develop_1_5_1\funktionstester\externallibs\wx2017_x64\src\msw\window.cpp(2747):
                    UxTheme.dll!?          
             ??:0
                    UxTheme.dll!?          
             ??:0
                    UxTheme.dll!?          
             ??:0
                    wxWndProc          
                        c:\sspandl\develop_1_5_1\funktionstester\externallibs\wx2017_x64\src\msw\window.cpp(2618):
                    USER32.dll!TranslateMessageEx
             ??:0
                    USER32.dll!SetWindowTextW
             ??:0
                    USER32.dll!IsDialogMessageW
             ??:0
                    ntdll.dll!KiUserCallbackDispatcher
             ??:0
                    wxWindow::MSWProcessMessage
                        c:\sspandl\develop_1_5_1\funktionstester\externallibs\wx2017_x64\src\msw\window.cpp(2407):
                    wxFrame::MSWDoTranslateMessage
                        c:\sspandl\develop_1_5_1\funktionstester\externallibs\wx2017_x64\src\msw\frame.cpp(825):
 
These two appear after opening the settings window

Code: Select all

Error #2: GDI USAGE ERROR: DC 0x000000006e01272a that contains selected object being deleted
         system call NtUserCallOneParam.RELEASEDC
             <system call>
         USER32.dll!ReleaseDC 
             ??:0
         COMCTL32.dll!Ordinal341  
             ??:0
         COMCTL32.dll!Ordinal341  
             ??:0
         wxWindow::MSWDefWindowProc
             c:\sspandl\develop_1_5_1\funktionstester\externallibs\wx2017_x64\src\msw\window.cpp(2240):
         KERNEL32.dll!MultiByteToWideChar
             ??:0
         COMCTL32.dll!Ordinal341  
             ??:0
         COMCTL32.dll!Ordinal341  
             ??:0
         USER32.dll!TranslateMessageEx
             ??:0
         USER32.dll!CallWindowProcW
             ??:0
         USER32.dll!CallWindowProcA
             ??:0
         wxNotebookWndProc  
             c:\sspandl\develop_1_5_1\funktionstester\externallibs\wx2017_x64\src\msw\notebook.cpp(915):
         USER32.dll!TranslateMessageEx
             ??:0
         USER32.dll!CallWindowProcW
             ??:0
         USER32.dll!CallWindowProcA
             ??:0
         wxWindow::MSWDefWindowProc
             c:\sspandl\develop_1_5_1\funktionstester\externallibs\wx2017_x64\src\msw\window.cpp(2240):
         wxWindow::MSWWindowProc
             c:\sspandl\develop_1_5_1\funktionstester\externallibs\wx2017_x64\src\msw\window.cpp(3427):
         UxTheme.dll!DrawThemeParentBackground
             ??:0
         UxTheme.dll!DrawThemeParentBackground
             ??:0
         UxTheme.dll!DrawThemeParentBackground
             ??:0
         Note: DC was allocated here:
                    system call NtUserGetDC 
             <system call>
                    COMCTL32.dll!Ordinal341  
             ??:0
                    COMCTL32.dll!Ordinal341  
             ??:0
                    wxWindow::MSWDefWindowProc
                        c:\sspandl\develop_1_5_1\funktionstester\externallibs\wx2017_x64\src\msw\window.cpp(2240):
                    KERNEL32.dll!MultiByteToWideChar
             ??:0
                    COMCTL32.dll!Ordinal341  
             ??:0
                    COMCTL32.dll!Ordinal341  
             ??:0
                    USER32.dll!TranslateMessageEx
             ??:0
                    USER32.dll!CallWindowProcW
             ??:0
                    USER32.dll!CallWindowProcA
             ??:0
                    wxNotebookWndProc  
                        c:\sspandl\develop_1_5_1\funktionstester\externallibs\wx2017_x64\src\msw\notebook.cpp(915):
                    USER32.dll!TranslateMessageEx
             ??:0
                    USER32.dll!CallWindowProcW
             ??:0
                    USER32.dll!CallWindowProcA
             ??:0
                    wxWindow::MSWDefWindowProc
                        c:\sspandl\develop_1_5_1\funktionstester\externallibs\wx2017_x64\src\msw\window.cpp(2240):
                    wxWindow::MSWWindowProc
                        c:\sspandl\develop_1_5_1\funktionstester\externallibs\wx2017_x64\src\msw\window.cpp(3427):
                    UxTheme.dll!DrawThemeParentBackground
             ??:0
                    UxTheme.dll!DrawThemeParentBackground
             ??:0
                    UxTheme.dll!DrawThemeParentBackground
             ??:0
                    UxTheme.dll!?          
             ??:0 

Code: Select all

Error #4: GDI USAGE ERROR: DC 0xffffffffdd011a7c that contains selected object being deleted
         system call NtGdiDeleteObjectApp
             <system call>
         GDI32.dll!GetRandomRgn
             ??:0
         wxToolTip::Add     
             c:\sspandl\develop_1_5_1\funktionstester\externallibs\wx2017_x64\src\msw\tooltip.cpp(375):
         wxToolTip::SetWindow
             c:\sspandl\develop_1_5_1\funktionstester\externallibs\wx2017_x64\src\msw\tooltip.cpp(402):
         wxWindowBase::SetToolTip
             c:\sspandl\develop_1_5_1\funktionstester\externallibs\wx2017_x64\src\common\wincmn.cpp(1714):
         MeasuringSettingPage::MeasuringSettingPage
             c:\sspandl\develop_1_5_1\funktionstester\source\fktlibgeneraldataloggertester\datasourceconfigurationpages\measuringsettingpage.cc(21):
         SystemTestNBPage::SystemTestNBPage
             c:\sspandl\develop_1_5_1\funktionstester\source\funktionstesteruserinterface\systemtestnbpage.cc(66):
         wxNotebookWndProc  
             c:\sspandl\develop_1_5_1\funktionstester\externallibs\wx2017_x64\src\msw\notebook.cpp(915):
         USER32.dll!TranslateMessageEx
             ??:0
         USER32.dll!SetScrollInfo
             ??:0
         USER32.dll!GetWindowLongW
             ??:0
         USER32.dll!IsWindow  
             ??:0
         USER32.dll!IsServerSideWindow
             ??:0
         USER32.dll!TranslateMessageEx
             ??:0
         USER32.dll!TranslateMessageEx
             ??:0
         USER32.dll!TranslateMessageEx
             ??:0
         USER32.dll!SetWindowTextW
             ??:0
         USER32.dll!GetSystemMenu
             ??:0
         wxWindowBase::InvalidateBestSize
             c:\sspandl\develop_1_5_1\funktionstester\externallibs\wx2017_x64\src\common\wincmn.cpp(514):
         wxStringData::Unlock
             c:\sspandl\develop_1_5_1\funktionstester\externallibs\wx2017_x64\include\wx\string.h(243):
         Note: DC was allocated here:
                    system call NtGdiCreateCompatibleDC 
             <system call>
                    GDI32.dll!CreateCompatibleDC
             ??:0
                    wxToolTip::Add     
                        c:\sspandl\develop_1_5_1\funktionstester\externallibs\wx2017_x64\src\msw\tooltip.cpp(343):
                    wxToolTip::SetWindow
                        c:\sspandl\develop_1_5_1\funktionstester\externallibs\wx2017_x64\src\msw\tooltip.cpp(402):
                    wxWindowBase::SetToolTip
                        c:\sspandl\develop_1_5_1\funktionstester\externallibs\wx2017_x64\src\common\wincmn.cpp(1714):
                    MeasuringSettingPage::MeasuringSettingPage
                        c:\sspandl\develop_1_5_1\funktionstester\source\fktlibgeneraldataloggertester\datasourceconfigurationpages\measuringsettingpage.cc(21):
                    SystemTestNBPage::SystemTestNBPage
                        c:\sspandl\develop_1_5_1\funktionstester\source\funktionstesteruserinterface\systemtestnbpage.cc(66):
                    wxNotebookWndProc  
                        c:\sspandl\develop_1_5_1\funktionstester\externallibs\wx2017_x64\src\msw\notebook.cpp(915):
                    USER32.dll!TranslateMessageEx
             ??:0
                    USER32.dll!SetScrollInfo
             ??:0
                    USER32.dll!GetWindowLongW
             ??:0
                    USER32.dll!IsWindow  
             ??:0
                    USER32.dll!IsServerSideWindow
             ??:0
                    USER32.dll!TranslateMessageEx
             ??:0
                    USER32.dll!TranslateMessageEx
             ??:0
                    USER32.dll!TranslateMessageEx
             ??:0
                    USER32.dll!SetWindowTextW
             ??:0
                    USER32.dll!GetSystemMenu
             ??:0
                    wxWindowBase::InvalidateBestSize
                        c:\sspandl\develop_1_5_1\funktionstester\externallibs\wx2017_x64\src\common\wincmn.cpp(514):
                    wxStringData::Unlock
                        c:\sspandl\develop_1_5_1\funktionstester\externallibs\wx2017_x64\include\wx\string.h(243): 
User avatar
eranon
Can't get richer than this
Can't get richer than this
Posts: 867
Joined: Sun May 13, 2012 11:42 pm
Location: France
Contact:

Re: SetBackground UnRef causing exception

Post by eranon »

I'm not used to use Dr. Memory specially, but according to their doc, it's not necessary relevant talking about recent Windows version: http://drmemory.org/docs/page_gdi.html (and in their topics -- at left side of the help pages --, it seems they separate memory leaks and GDI usage errors). So, maybe trying different analysis tools will help to figure out the point(s) of failure by crosscheck...
Last edited by eranon on Mon Sep 18, 2017 9:35 pm, edited 2 times in total.
[Ind. dev. - wxWidgets 3.0/3.1 under "Win 7 64-bit, TDM64-GCC" + "OS X 10.9, LLVM Clang"]
User avatar
doublemax
Moderator
Moderator
Posts: 19102
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: SetBackground UnRef causing exception

Post by doublemax »

We just overwrote the wxPanel onPaint() method:
wxWidgets event handlers are not implemented by overriding virtual methods. This method can have any name, there must be either a static event table or a Connect() call somewhere.

Code: Select all

wxNotebook::OnPaint
                        c:\sspandl\develop_1_5_1\funktionstester\externallibs\wx2017_x64\src\msw\notebook.cpp(927):
It's suspicious that the problem lies in the wxNotebook paint event handler. Do you have any class that derives from wxNotebook?

Seeing this, it's even possible that this is a bug in wxWidgets which has been fixed many years ago. Have you ever tried to compile your project under wx 3.1.x? Or did you just assume that it's a lot of work?

For a test, disable the paint event handler in SettingsGridPanel and check if the leak still exists. If yes, we've been searching in the wrong spot all the time.
Use the source, Luke!
User avatar
eranon
Can't get richer than this
Can't get richer than this
Posts: 867
Joined: Sun May 13, 2012 11:42 pm
Location: France
Contact:

Re: SetBackground UnRef causing exception

Post by eranon »

If it can help determining if the info is relevant or not, running Dr. Memory (1.11) against one of my own apps (launching the program, then exiting immediately), I got "13 total GDI usage errors" whose 12 about wxToolTip and one about wxNotebook:

Code: Select all

Error #35: GDI USAGE ERROR: DC 0x5f011a41 that contains selected object being deleted
# 0 system call NtGdiDeleteObjectApp     
# 1 GDI32.dll!DeleteDC                                 +0xb6     (0x7696596a <GDI32.dll+0x1596a>)
# 2 GDI32.dll!DeleteDC                                 +0x11     (0x769658c5 <GDI32.dll+0x158c5>)
# 3 wxMSWDCImpl::~wxMSWDCImpl                           [../../src/msw/dc.cpp:512]
# 4 wxMemoryDCImpl::~wxMemoryDCImpl                     [../../include/wx/msw/dcmemory.h:17]
# 5 wxMemoryDCImpl::~wxMemoryDCImpl                     [../../include/wx/msw/dcmemory.h:17]
# 6 wxDC::~wxDC                                         [C:/devlibs/wxWidgets-3.1.0/include/wx/dc.h:742]
# 7 wxMemoryDC::~wxMemoryDC                             [C:/devlibs/wxWidgets-3.1.0/include/wx/dcmemory.h:21]
# 8 wxNotebook::OnPaint                                 [../../src/msw/notebook.cpp:882]
# 9 wxAppConsoleBase::HandleEvent                       [../../src/common/appbase.cpp:657]
#10 wxAppConsoleBase::CallEventHandler                  [../../src/common/appbase.cpp:669]
#11 wxEvtHandler::ProcessEventIfMatchesId               [../../src/common/event.cpp:1381]
#12 wxEventHashTable::HandleEvent                       [../../src/common/event.cpp:989]
#13 wxEvtHandler::TryHereOnly                           [../../src/common/event.cpp:1578]
#14 wxEvtHandler::TryBeforeAndHere                      [../../include/wx/event.h:3656]
#15 wxEvtHandler::ProcessEventLocally                   [../../src/common/event.cpp:1511]
#16 wxEvtHandler::ProcessEvent                          [../../src/common/event.cpp:1484]
#17 wxEvtHandler::SafelyProcessEvent                    [../../src/common/event.cpp:1602]
#18 wxWindowBase::HandleWindowEvent                     [../../src/common/wincmn.cpp:1534]
#19 wxWindow::HandlePaint                               [../../src/msw/window.cpp:4719]
Note: @0:00:59.778 in thread 8248
Note: DC was allocated here:
Note: # 0 system call NtGdiCreateCompatibleDC  
Note: # 1 GDI32.dll!CreateCompatibleDC                       +0xf      (0x76965504 <GDI32.dll+0x15504>)
Note: # 2 wxMemoryDCImpl::CreateCompatible                    [../../src/msw/dcmemory.cpp:90]
Note: # 3 wxMemoryDCImpl::wxMemoryDCImpl                      [../../src/msw/dcmemory.cpp:45]
Note: # 4 wxNativeDCFactory::CreateMemoryDC                   [../../src/common/dcbase.cpp:149]
Note: # 5 wxMemoryDC::wxMemoryDC                              [../../src/common/dcbase.cpp:214]
Note: # 6 wxNotebook::OnPaint                                 [../../src/msw/notebook.cpp:802]
Note: # 7 wxAppConsoleBase::HandleEvent                       [../../src/common/appbase.cpp:657]
Note: # 8 wxAppConsoleBase::CallEventHandler                  [../../src/common/appbase.cpp:669]
Note: # 9 wxEvtHandler::ProcessEventIfMatchesId               [../../src/common/event.cpp:1381]
Note: #10 wxEventHashTable::HandleEvent                       [../../src/common/event.cpp:989]
Note: #11 wxEvtHandler::TryHereOnly                           [../../src/common/event.cpp:1578]
Note: #12 wxEvtHandler::TryBeforeAndHere                      [../../include/wx/event.h:3656]
Note: #13 wxEvtHandler::ProcessEventLocally                   [../../src/common/event.cpp:1511]
Note: #14 wxEvtHandler::ProcessEvent                          [../../src/common/event.cpp:1484]
Note: #15 wxEvtHandler::SafelyProcessEvent                    [../../src/common/event.cpp:1602]
Note: #16 wxWindowBase::HandleWindowEvent                     [../../src/common/wincmn.cpp:1534]
Note: #17 wxWindow::HandlePaint                               [../../src/msw/window.cpp:4719]
Note: #18 wxWindow::MSWHandleMessage                          [../../src/msw/window.cpp:2810]
Note: #19 wxWindow::MSWWindowProc                             [../../src/msw/window.cpp:3524]
Done under Windows 7 64-bit with a 32-bit DEBUG build of the app (wx31-based).
[Ind. dev. - wxWidgets 3.0/3.1 under "Win 7 64-bit, TDM64-GCC" + "OS X 10.9, LLVM Clang"]
User avatar
doublemax
Moderator
Moderator
Posts: 19102
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: SetBackground UnRef causing exception

Post by doublemax »

eranon wrote:If it can help determining if the info is relevant or not, running Dr. Memory (1.11) against one of my own apps (launching the program, then exiting immediately), I got "13 total GDI usage errors" whose 12 about wxToolTip and one about wxNotebook:
Thanks. So it's possible that the errors in the wxNoteBook paint event handler are not relevant after all. This is getting more confusing all the time.

To OP: If you can't provide a sample that demonstrates the issue, i can only recommend to start commenting out parts of your code that deal with GDI objects until you've narrowed down the code location.

If you can't post relevant code publicly, you can also PM me. Maybe we can figure something out.
Use the source, Luke!
Telemotive
Earned a small fee
Earned a small fee
Posts: 10
Joined: Thu Sep 07, 2017 7:59 am

Re: SetBackground UnRef causing exception

Post by Telemotive »

Hey, again.

Thanks for your suggestions doublemax and eranon (especially for the Dr. Memory testing).
First your questions:
Do you have any class that derives from wxNotebook?
yes, but there are too many to show them all here
Have you ever tried to compile your project under wx 3.1.x? Or did you just assume that it's a lot of work?
We tried, but got many linking errors. I think I can remember because of an wxWidgets API change.
For a test, disable the paint event handler in SettingsGridPanel and check if the leak still exists.
We did that and testing is still going on. We cant yet say it solved the problem, but the error has not occured yet.
To OP: If you can't provide a sample that demonstrates the issue, i can only recommend to start commenting out parts of your code that deal with GDI objects until you've narrowed down the code location.
We do not know under what circumstances the error happens, so I can not provide a sample. :?


As said we are testing with some paint events commented out. I´ll give you feedback as soon as possible.
The GDI- and User-Object monitoring is implemented, but since that we did not have a crash, so I still can not say that it is a GDI- User-Object leak.
User avatar
doublemax
Moderator
Moderator
Posts: 19102
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: SetBackground UnRef causing exception

Post by doublemax »

The GDI- and User-Object monitoring is implemented, but since that we did not have a crash, so I still can not say that it is a GDI- User-Object leak.
You said you got an increase of GDI handles when you opened end closed the settings window. Shouldn't the change be visible immediately ?
Use the source, Luke!
Telemotive
Earned a small fee
Earned a small fee
Posts: 10
Joined: Thu Sep 07, 2017 7:59 am

Re: SetBackground UnRef causing exception

Post by Telemotive »

You said you got an increase of GDI handles when you opened end closed the settings window. Shouldn't the change be visible immediately ?
Yea, that is true, but that was just a test to check if there is a leak somewhere in general.
Our guess is that there might be a leak in the progress panel or our log-output panel, but it only happens sporadically.
There is no leak on short test runs, only on long Test runs (1 hour per test cycle for about a week).
coderrc
Earned some good credits
Earned some good credits
Posts: 141
Joined: Tue Nov 01, 2016 2:46 pm

Re: SetBackground UnRef causing exception

Post by coderrc »

I havent used wxWidgets 2.8, so this is just a stab in the dark.

When I looked at your stack trace in the OP, it struck me as being very similar to what you would expect to see when you perform GUI tasks in a function that is called from a thread outside of the GUI context.

And then I saw
doublemax wrote:
What do you mean with connected?
We just overwrote the wxPanel onPaint() method:
...
no paint event entered the onPaint() code i previously posted here.
wxWidgets event handlers are not implemented by overriding virtual methods. This method can have any name, there must be either a static event table or a Connect() call somewhere.
Which leads me to think that, potentially, since your onPaint code wasnt properly connected to the event loop, your "this" pointer may lie outside of the GUI context, so you wind up with intermittent exceptions when trying to Ref and UnRef the GUI objects.

This is really just a guess though.
Post Reply