Multilineeditbox: Advance cursor to the next line when enter is hit at the end of the string being edited

Bug #1699778 reported by GunChleoc
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
widelands
Fix Released
Low
Unassigned

Bug Description

Editor: The map option window doesn´t handle the Enter key well while editing the map´s Description. The cursor seems to remain in the old space (not moving down a line) but when typing another letter it is entered in the new line, where the cursor now appears. Internally, everything is as expected; the cursor position just isn´t drawn properly.

Tags: ui

Related branches

Revision history for this message
Jukka Pakarinen (flegu) wrote :

When accessing to the map option, Valgrind detects multiple "Conditional jump or move depends on uninitialised value(s)" cases. I think if there is uninitialized values they may cause unexpected actiions.

Revision history for this message
Jukka Pakarinen (flegu) wrote :

After the access to the window, I set cursor to the Description and pressed enter 10 times and then one space. Scrollbar popped on and Valgrind detects quite a lot "Conditional jump or move depends on uninitialised value(s)" cases. The below I added just a few of those.

==8357== Conditional jump or move depends on uninitialised value(s)
==8357== at 0xAE9153: RenderTarget::clip(Rect<float>&) const (rendertarget.cc:373)
==8357== by 0xAE8AD5: RenderTarget::tile(Rect<int> const&, Image const*, Vector2<int> const&, BlendMode) (rendertarget.cc:235)
==8357== by 0xD1A982: UI::Scrollbar::draw_button(RenderTarget&, UI::Scrollbar::Area, Rect<int> const&) (scrollbar.cc:236)
==8357== by 0xD1C3AA: UI::Scrollbar::draw(RenderTarget&) (scrollbar.cc:351)
==8357== by 0xD15365: UI::Panel::do_draw_inner(RenderTarget&) (panel.cc:725)

==8357== Conditional jump or move depends on uninitialised value(s)
==8357== at 0xAE8BCB: RenderTarget::tile(Rect<int> const&, Image const*, Vector2<int> const&, BlendMode) (rendertarget.cc:264)
==8357== by 0xD1A982: UI::Scrollbar::draw_button(RenderTarget&, UI::Scrollbar::Area, Rect<int> const&) (scrollbar.cc:236)
==8357== by 0xD1C3AA: UI::Scrollbar::draw(RenderTarget&) (scrollbar.cc:351)
==8357== by 0xD15365: UI::Panel::do_draw_inner(RenderTarget&) (panel.cc:725)

==8357== Conditional jump or move depends on uninitialised value(s)
==8357== at 0xAE91D5: RenderTarget::clip(Rect<float>&) const (rendertarget.cc:380)
==8357== by 0xAE8427: RenderTarget::brighten_rect(Rect<int> const&, int) (rendertarget.cc:136)
==8357== by 0xD1AD63: UI::Scrollbar::draw_button(RenderTarget&, UI::Scrollbar::Area, Rect<int> const&) (scrollbar.cc:262)
==8357== by 0xD1C3AA: UI::Scrollbar::draw(RenderTarget&) (scrollbar.cc:351)
==8357== by 0xD15365: UI::Panel::do_draw_inner(RenderTarget&) (panel.cc:725)

==8357== Conditional jump or move depends on uninitialised value(s)
==8357== at 0xAE9296: RenderTarget::clip(Rect<float>&) const (rendertarget.cc:389)
==8357== by 0xAE8427: RenderTarget::brighten_rect(Rect<int> const&, int) (rendertarget.cc:136)
==8357== by 0xD1AE2C: UI::Scrollbar::draw_button(RenderTarget&, UI::Scrollbar::Area, Rect<int> const&) (scrollbar.cc:264)
==8357== by 0xD1C3AA: UI::Scrollbar::draw(RenderTarget&) (scrollbar.cc:351)
==8357== by 0xD15365: UI::Panel::do_draw_inner(RenderTarget&) (panel.cc:725)

Then I moved cursor back to the first line and pressed enter few times. Instead of seeing new lines the cursor moved forward.

Revision history for this message
Jukka Pakarinen (flegu) wrote :

With the following change all those "Conditional jump or move depends on uninitialised value(s)" mesages are gone.

=== modified file 'src/ui_basic/multilineeditbox.cc'
--- src/ui_basic/multilineeditbox.cc 2017-09-20 21:27:25 +0000
+++ src/ui_basic/multilineeditbox.cc 2017-12-03 16:32:02 +0000
@@ -105,6 +105,7 @@
    : scrollbar(&o, o.get_w() - Scrollbar::kSize, 0, Scrollbar::kSize, o.get_h(), button_background),
      background(init_background),
      cursor_pos(0),
+ lineheight(1),
      maxbytes(std::min(g_gr->max_texture_size() / UI_FONT_SIZE_SMALL, 0xffff)),
      ww_valid(false),
      owner(o) {

The original problem is still there. I'm not sure is the initial value ok?

Revision history for this message
Jukka Pakarinen (flegu) wrote :

I found where the problem is and made a branch which fixes it.

Revision history for this message
GunChleoc (gunchleoc) wrote :

Great, can you make a merge request?

GunChleoc (gunchleoc)
Changed in widelands:
status: New → Fix Committed
Revision history for this message
GunChleoc (gunchleoc) wrote :

Fixed in build20-rc1

Changed in widelands:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.