Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8682385
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T21:45:29+00:00 2026-06-12T21:45:29+00:00

I have some rendering code, which relies on DrawingContext.PushClip and the corresponding Pop method.

  • 0

I have some rendering code, which relies on DrawingContext.PushClip and the corresponding Pop method.

protected override void OnRender(DrawingContext drawingContext)
{
    drawingContext.PushClip(whatever);
    OnRenderInternal(...);
    drawingContext.Pop();
}
  • Now, let’s assume that something really bad happens in the OnRenderInternal method and it throws an exception (in this case Pop will never get called). Would this break the entire rendering process or the drawing context will revert itself to some “safe” state before performing other operations (and no clipping will occure for other renderable items)?

  • Basically, should I always care about reverting the drawing context to its initial state when performing rendering operations?

  • I realize that in this simple case I can avoid troubles by using a try-finally statement, but what would happen if I forget to preserve the correct Push / Pop stack?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T21:45:30+00:00Added an answer on June 12, 2026 at 9:45 pm

    I think there is typically no need to revert the DrawingContext to its initial state, for the simple reason that you get a new DrawingContext on every call to OnRender. The whole drawing is re-created every time OnRender is called and it doesn’t matter in which state you leave the DrawingContext.

    There is however an exception. A derived UIElement may also override OnRender and may first call base.OnRender() before performing its own rendering code. In this scenario the derived UIElement would get the “corrupted” DrawingContext from the base class’ OnRender method.

    So unless you can make sure that your UIElement can’t be derived from, it looks like a good idea not to leave the DrawingContext in an undefined, “corrupted” state.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a spring action that I am rendering some json from the controller,
I have an opengl scene rendering on an EAGLView layer and some other elements
For some reason the HTML2PDF/TCPDF is not rendering the PDF... and I have no
I have some code on two systems running kernel 2.4.20 and kernel 2.4.38 .
I have some weird problem in rendering some xhtml in IE 8 http://img709.imageshack.us/i/scrj.png/ .
I am rewriting some rendering C code in C++. The old C code basically
I have a critical section of code which examines each char in many strings
I have a visualforce page which is rendering correctly. There is a commandbutton Save
I have two web jsf projects which potentially could share some classes and beans,
I'm thinking about writing some code in JavaScript which I can use in my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.