提交 6fff7f0c 编写于 作者: W wangpeiqiang

window: solve crash problem.

Set destroy window in single function, to make window destroyed in message cycle thread.
上级 03940be6
......@@ -298,11 +298,17 @@ void Platform::user_event_function(const SDL_Event &event) {
window_manager_->remove_task(param->taskId);
}
} else if (event_type == USER_DESTROY_WINDOW) {
{
auto w = window_manager_->find_window_for_task(param->taskId);
if (w) {
w->destroy_window();
}
}
window_manager_->erase_task(param->taskId);
auto it = tasks_.find(param->taskId);
if (it != tasks_.end()) {
windows_.erase(it->second);
tasks_.erase(it);
windows_.erase(it->second);
tasks_.erase(it);
}
}
delete param;
......
......@@ -152,8 +152,13 @@ Window::Window(const std::shared_ptr<Renderer> &renderer,
SDL_ShowWindow(window_);
}
Window::~Window() {
if (window_) SDL_DestroyWindow(window_);
Window::~Window() {}
void Window::destroy_window() {
if (window_) {
SDL_DestroyWindow(window_);
window_ = NULL;
}
}
bool Window::title_event_filter(int x, int y) {
......
......@@ -90,6 +90,7 @@ class Window : public std::enable_shared_from_this<Window>, public wm::Window {
inline std::uint32_t get_property() {
return visible_property;
}
void destroy_window() override;
private:
static SDL_HitTestResult on_window_hit(SDL_Window *window, const SDL_Point *pt, void *data);
......
......@@ -65,6 +65,7 @@ class Window {
std::string title() const;
virtual bool checkResizeable() { return resizing_; }
virtual void setResizing(bool resizing) { resizing_ = resizing; }
virtual void destroy_window() {}
protected:
graphics::Rect last_frame_;
bool resizing_{false};
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册