Yukihiro Nakadaira wrote:
> When using %! item in 'statusline' option, Vim sometimes shows an error > and sometimes crash. > > vimrc.vim: > set statusline=%!MyStatusLine() > set laststatus=2 > function MyStatusLine() > return "" > endfunction > > $ gvim -u vimrc.vim > Error detected while processing function MyStatusLine: > E121: Undefined variable: MyStatusLine > Error detected while processing function MyStatusLine: > E15: Invalid expression: MyStatusLine > E15: Invalid expression: ~W^Iá3~L (message is random text) > > I am using GTK2 GUI. I saw the error at startup and when using > scrollbar. > > The error can be reproduced by using :redraw! command in MyStatusLine(). > > function MyStatusLine() > redraw! > return "" > endfunction > > > It seems that: > > 1. build_stl_str_hl() > w_p_stl is "%!MyStatusLine()". > > 2. eval_to_string() > Evaluate "MyStatusLine()". > > 3. call_func() > 8021 cc = name[len]; > 8022 name[len] = NUL; > At this time, name == w_p_stl + 2. > Then w_p_stl is changed from "%!MyStatusLine()" to "%!MyStatusLine" > > 4. call_user_func() > In this function, line_breakcheck() is invoked. Then Vim processes > the GUI event loop. If there is an event which is cause of drawing, > Vim draws statusline again. > > 5. build_stl_str_hl() > At this time, w_p_stl is "%!MyStatusLine" by 3. call_func(). > > 6. eval_to_string() > Evaluate "MyStatusLine" > > 7. get_var_tv() > Echo error "E121: Undefined variable: MyStatusLine" > > 8. eval0() > Echo error "E15: Invalid expression: MyStatusLine" > > 9. redraw_custum_statusline() > 5907 if (called_emsg) > 5908 set_string_option_direct((char_u *)"statusline", -1, > 5909 (char_u *)"", OPT_FREE | (*wp->w_p_stl != NUL > 5910 ? OPT_LOCAL : > OPT_GLOBAL), SID_ERROR); > Since error is raised, w_p_stl is freed. > > (back to first statusline drawing) > > 10. eval0() > 3924 if (!aborting()) > 3925 EMSG2(_(e_invexpr2), arg); > Echo error "E15: Invalid expression: ~W^Iá3~L" > At this time, arg == w_p_stl + 2. > And w_p_stl is already freed. I can't reproduce it right away, but your explanation shows what is wrong. I'll add it to the todo list. -- ARTHUR: But if he was dying, he wouldn't bother to carve "Aaaaarrrrrrggghhh". He'd just say it. BROTHER MAYNARD: It's down there carved in stone. GALAHAD: Perhaps he was dictating. "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD /// Bram Moolenaar -- b...@moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ download, build and distribute -- http://www.A-A-P.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org /// --~--~---------~--~----~------------~-------~--~----~ You received this message from the "vim_dev" maillist. For more information, visit http://www.vim.org/maillist.php -~----------~----~----~----~------~----~------~--~---