Re: ROOT incompatible with VC++ 6

From: Andy Haas (root_news@yahoo.com)
Date: Fri Oct 02 1998 - 21:34:43 MEST


I also found it necessary to make changes in TPad::Pick() so that
Canvases would not crash when opened in NT. The problems were again in
refering to gPad and other globals, before they had a chance to be
initialized. So, this appears to be slightly more general problem. I
inserted 2 lines into TPad::Pick() as follows:

TPad *TPad::Pick(Int_t px, Int_t py, TObjLink *&pickobj)
{
   Int_t dist;
   Float_t x = AbsPixeltoX(px);
   Float_t y = AbsPixeltoY(py);

   if (gPad == 0) return 0; //Andy Haas

   if (this != gPad->GetCanvas()) {
      if (!((x >= fX1 && x <= fX2) && (y >= fY1 && y <= fY2))) return 0;
   }

   static TObjOptLink dummyLink(0,"");  
   TPad *padsav = (TPad*)gPad;
   gPad  = this;
   TPad *pick   = 0;
   TPad *picked = this;
   pickobj      = 0;
   if (DistancetoPrimitive(px,py) < kDistanceMaximum) {
      dummyLink.SetObject(this);
      pickobj = &dummyLink;
   }
   Bool_t gotPrim = kFALSE;

   if (GetListOfPrimitives() == 0) return 0; //Andy Haas

   TObjLink *lnk = GetListOfPrimitives()->LastLink();
   while (lnk) {
      TObject *obj = lnk->GetObject();
      fPadPointer  = obj;
      if (obj->InheritsFrom(TPad::Class())) {
         pick = ((TPad*)obj)->Pick(px, py, pickobj);
         if (pick) {
            picked = pick;
            break;
         }
      } else if (!gROOT->GetEditorMode()) {
         if (!gotPrim) {
            dist = obj->DistancetoPrimitive(px, py);
            if (dist < kDistanceMaximum) {
               pickobj = lnk;
               gotPrim = kTRUE;
               if (dist == 0) break;
            }
         }
      }

      lnk = lnk->Prev();
   }

   if (picked->InheritsFrom(TButton::Class())) {
      TButton *button = (TButton*)picked;
      if (!button->GetCanvas()->IsEditable()) pickobj = 0;
   }

   gPad = padsav;
   return picked;
}

I hope this change can be included before the new release. Sorry for
not pointing it out earlier. Cheers, Andy.

Andrew Haas
University of Washington Physics Graduate Program
Glast - D0


---Valery Fine <fine@bnl.gov> wrote:
>
> On 25 Sep 98 at 11:07, Andy Haas wrote:
> 
> > I've noticed that ROOT version 2.00/11 for WinNT has problems with
> > the new MSVCRT.DLL distributed with VC++ 6.0 on NT. For instance,
> > using the new dll, attempting to divide a canvas by right clicking
> > and filling in arguments causes a crash in the dll. This happens
> > many other places as well. 
> 
>  I think it is  ROOT "problem" rather the MS one.
> 
>  I can not check it myself, since I have no VC++ 6.0 but I hope the 
> TPad::Divide can be changed as follows  and it will help
> The soil of this correction is to try to avoid touching
> the global variable <gPad> from the concurrent working threads.
> (Very likely the MS VC++ 6.0 DLL works just faster then that old one)
> 
> //_______________________________
> void TPad::Divide(Int_t nx, Int_t ny, Float_t xmargin, Float_t
ymargin, Int_t color)
> {
> //VF 02/10/98   TPad *padsav = (TPad*)gPad;
> //VF 02/10/98   cd();
>    if (nx <= 0) nx = 1;
>    if (ny <= 0) ny = 1;
>    Int_t ix,iy;
>    Float_t x1,y1,x2,y2;
>    Float_t dy = 1/Float_t(ny);
>    Float_t dx = 1/Float_t(nx);
>    TPad *pad;
>    char *name = new char [strlen(GetName())+6];
>    Int_t n = 0;
>    if (color == 0) color = GetFillColor();
>    for (iy=0;iy<ny;iy++) {
>       y2 = 1 - iy*dy - ymargin;
>       y1 = y2 - dy + 2*ymargin;
>       if (y1 < 0) y1 = 0;
>       if (y1 > y2) continue;
>       TList *primitives = GetListOfPrimitives();   // VF 02/10/98
>       if (primitives ) {                           // VF 02/10/98 
>         for (ix=0;ix<nx;ix++) {
>            x1 = ix*dx + xmargin;
>            x2 = x1 +dx -2*xmargin;
>            if (x1 > x2) continue;
>            n++;
>            sprintf(name,"%s_%d",GetName(),n);
>            pad = new TPad(name,name,x1,y1,x2,y2,color);
>            pad->SetNumber(n);
>            pad->SetMother(this);               // VF 02/10/98 we
need new method: TPad::SetMother(TPad *pad){fMother =  pad;} 
>            pad->setCanvas(GetCanvas());        // VF 02/10/98we need
new method: TPad::SetCanvas(TPad *canvas){fCanvas =  canvas;}   
>            primitives->Add(pad);
>       }
>    }
>    delete [] name;
>    Modified();
>    Paint();                 // VF 02/10/98
> // VF 02/10/98   padsav->cd();
> }
> =================================================================
> Dr. Valeri Faine (Fine)
>     -------------------          Phone: +1 516 344 7806
> Brookhaven National Laboratory   FAX  : +1 516 344 4206
> Bldg. 510A /STAR                 mailto:fine@bnl.gov
> Upton, New York, 11973-5000      http://nicewww.cern.ch/~fine
> USA
>                                  
> Dr. Valery Fine                  Telex : 911621 dubna su
>     -----------
> LCTA/Joint Inst.for Nuclear Res. Phone : +7 09621 6 40 80
> 141980 Dubna, Moscow region      Fax   : +7 09621 6 51 45
> Russia                           mailto:fine@main1.jinr.dubna.su    
                         
> 
> 

==
Andrew Haas - haas@yahoo.com
University of Washingon Physics
Glast - D0

_________________________________________________________
DO YOU YAHOO!?
Get your free @yahoo.com address at http://mail.yahoo.com



This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:34:38 MET