StatusBar fix exposes big issue...Lack of Dispose
See original GitHub issueIn https://github.com/migueldeicaza/gui.cs/pull/685, I caused a bug on exiting scenarios.
The problem is, within the StatusBar
constructor we connect up to Application.Resized
Application.Resized += (e) => {
This event subscription never gets removed, so even after the status bar has been destroyed this code gets called.
In order to fix this correctly, the View
class heirarchy needs to support Disposable
, I think,
I just built a POC to illustrate it, but it feels like a much deeper change than I’m comfy throughing together on a saturday morning. For now I’m going to hack around it to ensure that when the event handler is called nothing bad happens.
Issue Analytics
- State:
- Created 3 years ago
- Comments:7
Top Results From Across the Web
Dispose statusBarItem if there is no more message #320
At present, after sync extension displayed some message and then cleared the message after timeout, the statusBarItem still holds a place. This ...
Read more >issue with iOS7
Not every developer is sitting on a ton of money to throw at every problem. It's the very rare app that solve major...
Read more >Customize the Application Status Bar
If your status bar customization doesn't show, you may be using and outdated version of OutSystems UI. Try updating OutSystems UI from Forge....
Read more >tqdm in Jupyter Notebook prints new progress bars ...
The print statement is outputting a number (~0.89) in between each status bar update, which is messing up the output. Try removing the...
Read more >Python Progress Bar
A value at 1 or bigger represents 100% def update_progress(progress): barLength = 10 # Modify this to change the length of the progress...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Adding Disposable is fine, but I think that this surfaces one of the things that I hate most about the event programming in C#, which is that these things can leak and generally consume too much memory.
I wonder if we should instead encourage folks to either subclass Application and catch a proper virtual method for “Resize”, or using a delegate pattern for the event.
@migueldeicaza , while we have your attention:
I have convinced myself the
Responder
class hierarchy needs formalIDisposable
support.I have written a POC that adds
IDisposable
toResponder
and then modifiedApplication
and a few other key places to callDispose
on subviews appropriately.e.g. here’s
View.Dispose
:I added this to
Responder
:and used this to show it was working:
What do you think of adding this? I think we need it.