From 8c9dff945fd71db6a952f6f825aed8dd8f7f4159 Mon Sep 17 00:00:00 2001 From: Alexander Malmberg Date: Sun, 9 Feb 2003 13:53:35 +0000 Subject: [PATCH] Make the main typesetting method reentrant. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@15913 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 6 ++++++ Source/GSHorizontalTypesetter.m | 19 ++++++++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index b0bdbbf31..edc665439 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2003-02-09 14:48 Alexander Malmberg + + * Source/GSHorizontalTypesetter.m: Make the main method reentrant + by having it allocate a temporary instance to handle calls when + it is already in use. + 2003-02-09 Fred Kiefer * Source/NSColorList.m diff --git a/Source/GSHorizontalTypesetter.m b/Source/GSHorizontalTypesetter.m index 5c2bbbe5d..3942c9191 100644 --- a/Source/GSHorizontalTypesetter.m +++ b/Source/GSHorizontalTypesetter.m @@ -62,6 +62,7 @@ cache fairly aggressively without having to worry about memory consumption. free(cache); cache = NULL; } + DESTROY(lock); [super dealloc]; } @@ -896,7 +897,23 @@ restart: int ret = 0; BOOL newParagraph; - [lock lock]; + if (![lock tryLock]) + { + /* Since we might be the shared system typesetter, we must be + reentrant. Thus, if we are already in use and can't lock our lock, + we create a new instance and let it handle the call. */ + GSHorizontalTypesetter *temp; + + temp = [[isa alloc] init]; + ret = [temp layoutGlyphsInLayoutManager: layoutManager + inTextContainer: textContainer + startingAtGlyphIndex: glyphIndex + previousLineFragmentRect: previousLineFragRect + nextGlyphIndex: nextGlyphIndex + numberOfLineFragments: howMany]; + DESTROY(temp); + return ret; + } NS_DURING curLayoutManager = layoutManager;