Results 1 to 7 of 7

Thread: Unknow General exception..

  1. #1

    Unknow General exception..

    Hi all,

    I have a bit of a weird problem,
    i have a basic debugger unit that i use with my games engine, it works fine but when ever i turn the debugger off it causes a general exception, but works fine when it is on.

    The debugger is just a Stringlist with functions to write to it.

    Debugger unit:
    [pascal]
    uses
    Classes;

    var
    Log: TStringList;
    LogFilename: String;
    LogInitialized: Boolean = False;

    ..

    procedure IintializeLog(const Filename: String);
    begin
    LogFilename := Filename;
    Log := TStringList.Create;
    If FileExists(LogFilename) Then DeleteFile(LogFilename);
    LogInitialized := True;
    LogDetails;
    end;

    procedure OpenLog;
    begin
    If Not LogInitialized Then Exit;
    If FileExists(LogFilename) Then Log.LoadFromFile(LogFilename);
    end;

    procedure CloseLog;
    begin
    If Not LogInitialized Then Exit;
    Log.SaveToFile(LogFilename);
    end;

    procedure WriteToLog(const Value: String);
    begin
    If Not LogInitialized Then Exit;
    OpenLog;
    Log.Add(Value);
    CloseLog;
    end;

    procedure LogDetails;
    begin
    WriteToLog('Log version **** ');
    end;
    [/pascal]

    When my engine starts it calls InitializeLog if i want the debugger enabled (which runs ok) but if i dont then i get the exception!

    Maybe i have missed something but i can not see anything wrong with it :s

    If any one can help it would be great
    M109uk
    <br />--------------------------------------------------------
    <br />www.pulse-soft.oneuk.com

  2. #2
    Legendary Member cairnswm's Avatar
    Join Date
    Nov 2002
    Location
    Randburg, South Africa
    Posts
    1,537

    Unknow General exception..

    I Presume it is the fact that LogInitialized is never initialized which means it might be true when one of the functions is called.

    Add at the bottom of the unit

    [pascal]
    Initialization
    LogInitialized := False;
    Log := Nil;

    Finalization
    If Assigned(Log) then
    Log.Free;

    End.
    [/pascal]

    I didnlt test it exactly but its something like that.
    William Cairns
    My Games: http://www.cairnsgames.co.za (Currently very inactive)
    MyOnline Games: http://TheGameDeveloper.co.za (Currently very inactive)

  3. #3

    Unknow General exception..

    I have just tried your code but the same exception appears.

    I have found another wierd thing about it, i commented out ALL the code inside of my WriteToLog procedure and the exception happens wether or not i initialize the log :?

    I cant understand why this happens because this is the only procedure calling to the log, and with out the code how can it cause an exception :?
    M109uk
    <br />--------------------------------------------------------
    <br />www.pulse-soft.oneuk.com

  4. #4

    Unknow General exception..

    post more code, like from the main app. From what I've seen your log thing should work fine... maybe you're accessing the string list somewhere outside of that unit or something.
    Ask me about the xcess game development kit

  5. #5

    Unknow General exception..

    The main application's code is:

    [pascal]
    function winMain(hInstance: HINST; hPrevInstance: HINST; lpCmdLine: PChar; nCmdShow: Integer); stdcall;
    var
    Msg: TMsg;
    DemoStart: DWord;
    LastTime: Cardinal;
    begin
    KInitializeLog(KLogFilename);

    KLog('Init OpenGL..');

    .. OpenGL Initialize code ..
    .. Main OpenGL loop ..

    .. Free OpenGL code ..

    KFinalizeLog;
    Result := Msg.wParam;
    end;

    procedure InitializeKngine;
    begin
    KLog('Initializing engine');

    KLog('Create classes..');
    Cameras := TknCameras.Create;
    Textures := TknTextures.Create;
    Fonts := TknFonts.Create;
    Console := TknConsole.Create;

    KLog('Add camera');
    Cameras.Add('Player', Vertex3f(0,0,0), Vertex3f(0,90,0));

    KLog('Load all available fonts');
    Fonts.LoadAllFonts;

    KLog('Load console scheme..');
    Console.LoadFromFile('default.knc'); // <- EXCEPTION CREATED HERE

    KLog('Finished engine intialization');
    end;
    [/pascal]

    The complete Debug/log unit:
    [pascal]
    procedure KInitializeLog(const Filename: String);
    procedure KFInalizeLog;

    procedure KLog(const Value: String);
    procedure KLogError(const Value: String);
    procedure KLogLine;
    procedure KLogDetails;

    implementation

    var
    Log: TStringList;
    LogFilename: String;
    kDebug_Iint: Boolean;

    procedure KInitializeLog(const Filename: String);
    begin
    If Filename = '' Then Exit;
    Log := TStringList.Create;
    If FileExists(Filename) Then DeleteFile(Filename);
    LogFilename := Filename;
    kDebug_Init := True;
    KLogDetails;
    end;

    procedure SaveLog;
    begin
    If Not kDebug_Init Then Exit;
    Log.SaveToFile(LogFilename);
    end;

    procedure KLog(const Value: String);
    begin
    If Not kDebug_Init Then Exit;
    Log.Add(Value);
    SaveLog;
    end;

    procedure KLogError(const Value: String);
    begin
    If Not kDebug_Init Then Exit;
    KLog('Error :: '+Value);
    end;

    procedure KLogLine;
    begin
    If Not kDebug_Init Then Exit;
    KLog('******************************************** *****');
    end;

    procedure KLogDetails;
    begin
    If Not kDebug_Init Then Exit;
    KLogLine;
    KLog('Kngine Debugger');
    KLog('Version ***');
    KLogLine;
    end;

    initialization
    kDebug_Init := False;

    finalization

    [/pascal]

    Console loading routine:
    [pascal]
    KLog('Loading console scheme');
    Fs := TknStream.Create(Filename, fmOpenRead);
    Try
    Fs.Read(Animation, SizeOf(TConsoleAnimation));
    Fs.Read(Direction, SizeOf(TConsoleDirection));
    Fs.ReadInteger(MaxLines);
    For i := 0 To MaxLines-1 Do Fs.ReadVertex4f(LinePositions[i]);
    Fs.ReadVertex4f(cmdPosition);
    Fs.ReadSingle(OpenPos);
    Fs.ReadSingle(ClosePos);
    Fs.ReadSingle(XPos);
    Fs.ReadSingle(YPos);

    Fs.ReadString(Fontname); // < EXCEPTION RAISED HERE

    Fs.ReadVertex3f(FontColour);
    Fs.ReadString(Texturename);
    Except
    raise Exception.Create('Failed to load console!');
    End;
    Fs.Free;
    end;
    [/pascal]

    At the moment im re-writting my console editor, it seems to be a problem with that.. The editor was using the debugger while i saved the console file, i turned it off and the exception message changed.. But i cant see why this will be the problem :?
    M109uk
    <br />--------------------------------------------------------
    <br />www.pulse-soft.oneuk.com

  6. #6

    Unknow General exception..

    I guess this happened when you posted it here

    you declare
    kDebug_Iint: Boolean;

    but you use
    kDebug_Init: Boolean;


    Other than that I don't see anything that might be causing problems. My suggestion is to place your debug stuff into its own object. That way you can be sure that nothing from "outside" intereferes with it. Then I'd test it in a separate app and see if it works. If it does, the problem is somewhere else.
    Sorry, I wish I could be more helpful :?
    Ask me about the xcess game development kit

  7. #7

    Unknow General exception..

    you declare
    kDebug_ Iint : Boolean;

    but you use
    kDebug_ Init : Boolean;
    lol yeah thats my posting (thank borland for syntax checking :roll

    I have rebuilt the editor from scratch, that didnt solve the problem so i re-written the consoles file stucture (even though nothing much has changed except for the names of the variables), it does seem to work now, but i just cant see how my debugger managed to cause this problem when its switched off :? oh well at least it works!

    Thanx for your help anyway
    M109uk
    <br />--------------------------------------------------------
    <br />www.pulse-soft.oneuk.com

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •