Sniff, etc.
I've had this cold for about two weeks now. At its height I had a couple of days off work, feeling like hammered dog shit and able to do nothing but sit on the couch watching TV and feeling sorry for myself. On the plus side, it did let me catch up on some movies that I couldn't convince R to watch. Nothing like a big dumb blockbuster when you're feeling poorly. Thank you, Superman Returns. Anyway, once that stage passed I reckoned the cold would be gone completely in a day or two, but it's a tenacious little bugger and just won't die. In fact, last night I started feeling significantly worse, going through the best part of a box of tissues in just a few hours and sneezing my head clean off. R made some awesome chilli and nuclear-strength salsa which might have contributed to the sniffles in the short-term, but this was an all-night snotfest. Maybe it was hayfever interacting with the last vestiges of the cold itself. Either way, the least fun part of my evening was balancing precariously on top of a wobbly stepladder while attempting to put the smoke alarm back up and trying hard not to explosively sneeze myself into the "90% of accidents happen in the home" statistical bracket. It took far longer than it should have to get the thing to stay up, and I'm hoping that I don't come home tonight and find that it's fallen off and brained the cat. Somehow I never fail to turn even the simplest DIY task into an epic, sweary, struggle.
Labels: diary
Wednesday, May 09, 2007Pressing on with Poster
Hooray! After moaning about it here yesterday, the bug that's been holding up development of my desktop blogging app "Poster" has finally been vanquished. Finally I can move on with functionality.
It turned out to be something quite esoteric and unlikely, For the sake of anyone else having the same problem and Googling for it in vain, as I did repeatedly, here is the solution. If you're not interested in Java/SWT programming you should probably skip the rest of this post, or risk extreme boredom ...
Anyway, Poster is written in Java, and uses Eclipse's SWT libraries for its GUI. At first everything was peachy, but as time went on I was noticing more and more random lock-ups. Specifically, it seemed to hang if a control gained focus, and then the user pressed a key immediately afterwards. For example, if the user clicked a text box and immediately started typing, the whole app would freeze and need to be terminated. Waiting a little while between clicking on the control and typing would prevent it from happening, but that period got longer and longer as more buttons were added to the toolbar of the main window, confusingly. (It may simply be that more visible controls = longer wait time between the text box receiving focus and being able to handle key events.) However, once one control had successfully handled a key event, a lock-up would never happen no matter how fast the user was. It was only ever on the first key event handled.
The code which kicked off the app and started the main message loop looked something like this (with apologies for crappy indentation):
public PosterApp
{
private Display m_display = new Display();
public startApp()
{
// MainWindow is a wrapper around Shell
MainWindow appWindow = new MainWindow();
while(!m_display.isDisposed() && !appWindow.isDisposed())
{
if(!m_display.readAndDispatch())
{
m_display.sleep();
}
}
if(!m_display.isDisposed())
{
m_display.dispose();
}
}
public static void main(String[] sArgs)
{
PosterApp app = new PosterApp();
app.startApp();
}
}
Pretty standard stuff for an SWT app. Further investigation revealed that it was hanging somewhere in m_display.readAndDispatch();, though down in the native library layer, so I couldn't debug the actual SWT code.
Anyway, after banging my head against it for a while, and trying various things without success, I decided to hack in a version of Sleak, grasping at that last straw which suggested that maybe it was all down to me not disposing of some SWT resources.
To do so, I had to move the instantiation of the Display object ...
public PosterApp
{
private Display m_display;
public startApp()
{
m_display = new Display();
// MainWindow is a wrapper around Shell
MainWindow appWindow = new MainWindow();
...
... And, lo and behold, all my random crashes went away! It seems that instantiating the Display in the header of my class was causing strange issues that instantiating it in the startApp method resolved, but don't ask me why. I'm just glad it's working. I should probably note that this only seemed to happen on Windows. I never saw this happen on OS X, and haven't tried it on Linux. I suspect it's some quirk of the Windows implementation of SWT.
Labels: development, java, poster
Tuesday, May 08, 2007Um... hello
Sorry for not posting of late, but I have been stupidly busy, and continue to be so. My "to-do" list is literally overflowing and spilling all over the floor. Remember The Milk is a superb tool, and being able to sync it with iCal and then onto my phone by Bluetooth gets the geek in me all excited in a slightly disturbing way, but man it's depressing when your "overdue" list gets that big. You'd think that being busy would give me stuff to blog about, but I don't much like posting details of my real life. It's only when I'm bored and navel-gazing that I feel the urge to write about it.
I am pretty tired this morning, having been woken up at 3.45am by the incessant chirp of the smoke alarm, telling me that it's battery was running out. Cue much swearing and clattering while I dragged out the stepladder with a bleary-eyed lack of grace then wrestled with the alarm itself, virtually ripping it from the ceiling.
I had hoped to have a first beta release of Poster out by now, but a persistant and pernicious bug, seemingly in the Windows implementation of the Java GUI library I am using, is holding things up. It won't kill the project, but it is slowing me down while I bang my head against it. Frustratingly, I can't even replicate it in a persistant manner, so can't report it. Grr.
