Not sure, but it seems I stumble over a bug in combination with wxGrid + Linux with enabled Debug.
What Happens:
- I close my application an get the message: "../src/common/object.cpp(336): assert "m_count > 0" failed in DecRef(): invalid ref data count"
More Details:
- I wrote an application with my own wxGrid implementation (inherited) to support some special Insert/Delete/... features.
- The app uses the AUI-Manager to show exactly 3 Custom-wxGrid-windows (2 with it's own Renderer) and also 1 wxPropertyGridManager.
- I compile the application against wxWidgets 3.1.5 (the official-inofficial "gtk3-unicode-3.1-unofficial" variant for Ubuntu 20 and also cross-compile it for Windows (wxWidgets 3.1.5 + 3.1.6 --- cross compiled by myself).
What I have observed:
- The exactly same application-source compiled for Windows (wxWidgets 3.1.5 & 3.1.6) as Debug and Release version run without any problem.
- The compiled application for Linux as Release is working, as Debug version - the above message occurs with a segmentation fault.
- After searching for the cause, I found that
--- the Windows-Variant always sets the focus to the first wxGrid table
--- if I start the Linux-Variant, no cell is focused, if I click on any cell (to get the focus) - I can close the application without crash
--- if I insert the call "SetFoucs()" into my code for the first wxGrid - than the problem not occurs, seems to be fixed
--- If I compile with everything exactly (Debug-Settings that crash), but add the option "-DNDEBUG" the issue is gone, too
Some ideas?
Bug? wxGrid + Debug + Linux
Re: Bug? wxGrid + Debug + Linux
Based on the assert message, it seems obvious that there is an error in your code regarding reference counting. If you check the wxGrid documentation, you'll see several methods that say "The caller must call DecRef() on the returned pointer.". I guess you didn't do that everywhere where it's needed.
This will just disable the assert, the bug is still there.If I compile with everything exactly (Debug-Settings that crash), but add the option "-DNDEBUG" the issue is gone, too
Use the source, Luke!
Re: Bug? wxGrid + Debug + Linux
That's right, I found also an other Forum thread with the same issue about the "DecRef()" ... something about the the attributes. But I don't touch them anywhere.
The reason why I'am think it could be also something other is, a SetFocus() call fix the issue too and or just selecting a cell.
- Does the SetFocus touch any reference counter?
- Should the windows application (Debug-variant) not crash also?
The reason why I'am think it could be also something other is, a SetFocus() call fix the issue too and or just selecting a cell.
- Does the SetFocus touch any reference counter?
- Should the windows application (Debug-variant) not crash also?
Re: Bug? wxGrid + Debug + Linux
The first step should be to get a backtrace/call stack from the assert and check which object caused it. This should narrow it down.
Use the source, Luke!
Re: Bug? wxGrid + Debug + Linux
You have right, I believe I found the problem. Looks like the garbage-management failed because of multiple use of an object.
In Detail: I used the "same" instance of my own wxGridCellRenderer for 2 tables at the same time.
Fix: Add an "IncRef()" before use of the Renderer a second time.
--
But, the open question for me, why a SetFocus also helps, too?
In Detail: I used the "same" instance of my own wxGridCellRenderer for 2 tables at the same time.
Fix: Add an "IncRef()" before use of the Renderer a second time.
--
But, the open question for me, why a SetFocus also helps, too?
Re: Bug? wxGrid + Debug + Linux
No idea. Probably some weird side-effect. You'd have to check what operations on the grid are executed because of that call. I'm sure there is a logical explanation, but i'm not sure if it's worth the effort to track it down.
Use the source, Luke!