src/osx/native_window.mm in reflexion-0.1.14 vs src/osx/native_window.mm in reflexion-0.1.15

- old
+ new

@@ -41,11 +41,11 @@ view = nil; timer = nil; [self setDelegate: self]; [self setupContentView]; - [self startTimer: 60]; + [self startTimer]; return self; } - (void) dealloc @@ -64,11 +64,12 @@ Reflex::WindowData& data = Window_get_data(window); if (data.native) Reflex::invalid_state_error(__FILE__, __LINE__); - data.native = [self retain]; + // ruby value references native window weakly. + data.native = self; // Reflex::Window is not constructed completely, // so can not call ClassWrapper::retain(). window->Xot::template RefCountable<>::retain(); @@ -84,25 +85,18 @@ pwindow->retain(); ptr_for_rebind->Xot::template RefCountable<>::release(); ptr_for_rebind = NULL; } - - assert(pwindow && !ptr_for_rebind); } - (void) unbind { [self rebind]; if (!pwindow) return; - Reflex::WindowData& data = Window_get_data(pwindow); - if (data.native) - { - [data.native release]; - data.native = nil; - } + Window_get_data(pwindow).native = nil; pwindow->release(); pwindow = NULL; } @@ -118,10 +112,15 @@ rect.origin.x = rect.origin.y = 0; view = [[OpenGLView alloc] initWithFrame: rect]; [self setContentView: view]; } + - (void) startTimer + { + [self startTimer: 60]; + } + - (void) startTimer: (int) fps { [self stopTimer]; if (fps <= 0) return; @@ -181,25 +180,10 @@ win->self->prev_time_draw = now; win->self->prev_fps = fps; Reflex::DrawEvent e(dt, fps); - - e.painter = win->painter(); - if (!e.painter) - Xot::invalid_state_error(__FILE__, __LINE__); - - Rays::Bounds frame = win->frame(); - e.bounds.reset(0, 0, frame.width, frame.height); - - e.painter->begin(); - e.painter->clear(); - - win->on_draw(&e); - if (!e.is_blocked()) - Reflex::View_draw_tree(win->root(), e, 0, frame.move_to(0)); - - e.painter->end(); + Window_call_draw_event(win, &e); } - (BOOL) windowShouldClose: (id) sender { Reflex::Window* win = self.window;