Changeset 237

Show
Ignore:
Timestamp:
02/26/07 22:34:26 (2 years ago)
Author:
Alan Knowles
Message:

thread dmd compile so that the interface does not hang on slow syntax tests

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/leds/LanguageD.d

    r230 r237  
    4242    private import gtk.TreeIter; 
    4343    private import gdk.Pixbuf; 
     44    private import gtk.GtkD; 
    4445    private import image.XPM; 
    4546     
     
    603604        //debug(flow ) System.writefln("CodeView.checkSintax 7"); 
    604605        codeview.getWorkspace().getSystemConsole.print("Compile Command: \n" ~  compileCommand.toString() ~ "\n"); 
    605          
    606         Spawn spawn = new Spawn(compileCommand.toString()); 
    607         correct = spawn.commandLineSync()!=0; 
     606        SpawnWrapper sp = new SpawnWrapper(compileCommand.toString()); 
     607        sp.start(); 
     608        while(1 && GtkD.eventsPending()) { 
     609            GtkD.mainIteration(); 
     610            if (sp.getState() == Thread.TS.TERMINATED) { 
     611                break; 
     612            } 
     613        } 
     614         
     615        //Spawn spawn = new Spawn(compileCommand.toString()); 
     616        //correct = spawn.commandLineSync()!=0; 
    608617        //debug(flow ) System.writefln("CodeView.checkSintax 8"); 
    609         codeview.getWorkspace().getSystemConsole.print("Compile Result:\n" ~ spawn.getOutputString() ~ "\n"); 
    610         checkSyntax( spawn.getOutputString(), spawn.getErrorString()); 
     618        codeview.getWorkspace().getSystemConsole.print("Compile Result:\n" ~ sp.outputstring ~ "\n"); 
     619        //checkSyntax( spawn.getOutputString(), spawn.getErrorString()); 
     620        checkSyntax( SpawnWrapper.outputstring, SpawnWrapper.errorstring); 
    611621        //workspace.getStatusbar().addBackgroundProcess(); 
    612622        //debug(flow ) System.writefln("CodeView.checkSintax 9"); 
    613623        codeview.endSintaxCheck(); 
     624         
     625        // is there any reason we bother with this? 
     626        // otherwise we have to hang on for events pending. 
     627        return correct; 
     628    } 
     629    bool syntaxCorrect = false; 
    614630      
    615         return correct; 
     631    private import std.thread; 
     632    class SpawnWrapper : Thread 
     633    { 
     634        char[] command;; 
     635        this(char[] cmd) 
     636        { 
     637            command = cmd; 
     638        } 
     639        static char[] errorstring = ""; 
     640        static char[] outputstring = ""; 
     641         
     642        int run() 
     643        { 
     644            Spawn spawn = new Spawn(command); 
     645            spawn.commandLineSync(); 
     646            setStrings(spawn); 
     647            return 1; 
     648        } 
     649        synchronized void setStrings(Spawn spawn)  
     650        { 
     651             
     652            SpawnWrapper.outputstring = spawn.getOutputString() ; 
     653            SpawnWrapper.errorstring =spawn.getErrorString(); 
     654             
     655        } 
    616656    } 
    617657