# SetBatch causes different graphics output for pngs

**URL:** <https://root-forum.cern.ch/t/setbatch-causes-different-graphics-output-for-pngs/19682>\
**Category:** ROOT\
**Created:** [August 12, 2015, 7:44pm UTC](https://root-forum.cern.ch/t/setbatch-causes-different-graphics-output-for-pngs/19682 "2015-08-12T19:44:25Z")\
**Posts on this page:** 1\
**Showing post:** 22

<div class="post-metadata">

**Author:** ![Wile\_E\_Coyote](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/wile_e_coyote/32/12417_2.png) [@Wile\_E\_Coyote](https://root-forum.cern.ch/u/Wile_E_Coyote)\
**Post date:** [September 15, 2017, 1:51pm UTC](https://root-forum.cern.ch/t/setbatch-causes-different-graphics-output-for-pngs/19682/22 "2017-09-15T13:51:07Z")

</div>

I play with “v5-34-00-patches" only and it seems I was able to “stabilize” it.

The original old source code of “TRootCanvas::SetWindowSize” failed in something like 40% of trials. After adding “gVirtualX-\>Update(1);”, it failed in something like 33% of trials. After “gSystem-\>Sleep(100);” modification, it failed in something like 27% of trials. So I tried “gSystem-\>Sleep(1000);” and it still failed in something like 15% of trials.

So, I decided to play with this myself and I have found a solution which seems to work:

```auto
   gVirtualX->Update(1);
   if (!gThreadXAR) {
      gSystem->Sleep(100); // at least 50; 100 is safer                         
      gSystem->ProcessEvents();
      gSystem->Sleep(10); // does not matter at all                             
      gSystem->ProcessEvents();
   }

```

---

_[View the full topic](https://root-forum.cern.ch/t/setbatch-causes-different-graphics-output-for-pngs/19682)._
