Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid deadlock caused by Cocoa code taking the ROOT lock #1573

Merged
merged 1 commit into from
Feb 2, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 23 additions & 5 deletions graf2d/cocoa/src/QuartzWindow.mm
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@
#include "TSystem.h"
#include "TGCocoa.h"
#include "TROOT.h"
#include "TGTextView.h"
#include "TGView.h"
#include "TGCanvas.h"


namespace ROOT {
Expand Down Expand Up @@ -896,7 +899,10 @@ bool ViewIsTextView(unsigned viewID)
const TGWindow * const window = gClient->GetWindowById(viewID);
if (!window)
return false;
return window->InheritsFrom("TGTextView");
// This code used to use TObject::InheritsFrom, however since this is
// run under the AppKit, we can not call core/meta functions, otherwise
// we will run into deadlocks.
return dynamic_cast<const TGTextView*>(window);
}

//______________________________________________________________________________
Expand All @@ -916,7 +922,10 @@ bool ViewIsTextViewFrame(NSView<X11Window> *view, bool checkParent)
if (!window)
return false;

if (!window->InheritsFrom("TGViewFrame"))
// This code used to use TObject::InheritsFrom, however since this is
// run under the AppKit, we can not call core/meta functions, otherwise
// we will run into deadlocks.
if (!dynamic_cast<const TGViewFrame*>(window))
return false;

if (!checkParent)
Expand All @@ -934,7 +943,10 @@ bool ViewIsHtmlView(unsigned viewID)
const TGWindow * const window = gClient->GetWindowById(viewID);
if (!window)
return false;
return window->InheritsFrom("TGHtml");
// This code used to use TObject::InheritsFrom, however since this is
// run under the AppKit, we can not call core/meta functions, otherwise
// we will run into deadlocks.
return window->TestBit(TGWindow::kIsHtmlView);
}

//______________________________________________________________________________
Expand All @@ -955,7 +967,10 @@ bool ViewIsHtmlViewFrame(NSView<X11Window> *view, bool checkParent)
if (!window)
return false;

if (!window->InheritsFrom("TGViewFrame"))
// This code used to use TObject::InheritsFrom, however since this is
// run under the AppKit, we can not call core/meta functions, otherwise
// we will run into deadlocks.
if (!dynamic_cast<const TGViewFrame*>(window))
return false;

if (!checkParent)
Expand Down Expand Up @@ -2705,7 +2720,10 @@ - (void) drawRect : (NSRect) dirtyRect
if (self.fQuartzWindow.fShapeCombineMask)
X11::ClipToShapeMask(self, fContext);

if (window->InheritsFrom("TGContainer"))//It always has an ExposureMask.
// This code used to use TObject::InheritsFrom, however since this is
// run under the AppKit, we can not call core/meta functions, otherwise
// we will run into deadlocks.
if (dynamic_cast<const TGContainer*>(window))//It always has an ExposureMask.
vx->GetEventTranslator()->GenerateExposeEvent(self, [self visibleRect]);

if (fEventMask & kExposureMask) {
Expand Down
4 changes: 4 additions & 0 deletions gui/gui/inc/TGWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ friend class TGClient;
kEditDisableKeyEnable = BIT(8) // window can handle keyboard events
};

enum EStatusBits {
kIsHtmlView = BIT(14)
};

TGWindow(const TGWindow *p = 0, Int_t x = 0, Int_t y = 0,
UInt_t w = 0, UInt_t h = 0, UInt_t border = 0,
Int_t depth = 0,
Expand Down
2 changes: 2 additions & 0 deletions gui/guihtml/src/TGHtml.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ int HtmlDepth = 0;

TGHtml::TGHtml(const TGWindow *p, int w, int h, int id) : TGView(p, w, h, id)
{
SetBit(kIsHtmlView);

int i;

fExiting = 0;
Expand Down