Hi,
I am experiencing a crash in pollEvent() on Mac OSX using SFML 2.5.1.
When I create the window using Window::create(VideoMode mode, String title), there are no crashes.
However, for my application I have to give SFML an NSView * that is already created, so I use Window::create(WindowHandle handle).
Traceback is pollEvent()->popEvent()->processEvents()->drainThreadPool->destroyPool()->[pool drain];
Here is the code where the window is opened:
void ZivixGraphicsMacVST::OpenWindow(void * parent) {
m_cocoaGraphics = (ZIVIXGRAPHICS_COCOA *) [[ZIVIXGRAPHICS_COCOA alloc] initWithZivixGraphics: this];
setWindow(m_cocoaGraphics);
if (parent) {
[(NSView *) parent addSubView: (ZIVIXGRAPHICS_COCOA *) m_cocoaGraphics];
}
}
setWindow():
void setWindow(void * w) {
m_Window = new sf::RenderWindow(w, m_sfmlSettings);
m_Window->setFramerateLimit(100);
}
And the update function up to the point of the crash:
sf::Vector2i mpos = sf::Mouse::getPosition(*m_Window);
mouseMove(mpos.x, mpos.y);
sf::Event event;
while (getWindow()->pollEvent(event)) { //<<<< CRASH
switch (event.type) {
Other code that may be useful in diagnosing the problem:
@interface ZIVIXGRAPHICS_COCOA : NSView {
NSTimer * m_Timer;
@public
ZivixGraphics::ZivixGraphicsMac * m_GFX;
}
- (id) init;
- (id) initWithZivixGraphics: (ZivixGraphics::ZivixGraphicsMac *) gfx;
- (void) onTimer: (NSTimer *) pTimer;
@end
@implementation ZIVIXGRAPHICS_COCOA
- (id) init {
m_GFX = 0;
return self;
}
- (id) initWithZivixGraphics:(ZivixGraphics::ZivixGraphicsMac *)gfx {
m_GFX = gfx;
NSRect r;
r.origin.x = 0.0f;
r.origin.y = 0.0f;
r.size.width = (float) gfx->getWidth();
r.size.height = (float) gfx->getHeight();
self = [super initWithFrame:r];
// init timer
double sec = 1/100;
m_Timer = [NSTimer timerWithTimeInterval:sec target:self selector:@selector(onTimer:) userInfo:nil repeats:YES];
[[NSRunLoop currentRunLoop] addTimer: m_Timer forMode: (NSString*) kCFRunLoopCommonModes];
return self;
}
- (void) onTimer: (NSTimer*) pTimer {
if (pTimer == m_Timer)
m_GFX->update();
}
@end
Any suggestions?
Thank you,
Jon