Artifact ef11711dc617ab2b66c75f6c6a285189e9eeaa644ef242d0135ef6b696bce33e:
- File
QtCore/QtChildEvent.mm
— part of check-in
[6de2243af6]
at
2017-04-09 12:20:40
on branch trunk
— Ownership fix for QtChildEvent
When created using initWithType:child:, it should take ownership of the
underlying QChildEvent. (user: js, size: 915) [annotate] [blame] [check-ins using]
#import "QtChildEvent.h" #import "QtObject.h" @implementation QtChildEvent - initWithQEvent: (QEvent*)event { OF_INVALID_INIT_METHOD } - initWithQChildEvent: (QChildEvent*)event { return [super initWithQEvent: event]; } - initWithType: (QChildEvent::Type)type child: (QtObject*)child { try { self = [self initWithQChildEvent: new QChildEvent(type, [child qObject])]; [self takeOwnership]; return self; } catch (const std::bad_alloc &e) { self = [super initWithQEvent: NULL]; [self release]; throw; } } - (QChildEvent*)qChildEvent { return dynamic_cast<QChildEvent*>(_qEvent); } - (bool)isAdded { return [self qChildEvent]->added(); } - (QtObject*)child { return [[[QtObject alloc] initWithQObject: [self qChildEvent]->child()] autorelease]; } - (bool)isPolished { return [self qChildEvent]->polished(); } - (bool)isRemoved { return [self qChildEvent]->removed(); } @end