Skip to content

Conversation

@merceyz
Copy link
Member

@merceyz merceyz commented Feb 17, 2019

  • Added AbstractRenderHandler that takes care of the basics of a IRenderHandler
  • Refactored the RenderHandlers to inherit from AbstractRenderHandler
  • Implemented the correct and thread safe dispose pattern

* Added a AbstractRenderHandler
* Refactored the RenderHandlers to inherit from AbstractRenderHandler
* Implemented the correct and thread safe dispose pattern
@AppVeyorBot
Copy link

@AppVeyorBot
Copy link

Copy link
Member

@amaitland amaitland left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comments inline, not quite sure what to do with ByteArrayWritableBitmapRenderHandler inheriting from AbstractRenderHandler, open to suggestions.

/// </summary>
/// <seealso cref="CefSharp.Wpf.IRenderHandler" />
public class ByteArrayWritableBitmapRenderHandler : IRenderHandler
public class ByteArrayWritableBitmapRenderHandler : AbstractRenderHandler
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AbstractRenderHandler contains methods/properties that aren't used in this particular instance, so doesn't quite fit having it as a base class.

@amaitland amaitland added this to the 73.0.0 milestone Feb 28, 2019
@AppVeyorBot
Copy link

/// </summary>
public void Dispose()
{
Dispose(true);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If obj does not have a finalizer, the call to the SuppressFinalize method has no effect.

https://docs.microsoft.com/en-us/dotnet/api/system.gc.suppressfinalize?view=netframework-4.7.2

So looks like it's a NO OP, not sure why it's in the example.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's for when a derived class has a Finalizer

@amaitland
Copy link
Member

Will remove the AbstractRenderHandler inheritance from ByteArrayWritableBitmapRenderHandler and make the static properties internal.

It might be worth creating an abstract class that implants just the Dispose pattern, will look at doing so if I have time.

Little more testing and this should be merged in a few days, will take care of the changes when it comes to merge time. Thanks 👍

@merceyz
Copy link
Member Author

merceyz commented Feb 28, 2019

It might be worth creating an abstract class that implants just the Dispose pattern, will look at doing so if I have time.

That was what i wanted to do for #2651 but it would only be possible on the OffScreen version.
I also wanted to do it on every object that doesn't have a base class + implements IDisposable but I haven't gotten around to it yet.

@amaitland
Copy link
Member

Broadly speaking that sounds fine, feel free to create an issue to track the task. There are quite a few instances where Dispose is called as the result of the unmanaged class/refptr being freed which won't be candidates for a base class.

@AppVeyorBot
Copy link

@amaitland amaitland merged commit 5c292cd into cefsharp:master Mar 1, 2019
amaitland added a commit that referenced this pull request Mar 1, 2019
AbstractRenderHandler - change pixel properties to internal so they can be shared ByteArrayWritableBitmapRenderHandler
WritableBitmapRenderHandler - run Format Document (changed fields to read only)

Follow up to #2652
@amaitland
Copy link
Member

Follow up commit is 4a145bf

Changed base class, didn't implement a base disposable class yet, will look at that as a issue of it's own. I guess technically it doesn't need to actually implement Dispose, so we might not even bother for ByteArrayWritableBitmapRenderHandler.

@merceyz merceyz deleted the refactor-wpf-renderhandler branch March 30, 2019 12:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants