[darcs-devel] wxDarcs and withRepoLock

Eric Kow eric.kow at gmail.com
Sat Jan 28 16:06:53 PST 2006


Hi all,

For the past couple of weeks, I've been trying to slap together a 
minimal standalone graphical interface for darcs (1), but I'm stuck on 
a problem and would appreciate a hand figuring out what's wrong.

A little background: I'm aiming for a fully integrated darcs-native 
interface using the original wxhaskell code.  The original gui code was 
to be called from the command line.  For instance, if you type in darcs 
record --gui, you get a graphical interface for recording.  The new gui 
code preserves this behaviour and builds off it by adding a graphical 
front end, so that you can call these pre-existing forms with a click 
of a button. You can see a screenshot here: http://tinyurl.com/7z35q

the problem
-----------
What actually happens when you click on the "Record" button (in the 
main interface) is that the gui calls 'command_command record' with 
some default arguments.  So far so good.

But one horrible thing that happens is that the record command never 
gets around to releasing its repository lock, even if you close the 
Record window (2).  It doesn't matter if you actually record something 
or if you cancel.  Both options leave the lock behind.  It seems as 
though the record command never comes back when you close the Record 
window.  Indeed, if you modify Record.lhs, inserting a putStrLn like 
so:
                  if Gui `elem` opts
                  then do s <- slurp_recorded repository
                          guiSelectPatches opts s $ flatten ch
                          putStrLn "done with record"
                          hFlush stdout
                  else

... the "done with record" putStrLn never happens (3).

Naturally enough, calling the record gui from the command line the 
old-fashioned way (darcs record --gui) works; the lock is released,  
and 'done with record' is put onto the screen.  But calling it from 
another gui keeps it stuck.

Does anyone have an idea why this lock is never getting released?

Maybe one of my sins is invoking command_command directly without any 
of the magic that darcs.lhs and friends do?  The relevant code looks 
like this; I invoke the command as if you had passed the --gui flag and 
the default arguments to it.

let dbutton p txt cmd =
          do args <- command_argdefaults cmd "" []
             button p [ WX.text := txt, enabled := hasRepo
                      , on command := command_command cmd [Gui] args ]
recBt  <- dbutton mp "Record" record

I guess I'll post to wxhaskell users as well, but maybe somebody on the 
darcs end could pipe up with debugging ideas.

Anyway,  thanks for your time.
Cheers,

--eric

footnotes... cuz eric can't be concise
---------
(1) I don't intend this to be fully featured, polished or even for that 
matter, functional.  I think the idea is to make a proof-of-concept, 
but one which is usable enough to suck other coders in, and get them to 
hack it into something truly useful.

(2) Interestingly, closing the main wxDarcs window causes a bus error.

(3) Incidentally, i would that thought that by virtue of laziness, it 
would have executed even without the user touching the gui, but maybe 
that's another issue.

-- 
Eric Kow                     http://www.loria.fr/~kow
PGP Key ID: 08AC04F9         Merci de corriger mon français.




More information about the darcs-devel mailing list