Index: src/OFExceptions.h ================================================================== --- src/OFExceptions.h +++ src/OFExceptions.h @@ -1170,10 +1170,16 @@ * \brief An exception indicating that unlocking a mutex failed. */ @interface OFMutexUnlockFailedException: OFException @end +/** + * \brief An exception indicating that a mutex is still locked. + */ +@interface OFMutexLockedException: OFException +@end + /** * \brief An exception indicating that the hash has already been calculated. */ @interface OFHashAlreadyCalculatedException: OFException @end Index: src/OFExceptions.m ================================================================== --- src/OFExceptions.m +++ src/OFExceptions.m @@ -1674,11 +1674,11 @@ if (description != nil) return description; description = [[OFString alloc] initWithFormat: @"Deallocation of a thread of type %@ was tried, even though it " - @"was still running", inClass]; + @"was still running!", inClass]; return description; } @end @@ -1687,11 +1687,11 @@ { if (description != nil) return description; description = [[OFString alloc] initWithFormat: - @"A mutex could not be locked in class %@", inClass]; + @"A mutex of class %@ could not be locked!", inClass]; return description; } @end @@ -1700,11 +1700,25 @@ { if (description != nil) return description; description = [[OFString alloc] initWithFormat: - @"A mutex could not be unlocked in class %@", inClass]; + @"A mutex of class %@ could not be unlocked!", inClass]; + + return description; +} +@end + +@implementation OFMutexLockedException +- (OFString*)description +{ + if (description != nil) + return description; + + description = [[OFString alloc] initWithFormat: + @"Deallocation of a mutex of type %@ was tried, even though it " + @"was still locked!", inClass]; return description; } @end Index: src/OFThread.m ================================================================== --- src/OFThread.m +++ src/OFThread.m @@ -367,10 +367,11 @@ } - (void)dealloc { if (initialized) - of_mutex_free(&mutex); + if (!of_mutex_free(&mutex)) + @throw [OFMutexLockedException newWithClass: isa]; [super dealloc]; } @end