Skip to content

Commit

Permalink
Display : Fix shutdown crashes caused by Python slots
Browse files Browse the repository at this point in the history
  • Loading branch information
johnhaddon committed Mar 28, 2024
1 parent 42c5866 commit 0a9b600
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
1 change: 1 addition & 0 deletions Changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Fixes
- GafferTest, GafferImageTest : Fixed import of these modules if the `Gaffer` module had not been imported previously.
- SceneAlgo : Fixed potential shutdown crashes caused by the adaptor registry [^1].
- Dispatcher : Fixed shutdown crashes caused by Python slots connected to the dispatch signals [^1].
- Display : Fixed shutdown crashes caused by Python slots connected to `driverCreatedSignal()` and `imageReceivedSignal()` [^1].

1.4.0.0b5 (relative to 1.4.0.0b4)
=========
Expand Down
12 changes: 12 additions & 0 deletions python/GafferImageTest/DisplayTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,18 @@ def testSetDriver( self ) :
driver.close()
self.assertTrue( display.driverClosed() )

def testSignalShutdownCrash( self ) :

subprocess.check_call( [
Gaffer.executablePath(), "env", "python", "-c",
"""import GafferImage; GafferImage.Display.driverCreatedSignal().connect( lambda d, p : None, scoped = False )"""
] )

subprocess.check_call( [
Gaffer.executablePath(), "env", "python", "-c",
"""import GafferImage; GafferImage.Display.imageReceivedSignal().connect( lambda p : None, scoped = False )"""
] )

def __testTransferImage( self, fileName ) :

imageReader = GafferImage.ImageReader()
Expand Down
8 changes: 4 additions & 4 deletions src/GafferImage/Display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -466,14 +466,14 @@ void Display::affects( const Gaffer::Plug *input, AffectedPlugsContainer &output

Display::DriverCreatedSignal &Display::driverCreatedSignal()
{
static DriverCreatedSignal s;
return s;
static DriverCreatedSignal *g_driverCreatedSignal = new DriverCreatedSignal;
return *g_driverCreatedSignal;
}

Node::UnaryPlugSignal &Display::imageReceivedSignal()
{
static UnaryPlugSignal s;
return s;
static UnaryPlugSignal *g_imageReceivedSignal = new UnaryPlugSignal;
return *g_imageReceivedSignal;
}

void Display::setDriver( IECoreImage::DisplayDriverPtr driver, bool copy )
Expand Down

0 comments on commit 0a9b600

Please sign in to comment.