lyx_mirror/src/frontends
Abdelrazak Younes 4d5ae916ad Fix bug 3293 by Bernhard Roider:
This changes the semantics of isOK() and operator(), comments from Bernhard below:

With the old version of lyxlex it was _impossible_ to check whether reading an integer, float, ... succeeded or not. The current solution to check for is.bad() in some cases and in other cases use is.good() does not give the desired information. Moreover the result of is.bad() depends on the stl implementation and behaves different for linux and windows.

the bug was introduced by the patch that fixed the bug that crashed lyx when "inset-insert ert" was executed from the command buffer.
The lexer has the method isOK() which reflects the status of the stream is.
The operators void* and ! are not really well defined (they depend on the value of is.bad()). What is missing is a test if the last reading operation was successful and thus the returned value is valid.
That's what i implemented in this patch.

The new rule for using the lexer:

if you want to know if the lexer still has data to read (either from the stream or from the pushed token) then use "lex.isOK()".
If you want to test if the last reading operation was successful then use eg. "if (lex) {...}" or unsuccessful then use eg. "if (!lex) {...}"

an example:

int readParam(LyxLex &lex) {

    int param = 1; // default value
    if (lex.isOK()) { // the lexer has data to read
        int p;    // temporary variable
        lex >> p;
        if (lex) param = p; // only use the input if the reading operation was successful
    }
    return param;
}




git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@17569 a592a061-630c-0410-9148-cb99ea01b6c8
2007-03-26 13:43:49 +00:00
..
controllers Fix bug 3293 by Bernhard Roider: 2007-03-26 13:43:49 +00:00
qt4 compile fix 2007-03-26 07:38:33 +00:00
Alert_pimpl.h
Alert.C Write the warnings and errors both to lyxerr and to the dialog. 2007-01-23 14:29:15 +00:00
Alert.h
Application.C fix bug: vert. maximized window is completely maximized after restart 2007-03-17 12:28:26 +00:00
Application.h fix bug: vert. maximized window is completely maximized after restart 2007-03-17 12:28:26 +00:00
ChangeLog
Clipboard.h Fix bug 3255 2007-02-21 21:47:44 +00:00
Dialogs.C Bugfix: no need to update if the dialog is not visible. 2007-03-25 00:45:34 +00:00
Dialogs.h
FileDialog.h
FontLoader.h
FontMetrics.h * support/qstring_helpers.h: erase ucs4_to_qstring() method. 2007-02-26 15:13:08 +00:00
Gui.h Clean up quit code. 2006-12-02 17:39:31 +00:00
key_state.h
LyXKeySym.h We use char_type, not size_t for storing UCS4 characters. 2007-01-24 14:01:34 +00:00
LyXKeySymFactory.h
LyXView.C Support code for advanced Toc management and bug correction. 2007-03-12 11:23:41 +00:00
LyXView.h fix bug: vert. maximized window is completely maximized after restart 2007-03-17 12:28:26 +00:00
Makefile.am
Menubar.h
mouse_state.h
NoGuiFontLoader.h
NoGuiFontMetrics.h * support/qstring_helpers.h: erase ucs4_to_qstring() method. 2007-02-26 15:13:08 +00:00
Painter.C Button face-lift: stop shifting text under mouse 2006-12-07 16:26:17 +00:00
Painter.h * support/qstring_helpers.h: erase ucs4_to_qstring() method. 2007-02-26 15:13:08 +00:00
pch.h
Selection.h Fix enabling of LFUN_PRIMARY_SELECTION_PASTE: It was always disabled, because 2007-01-08 18:37:40 +00:00
Timeout.C
Timeout.h
Toolbars.C Session: restore toolbars in the right order and location 2007-01-31 02:39:46 +00:00
Toolbars.h Session: restore toolbars in the right order and location 2007-01-31 02:39:46 +00:00
WorkArea.C For each operation, stop the blinking cursor before acting and restart it _after_ redrawing. This latter fixes the spurious cursor jumps in mathed. This was due to the fact that MathArray are filled-in at draw time (as opposed to text positions in the CoordCache which are filled in at metrics calculation time.) 2007-02-03 06:53:22 +00:00
WorkArea.h Prepare for advanced mouse click selections. 2007-01-27 10:41:03 +00:00