From 1a6012aff57498a476982f8dd918b5898da6e1f1 Mon Sep 17 00:00:00 2001 From: Gen Date: Tue, 28 Apr 2015 23:06:34 +0800 Subject: Update label.cpp --- scene/gui/label.cpp | 42 +++++++++++++++++++++++++++++++++++++----- 1 file changed, 37 insertions(+), 5 deletions(-) (limited to 'scene/gui') diff --git a/scene/gui/label.cpp b/scene/gui/label.cpp index 6afff81fd..951df155d 100644 --- a/scene/gui/label.cpp +++ b/scene/gui/label.cpp @@ -170,7 +170,7 @@ void Label::_notification(int p_what) { while(to && to->char_pos>=0) { taken+=to->pixel_width; - if (to!=from) { + if (to!=from && to->space_insert) { spaces++; } to=to->next; @@ -212,15 +212,15 @@ void Label::_notification(int p_what) { ERR_PRINT("BUG"); return; } - if (from!=wc) { + if (from!=wc && from->space_insert) { /* spacing */ x_ofs+=space_w; if (can_fill && align==ALIGN_FILL && spaces) { - + x_ofs+=int((size.width-(taken+space_w*spaces))/spaces); } - - + + } @@ -411,6 +411,38 @@ void Label::regenerate_word_cache() { } + }else if ((current < 65||current >90) && (current<97||current>122)) { + if (current_word_size>0) { + + WordCache *wc = memnew( WordCache ); + if (word_cache) { + last->next=wc; + } else { + word_cache=wc; + } + last=wc; + + wc->pixel_width=current_word_size; + wc->char_pos=word_pos; + wc->word_len=i-word_pos; + current_word_size=0; + } + WordCache *wc = memnew( WordCache ); + if (word_cache) { + last->next=wc; + } else { + word_cache=wc; + } + last=wc; + + wc->pixel_width=font->get_char_size(current).width; + wc->char_pos=i; + wc->word_len=1; + wc->space_insert = false; + current_word_size=0; + word_pos = i+1; + line_width+=wc->pixel_width; + total_char_cache++; } else { if (current_word_size==0) { -- cgit v1.2.3-70-g09d2 From dfc59d1e006a0c7c90d48d2781b48000cbd7c88c Mon Sep 17 00:00:00 2001 From: Gen Date: Tue, 28 Apr 2015 23:07:41 +0800 Subject: Update label.h --- scene/gui/label.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'scene/gui') diff --git a/scene/gui/label.h b/scene/gui/label.h index 3b0dddc1a..6c1a5d8c8 100644 --- a/scene/gui/label.h +++ b/scene/gui/label.h @@ -75,8 +75,9 @@ private: int char_pos; // if -1, then newline int word_len; int pixel_width; + bool space_insert; WordCache *next; - WordCache() { char_pos=0; word_len=0; pixel_width=0; next=0; } + WordCache() { char_pos=0; word_len=0; pixel_width=0; next=0; space_insert=true;} }; bool word_cache_dirty; -- cgit v1.2.3-70-g09d2 From ad358562e5ab2c0fdb916acba7cf3118802de21f Mon Sep 17 00:00:00 2001 From: Gen Date: Wed, 29 Apr 2015 16:34:25 +0800 Subject: record the number of space before a words. --- scene/gui/label.cpp | 42 ++++++++++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 16 deletions(-) (limited to 'scene/gui') diff --git a/scene/gui/label.cpp b/scene/gui/label.cpp index 951df155d..e5226ca9b 100644 --- a/scene/gui/label.cpp +++ b/scene/gui/label.cpp @@ -170,8 +170,8 @@ void Label::_notification(int p_what) { while(to && to->char_pos>=0) { taken+=to->pixel_width; - if (to!=from && to->space_insert) { - spaces++; + if (to!=from && to->space_count) { + spaces+=to->space_count; } to=to->next; } @@ -212,9 +212,9 @@ void Label::_notification(int p_what) { ERR_PRINT("BUG"); return; } - if (from!=wc && from->space_insert) { + if (from!=wc && from->space_count) { /* spacing */ - x_ofs+=space_w; + x_ofs+=space_w*from->space_count; if (can_fill && align==ALIGN_FILL && spaces) { x_ofs+=int((size.width-(taken+space_w*spaces))/spaces); @@ -366,6 +366,8 @@ void Label::regenerate_word_cache() { int word_pos=0; int line_width=0; int last_width=0; + int space_count=0; + int space_width=font->get_char_size(' ').width; line_count=1; total_char_cache=0; @@ -383,7 +385,6 @@ void Label::regenerate_word_cache() { if (current<33) { if (current_word_size>0) { - WordCache *wc = memnew( WordCache ); if (word_cache) { last->next=wc; @@ -395,7 +396,9 @@ void Label::regenerate_word_cache() { wc->pixel_width=current_word_size; wc->char_pos=word_pos; wc->word_len=i-word_pos; + wc->space_count = space_count; current_word_size=0; + space_count=0; } @@ -408,10 +411,16 @@ void Label::regenerate_word_cache() { if (i 0) { + space_count++; + line_width+=space_width; + }else { + space_count=0; + } } - }else if ((current < 65||current >90) && (current<97||current>122)) { + }else if ((current < 65||current >90) && (current<97||current>122) && (current<48||current>57)) { if (current_word_size>0) { WordCache *wc = memnew( WordCache ); @@ -425,7 +434,9 @@ void Label::regenerate_word_cache() { wc->pixel_width=current_word_size; wc->char_pos=word_pos; wc->word_len=i-word_pos; + wc->space_count = space_count; current_word_size=0; + space_count=0; } WordCache *wc = memnew( WordCache ); if (word_cache) { @@ -438,16 +449,14 @@ void Label::regenerate_word_cache() { wc->pixel_width=font->get_char_size(current).width; wc->char_pos=i; wc->word_len=1; - wc->space_insert = false; + wc->space_count=space_count; current_word_size=0; - word_pos = i+1; - line_width+=wc->pixel_width; + space_count=0; total_char_cache++; + line_width+=wc->pixel_width; } else { - + // latin characters if (current_word_size==0) { - if (line_width>0) // add a space before the new word if a word existed before - line_width+=font->get_char_size(' ').width; word_pos=i; } @@ -457,9 +466,10 @@ void Label::regenerate_word_cache() { total_char_cache++; } - + + print_line(itos(line_width)); if ((autowrap && line_width>=width && last_widthnext=wc; @@ -467,14 +477,14 @@ void Label::regenerate_word_cache() { word_cache=wc; } last=wc; - + wc->pixel_width=0; wc->char_pos=insert_newline?WordCache::CHAR_NEWLINE:WordCache::CHAR_WRAPLINE; line_width=current_word_size; line_count++; - + } last_width=line_width; -- cgit v1.2.3-70-g09d2 From 6fa342a1b05ad4f4f079ba38925e4980439137c4 Mon Sep 17 00:00:00 2001 From: Gen Date: Wed, 29 Apr 2015 16:34:56 +0800 Subject: record the number of space before a word. --- scene/gui/label.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'scene/gui') diff --git a/scene/gui/label.h b/scene/gui/label.h index 6c1a5d8c8..81e3ab567 100644 --- a/scene/gui/label.h +++ b/scene/gui/label.h @@ -75,9 +75,9 @@ private: int char_pos; // if -1, then newline int word_len; int pixel_width; - bool space_insert; + int space_count; WordCache *next; - WordCache() { char_pos=0; word_len=0; pixel_width=0; next=0; space_insert=true;} + WordCache() { char_pos=0; word_len=0; pixel_width=0; next=0; space_count=0;} }; bool word_cache_dirty; -- cgit v1.2.3-70-g09d2 From 02d672753f18eb3dbae1f5479861b84a1912a5db Mon Sep 17 00:00:00 2001 From: Gen Date: Wed, 29 Apr 2015 23:43:39 +0800 Subject: space is only skipped when autowrap. --- scene/gui/label.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'scene/gui') diff --git a/scene/gui/label.cpp b/scene/gui/label.cpp index e5226ca9b..83b36daff 100644 --- a/scene/gui/label.cpp +++ b/scene/gui/label.cpp @@ -212,7 +212,7 @@ void Label::_notification(int p_what) { ERR_PRINT("BUG"); return; } - if (from!=wc && from->space_count) { + if (from->space_count) { /* spacing */ x_ofs+=space_w*from->space_count; if (can_fill && align==ALIGN_FILL && spaces) { @@ -411,7 +411,7 @@ void Label::regenerate_word_cache() { if (i 0) { + if (line_width > 0 || last==NULL || last->char_pos!=WordCache::CHAR_WRAPLINE) { space_count++; line_width+=space_width; }else { @@ -467,7 +467,6 @@ void Label::regenerate_word_cache() { } - print_line(itos(line_width)); if ((autowrap && line_width>=width && last_widthspace_count = space_count; current_word_size=0; space_count=0; + } + float current_width = font->get_char_size(current).width; + if ((autowrap && line_width+current_width>=width && last_widthnext=wc; + } else { + word_cache=wc; + } + last=wc; + + wc->pixel_width=0; + wc->char_pos=WordCache::CHAR_WRAPLINE; + + line_width=0; + line_count++; + + } WordCache *wc = memnew( WordCache ); if (word_cache) { @@ -446,7 +465,7 @@ void Label::regenerate_word_cache() { } last=wc; - wc->pixel_width=font->get_char_size(current).width; + wc->pixel_width=current_width; wc->char_pos=i; wc->word_len=1; wc->space_count=space_count; -- cgit v1.2.3-70-g09d2 From c322eddffb6ac9abc709cfdc7bdc4466bdb7b80a Mon Sep 17 00:00:00 2001 From: Gen Date: Thu, 30 Apr 2015 12:47:05 +0800 Subject: fixed a autowrap bug when word is too length. --- scene/gui/label.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'scene/gui') diff --git a/scene/gui/label.cpp b/scene/gui/label.cpp index 4069fbb55..38e7435ae 100644 --- a/scene/gui/label.cpp +++ b/scene/gui/label.cpp @@ -99,7 +99,7 @@ void Label::_notification(int p_what) { int chars_total=0; int vbegin=0,vsep=0; - + if (lines_total && lines_total < lines_visible) { @@ -136,10 +136,9 @@ void Label::_notification(int p_what) { if (!wc) return; - + int c = 0; int line=0; while(wc) { - /* handle lines not meant to be drawn quickly */ if (line>line_to) break; @@ -253,7 +252,7 @@ void Label::_notification(int p_what) { } for (int i=0;iword_len;i++) { - + if (visible_chars < 0 || chars_total=width && last_width=width && last && last->char_pos >= 0) || insert_newline) { WordCache *wc = memnew( WordCache ); if (word_cache) { @@ -525,7 +524,7 @@ void Label::regenerate_word_cache() { set_max(line_count); word_cache_dirty=false; - + } -- cgit v1.2.3-70-g09d2 From 0bc5b7a1464b442a9e54cd05c9720d1d53693ee1 Mon Sep 17 00:00:00 2001 From: Gen Date: Fri, 1 May 2015 18:47:34 +0800 Subject: Optimize the code. --- scene/gui/label.cpp | 97 +++++++++++++++++------------------------------------ 1 file changed, 31 insertions(+), 66 deletions(-) (limited to 'scene/gui') diff --git a/scene/gui/label.cpp b/scene/gui/label.cpp index 38e7435ae..1751d335e 100644 --- a/scene/gui/label.cpp +++ b/scene/gui/label.cpp @@ -360,11 +360,10 @@ void Label::regenerate_word_cache() { int width=autowrap?get_size().width:get_longest_line_width(); Ref font = get_font("font"); - + int current_word_size=0; int word_pos=0; int line_width=0; - int last_width=0; int space_count=0; int space_width=font->get_char_size(' ').width; line_count=1; @@ -375,14 +374,16 @@ void Label::regenerate_word_cache() { for (int i=0;i=33 && (current < 65||current >90) && (current<97||current>122) && (current<48||current>57); bool insert_newline=false; - + int char_width; + if (current<33) { - + if (current_word_size>0) { WordCache *wc = memnew( WordCache ); if (word_cache) { @@ -391,16 +392,16 @@ void Label::regenerate_word_cache() { word_cache=wc; } last=wc; - + wc->pixel_width=current_word_size; wc->char_pos=word_pos; wc->word_len=i-word_pos; wc->space_count = space_count; current_word_size=0; space_count=0; - + } - + if (current=='\n') { insert_newline=true; @@ -419,73 +420,39 @@ void Label::regenerate_word_cache() { } - }else if ((current < 65||current >90) && (current<97||current>122) && (current<48||current>57)) { - if (current_word_size>0) { - - WordCache *wc = memnew( WordCache ); - if (word_cache) { - last->next=wc; - } else { - word_cache=wc; - } - last=wc; - - wc->pixel_width=current_word_size; - wc->char_pos=word_pos; - wc->word_len=i-word_pos; - wc->space_count = space_count; - current_word_size=0; - space_count=0; - } - float current_width = font->get_char_size(current).width; - if ((autowrap && line_width+current_width>=width && last_widthnext=wc; - } else { - word_cache=wc; - } - last=wc; - - wc->pixel_width=0; - wc->char_pos=WordCache::CHAR_WRAPLINE; - - line_width=0; - line_count++; - - - } - WordCache *wc = memnew( WordCache ); - if (word_cache) { - last->next=wc; - } else { - word_cache=wc; - } - last=wc; - - wc->pixel_width=current_width; - wc->char_pos=i; - wc->word_len=1; - wc->space_count=space_count; - current_word_size=0; - space_count=0; - total_char_cache++; - line_width+=wc->pixel_width; } else { // latin characters if (current_word_size==0) { word_pos=i; } - int char_width=font->get_char_size(current).width; + char_width=font->get_char_size(current).width; current_word_size+=char_width; line_width+=char_width; total_char_cache++; } - if ((autowrap && line_width>=width && last && last->char_pos >= 0) || insert_newline) { + if ((autowrap && line_width>=width && (last && last->char_pos >= 0 || not_latin)) || insert_newline) { + if (not_latin) { + if (current_word_size>0) { + WordCache *wc = memnew( WordCache ); + if (word_cache) { + last->next=wc; + } else { + word_cache=wc; + } + last=wc; + + wc->pixel_width=current_word_size-char_width; + wc->char_pos=word_pos; + wc->word_len=i-word_pos; + wc->space_count = space_count; + current_word_size=char_width; + space_count=0; + word_pos=i; + } + } WordCache *wc = memnew( WordCache ); if (word_cache) { @@ -500,12 +467,10 @@ void Label::regenerate_word_cache() { line_width=current_word_size; line_count++; - + space_count=0; } - last_width=line_width; - } //total_char_cache -= line_count + 1; // do not count new lines (including the first one) -- cgit v1.2.3-70-g09d2 From 8e7973d660b1f7bc25323b8ef843310f1deb2107 Mon Sep 17 00:00:00 2001 From: Biliogadafr Date: Sat, 2 May 2015 00:03:49 +0300 Subject: Triple click doesn't select line if click was done on different lines. Fix #1727 --- scene/gui/text_edit.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scene/gui') diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index 1e8243216..6cdff20aa 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -1249,7 +1249,7 @@ void TextEdit::_input_event(const InputEvent& p_input_event) { } - if (!mb.doubleclick && (OS::get_singleton()->get_ticks_msec()-last_dblclk)<600) { + if (!mb.doubleclick && (OS::get_singleton()->get_ticks_msec()-last_dblclk)<600 && cursor.line==prev_line) { //tripleclick select line select(cursor.line,0,cursor.line,text[cursor.line].length()); last_dblclk=0; -- cgit v1.2.3-70-g09d2 From f3542ff8381fe7e67f39ff004d98c5b40f331fed Mon Sep 17 00:00:00 2001 From: Ricardo Pérez Date: Mon, 4 May 2015 19:54:17 +0200 Subject: Wrong use of | instead of || --- scene/gui/text_edit.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'scene/gui') diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index 1e8243216..a87d8eea5 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -489,7 +489,7 @@ void TextEdit::_notification(int p_what) { CharType cc = text[i][j]; //ignore any brackets inside a string - if (cc== '"' | cc == '\'') { + if (cc== '"' || cc == '\'') { CharType quotation = cc; do { j++; @@ -560,7 +560,7 @@ void TextEdit::_notification(int p_what) { CharType cc = text[i][j]; //ignore any brackets inside a string - if (cc== '"' | cc == '\'') { + if (cc== '"' || cc == '\'') { CharType quotation = cc; do { j--; -- cgit v1.2.3-70-g09d2 From 2a02d3f96f8fa3ed844a9abf58c0bf4d8023ebcc Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Mon, 4 May 2015 15:06:41 -0300 Subject: fix font import path on windows, closes #1675 --- core/ustring.cpp | 11 ++++++++--- scene/gui/file_dialog.cpp | 1 - tools/editor/editor_import_export.cpp | 1 + tools/editor/io_plugins/editor_font_import_plugin.cpp | 7 +++++-- 4 files changed, 14 insertions(+), 6 deletions(-) (limited to 'scene/gui') diff --git a/core/ustring.cpp b/core/ustring.cpp index ffd22c1f8..5df95ac4c 100644 --- a/core/ustring.cpp +++ b/core/ustring.cpp @@ -3297,8 +3297,11 @@ String String::path_to_file(const String& p_path) const { String src=this->replace("\\","/").get_base_dir(); String dst=p_path.replace("\\","/").get_base_dir(); - - return src.path_to(dst)+p_path.get_file(); + String rel = src.path_to(dst); + if (rel==dst) // failed + return p_path; + else + return rel+p_path.get_file(); } String String::path_to(const String& p_path) const { @@ -3333,7 +3336,9 @@ String String::path_to(const String& p_path) const { String src_begin=src.get_slice("/",0); String dst_begin=dst.get_slice("/",0); - ERR_FAIL_COND_V(src_begin!=dst_begin,p_path); //return dst absolute path + if (src_begin!=dst_begin) + return p_path; //impossible to do this + base=src_begin; src=src.substr(src_begin.length(),src.length()); dst=dst.substr(dst_begin.length(),dst.length()); diff --git a/scene/gui/file_dialog.cpp b/scene/gui/file_dialog.cpp index 50ce657d2..13cf87ac2 100644 --- a/scene/gui/file_dialog.cpp +++ b/scene/gui/file_dialog.cpp @@ -92,7 +92,6 @@ void FileDialog::_file_entered(const String& p_file) { } void FileDialog::_save_confirm_pressed() { - String f=dir_access->get_current_dir().plus_file(file->get_text()); emit_signal("file_selected",f); hide(); diff --git a/tools/editor/editor_import_export.cpp b/tools/editor/editor_import_export.cpp index d76009a72..4e6435b22 100644 --- a/tools/editor/editor_import_export.cpp +++ b/tools/editor/editor_import_export.cpp @@ -47,6 +47,7 @@ String EditorImportPlugin::validate_source_path(const String& p_path) { String rp = Globals::get_singleton()->get_resource_path(); if (!rp.ends_with("/")) rp+="/"; + return rp.path_to_file(gp); } diff --git a/tools/editor/io_plugins/editor_font_import_plugin.cpp b/tools/editor/io_plugins/editor_font_import_plugin.cpp index b0ff6f6e7..375333ddf 100644 --- a/tools/editor/io_plugins/editor_font_import_plugin.cpp +++ b/tools/editor/io_plugins/editor_font_import_plugin.cpp @@ -406,7 +406,10 @@ class EditorFontImportDialog : public ConfirmationDialog { imd->set_option(opt,v); } - imd->add_source(EditorImportPlugin::validate_source_path(source->get_line_edit()->get_text())); + String src_path = EditorImportPlugin::validate_source_path(source->get_line_edit()->get_text()); + //print_line("pre src path "+source->get_line_edit()->get_text()); + //print_line("src path "+src_path); + imd->add_source(src_path); imd->set_option("font/size",font_size->get_val()); return imd; @@ -1018,7 +1021,7 @@ Ref EditorFontImportPlugin::generate_font(const Refbitmap.rows; int p = slot->bitmap.pitch; - print_line("W: "+itos(w)+" P: "+itos(slot->bitmap.pitch)); + //print_line("W: "+itos(w)+" P: "+itos(slot->bitmap.pitch)); if (font_mode==_EditorFontImportOptions::FONT_DISTANCE_FIELD) { -- cgit v1.2.3-70-g09d2 From 74b0e0c296ac438df2f0826482310e788d0ba898 Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Tue, 5 May 2015 00:17:22 -0300 Subject: fix crash in editor when using alt+arrows to indent, thanks adolson and romulox_x --- scene/gui/text_edit.cpp | 3 +++ tools/editor/plugins/script_editor_plugin.cpp | 24 ++++++++++++------------ 2 files changed, 15 insertions(+), 12 deletions(-) (limited to 'scene/gui') diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index 75174a85d..681c33652 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -3494,6 +3494,9 @@ void TextEdit::set_line(int line, String new_text) return; _remove_text(line, 0, line, text[line].length()); _insert_text(line, 0, new_text); + if (cursor.line==line) { + cursor.column=MIN(cursor.column,new_text.length()); + } } void TextEdit::insert_at(const String &p_text, int at) diff --git a/tools/editor/plugins/script_editor_plugin.cpp b/tools/editor/plugins/script_editor_plugin.cpp index e6e311cfa..edc5d460e 100644 --- a/tools/editor/plugins/script_editor_plugin.cpp +++ b/tools/editor/plugins/script_editor_plugin.cpp @@ -816,11 +816,11 @@ void ScriptEditor::_menu_option(int p_option) { if (scr.is_null()) return; - int begin, end; - begin = tx->get_selection_from_line(); + if (tx->is_selection_active()) { - end = tx->get_selection_to_line(); + int begin = tx->get_selection_from_line(); + int end = tx->get_selection_to_line(); for (int i = begin; i <= end; i++) { String line_text = tx->get_line(i); @@ -840,7 +840,7 @@ void ScriptEditor::_menu_option(int p_option) { } else { - begin = tx->cursor_get_line(); + int begin = tx->cursor_get_line(); String line_text = tx->get_line(begin); // begins with tab if (line_text.begins_with("\t")) @@ -866,11 +866,10 @@ void ScriptEditor::_menu_option(int p_option) { if (scr.is_null()) return; - int begin, end; - begin = tx->get_selection_from_line(); if (tx->is_selection_active()) { - end = tx->get_selection_to_line(); + int begin = tx->get_selection_from_line(); + int end = tx->get_selection_to_line(); for (int i = begin; i <= end; i++) { String line_text = tx->get_line(i); @@ -880,7 +879,7 @@ void ScriptEditor::_menu_option(int p_option) { } else { - begin = tx->cursor_get_line(); + int begin = tx->cursor_get_line(); String line_text = tx->get_line(begin); line_text = '\t' + line_text; tx->set_line(begin, line_text); @@ -913,11 +912,12 @@ void ScriptEditor::_menu_option(int p_option) { if (scr.is_null()) return; - int begin, end; - begin = tx->get_selection_from_line(); + + if (tx->is_selection_active()) { - end = tx->get_selection_to_line(); + int begin = tx->get_selection_from_line(); + int end = tx->get_selection_to_line(); for (int i = begin; i <= end; i++) { String line_text = tx->get_line(i); @@ -931,7 +931,7 @@ void ScriptEditor::_menu_option(int p_option) { } else { - begin = tx->cursor_get_line(); + int begin = tx->cursor_get_line(); String line_text = tx->get_line(begin); if (line_text.begins_with("#")) -- cgit v1.2.3-70-g09d2 From 36932a006541b9c3614fbceca331b2dae38a011f Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Tue, 5 May 2015 00:37:06 -0300 Subject: avoid crash on some cases of richtextlabel fill, but odd behavior persists, #1803 --- scene/gui/rich_text_label.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'scene/gui') diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp index 4be53839b..3489b0259 100644 --- a/scene/gui/rich_text_label.cpp +++ b/scene/gui/rich_text_label.cpp @@ -268,7 +268,9 @@ if (m_height > line_height) {\ } if (found_space) { - fw+=l.offset_caches[line]/l.space_caches[line]; + int ln = MIN(l.offset_caches.size()-1,line); + + fw+=l.offset_caches[ln]/l.space_caches[ln]; } } -- cgit v1.2.3-70-g09d2