[wesnoth-commits] [wesnoth/wesnoth] 464f7c: GUI2: minor refactoring of window construction to ...

GitHub noreply at github.com
Wed Apr 4 06:07:13 UTC 2018


  Branch: refs/heads/master
  Home:   https://github.com/wesnoth/wesnoth
  Commit: 464f7ce6284309ef3bba7999c220051007d6f071
      https://github.com/wesnoth/wesnoth/commit/464f7ce6284309ef3bba7999c220051007d6f071
  Author: Charles Dang <exodia339 at gmail.com>
  Date:   2018-04-04 (Wed, 04 Apr 2018)

  Changed paths:
    M src/gui/core/window_builder.cpp
    M src/gui/core/window_builder.hpp
    M src/gui/dialogs/modal_dialog.cpp
    M src/gui/dialogs/modal_dialog.hpp
    M src/gui/dialogs/modeless_dialog.cpp
    M src/gui/dialogs/modeless_dialog.hpp
    M src/gui/widgets/window.hpp
    M src/scripting/lua_gui2.cpp

  Log Message:
  -----------
  GUI2: minor refactoring of window construction to guard against memory leaks

This ensures the window object is managed by a smart pointer from the moment of its
creation, instead of being passed around as a raw pointer first. If an exception were
thrown during window creation, it would have resulted in a memory leak.

* Moved window_ member assignment to build_window() in both modal_dialog and modeless_dialog.
* Added an assertion after window creation in modeless_dialog.
* Renamed the global build() function to build_window_impl() to avoid confusion with
  builder_widget::build.




More information about the Commits mailing list