Fix potential buffer overflow if `length` (now `length_of_initial_text`)
is less than the `strlen` computed length of text.
Rename variables to clarify usage.
Eliminate the unnecessary use of `strlen`.
Add macro cf_assert ("control flow" assert) to hint to gcc that certain
conditions are impossible. Use it to avoid generating range checks for
situations that never happen. If the event did happen, the only
consequence would be truncated UI text, rather than a correctness
problem.
Rather than use an inline wrapper and rely on the compiler optimizer to
redirect gr_set_current_canvas(nullptr) to gr_set_default_canvas,
rewrite all relevant calls directly in the source.
git grep -l 'gr_set_current_canvas' | xargs sed -i -e 's:gr_set_current_canvas(\s*NULL\|nullptr\s*);:gr_set_default_canvas();:'
All supported compilers have an acceptable <type_traits>. Commit
4cb3d46148 ("Move <type_traits> test to Cxx11RequiredFeature") made
<type_traits> support mandatory in August and no one has objected.
Remove the indirection and use namespace std directly for type_traits
members.
For switch cases where existing comments or code flow logic obviously
intended to fall through, add a gcc-7 /*-fallthrough*/ comment to
silence warnings about this. Some cases which are less obvious are not
converted, so the code does not yet compile clean with
-Wimplicit-fallthrough.
Reported-by: parkerlreed <https://github.com/dxx-rebirth/dxx-rebirth/issues/338>
Commit 1c8ad24 removed all reads of `wind`, but did not remove its
assignment or declaration. This breaks the build with gcc due to
-Wunused-but-set-variable.
Fixes: 1c8ad24da3 ("Check for window_event_result::deleted for ui_get_filename polling loop")
Commit 917f079 removed all reads of `wind`, but did not remove its
assignment or declaration. This breaks the build with gcc due to
-Wunused-but-set-variable.
Fixes: 917f079f02 ("Check for window_event_result::deleted in ui_dialog_do_gadgets")
The functions med-mark-start and med-mark-end don't exist - that's fine, still read the rest of the menus, so it can actually properly 'hide' the help menu after it's clicked on.
If a game was playing, continue playing. If it was in the main menu, return to the main menu. (If all files are put in place the editor can load again.)
As the UI_DIALOG client is now responsible for freeing all gadgets (via unique_ptr's), this function now causes issues where it attempts to access freed gadgets (resulting in std::runtime_error("unknown gadget kind") exception when closing the AI Properties dialog on my Macbook, for example). Removing the offending function fixes the issue.
In particular, window_event_result::deleted so the event system doesn't have to rely on the somewhat problematic window_exists. If a gadget is manipulated, it still returns at least window_event_result::handled so all the other gadgets in all the other windows don't have to be checked (that weren't already checked).
Conflicts:
common/arch/sdl/window.cpp - Remove unused EVENT_WINDOW_CLOSED and w_callback local var
common/ui/dialog.cpp - Remove unused EVENT_WINDOW_CLOSED
Allow dcx::UI_DIALOG struct to be subclassed step 3. This step adds the destructor and makes sure the dialog is only deleted within the main dialog handler if the specific handler didn't return window_event_result::deleted.
Replace delete dcx::window kludge with a better solution: instead of requiring every handler to delete the window, add a window_event_result::deleted, which gets returned if the window was deleted by the handler, so window_close knows not to attempt to delete it again.
Allow dcx::UI_DIALOG struct to be subclassed step 1. This step renames and reconfigures untyped_ui_dialog_create in dialog.cpp to be the main constructor. Also adds a template constructor that allows an event handler that takes a subclass of UI_DIALOG.
Allow dcx::window struct to be subclassed step 3. This step adds the window destructor and both requires and implements the window to be deleted by the event handler/client in all cases.