Saturday, May 11, 2013

Error Highlighting – Program Load Fix

Displaying the error messages on the status bar at the bottom of the window has proven to be difficult.  While working on getting these changes to work, a problem was discovered when loading a program with errors - the errors were not display just like the problem when the application first starts.

The mechanism added to correct that initial start up problem did not work for this case because the cursor valid flag, which is initially reset, is set the first time the cursor is moved.  When a program is loaded, the text of the program loaded in set in the edit box's document using the setPlainText() function.  Apparently while the text is being set, the cursor is again invalid preventing the errors from being highlighted.

The cursor valid flag mechanism was utilized to correct this problem.  The setPlainText() function of the base QPlainTextEdit class was reimplemented in the edit box class, which resets the cursor valid flag and calls the base class function.  Once the text is set, a cursor changed signal gets emitted and the cursor valid flag is once again set triggering the errors to be updated.

[commit 58b0f23680]