Home   About   Contact   Log in

Archive for December, 2006

Debuggeration

December 31st, 2006 | No Comments | Filed in Programming

Not surprisingly there is a bug in my code. The segfault was a hint. So, like you do I sprayed printf()s all over the place and found a likely bit of code causing the trouble. I was trying to dereference a NULL pointer, so added a bit of code that said “if (!whatever) return”.

Which then shifted the crash up a level, so I attached a debugger and began stepping through the code, jumping over the error several times before remembering what I was doing. Debuggers really need an “undo” or “rewind” option for when you accidentally jump over the line of code causing the crash.

And now I know exactly where my code crashes and why. It crashes on the line where I attempt to call an object’s member function, except the object is really a NULL pointer.

The pointer should be NULL, the problem is the code shouldn’t even be running at this moment in time.

I hate recursive programming, it always bites me somewhere unexpected. Unfortunately it makes sense to parse a recursive data structure using a recursive function.

And I won’t ask why I can’t compare two std::string objects using ==, but .compare() works fine.

Enter the layout manager

December 30th, 2006 | No Comments | Filed in Programming, Projects

It’s getting tedious hand coding the GUI already so I’m off to dig out TinyXML and create an XML schema for defining my GUI layout.

School’s Out

December 23rd, 2006 | No Comments | Filed in Uncategorized

So, it’s finished. I’ve survived my first school placement. It was interesting, difficult at times but mostly quite good. Onwards to my next one in January. Let’s see how different it is.

Thursday consisted of Student Review Day, where we talk to each person in our form and tell them what to do and how to improve their grades. Some of the kids were quite receptive to what we had to say, some just sat there and mumbled at us. There was even the odd parent.

Now sat at my cousin’s house typing this on his Intel MacBook which is quite nice, but feels like Linux with a different window manager. Nice small computer though, even if its keyboard does feel like typing on a ZX81.

GUI Programming

December 23rd, 2006 | No Comments | Filed in Programming, Projects

I have sought the wisdom of my as yet unwritten application, and it wants its own GUI writing.

So far I have a nice basic “GUI base object” that handles standard stuff like screen position and a bit of memory to draw onto. It also contains a list to put child objects in. The “draw” function iterates that list calling each child’s draw function.

Then I derived a “window” object which at the moment doesn’t do much beyond claim its own bit of graphics memory to scribble on and set up its size. Right now I’m not going for anything more advanced than a load of coloured boxes on the screen.

Now what’s a nice way to handle the drawing onto the screen? I’m using SDL and the way it works is to first create a main surface for your app. This gets done in the main function right when the program starts. I can then blit more surfaces onto this in a relatively painless way.

All my widgets need to draw themselves on this main surface, but how can I do this in a sane way? I could just pass a pointer to this into every object’s constructor but it seems inelegant.

Would it be better to have each object’s draw function return the allocated graphics surface, and build up the screen in chunks. English isn’t so good at explaining this, have some code…

Code:
Widget::Draw()
{
for (all widgets in our child list) {
blit (child.surface, this.surface, child,x, child.y, child.w, child.h)
}return this.surface;
}

with the top level doing this:

Code:
main()
{
screen = SDL_Initblah (800×600@32bpp);Window mainwind;

for (ever) {
process event loop
other stuff
mainwind.draw();
blit (mainwind.surface, screen, with-and-height);
}
}

This would need all object co-ords to be done relative to their parent window, but that’s normal anyway, isn’t it?

It’s an Internet Go-slow

December 19th, 2006 | No Comments | Filed in Technology

Got this email from my ISP…

Quote: My ISP
Dear Mr Piku,

Your peak-time usage for this billing month just exceeded 11GB.

Although this is not more than your allowance, we wanted to make you aware
of light restrictions to your connection speeds that come into force should
you reach 13GB. These restrictions help you to stay within your allowance,
and ensure that all customers receive the best possible quality of
service.

All I did was download the Fedora Core 6 DVD image twice, plus the usual downloadings and stuff that happen in a month. Turns out my ISP’s idea of “off peak” is 4PM till Midnight. Not the usual 9-5, Monday-Friday we all assume…

Reinstallation

December 16th, 2006 | No Comments | Filed in Technology

I am now running Fedora Core 6 and it’s really nice.

The installer doesn’t appear to have deleted my Windows installation, and after some fiddling with the graphics driver I have everything back to how it used to be - with extras. Fonts look nicer, the KDE theme is nice and soothing to look at, and lots of things Just Work without me having to spend hours fiddling. I like fiddling with things and learning how they work, but not when it gets in the way of me using my computer for normal things. I can write an X.org config file, but would much rather something did it for me.

I can plug USB storage devices in and they mount themselves properly. Everything is as it should be.

What’s really helped was moving my mail and data onto my server. I can use any computer in my house to access it now. There’s IMAP for mail, LDAP for addresses, SMB or SSH for file sharing and when I turn on the ports in my firewall, remote access to my mail and files.

Now if only I could build a recovery DVD that contained my system at this current moment in time. Having an equivalent of the XP System Restore would be handy too. I managed to break Yum by upgrading things and had to spend an hour undoing the mess. I always thought putting /etc in an SVN repository would be a good idea.

Insanity

December 12th, 2006 | No Comments | Filed in Technology

Think back to when you were at school. Wasn’t it great waiting for Christmas to come? Two weeks of guaranteed free time away from school and having to get up at half seven in the morning.

Yes, teachers also think this way. Unfortunately we have to get up at 6:45 and at least look like we’re trying to teach you something. It helps if you pretend to listen, makes the whole thing work a bit better.

Teaching year 7’s about formulae in spreadsheets is quite tricky. The fundamental concept of a formula is totally alien to them. How do you explain to a small kid that even though the cell says “14″, it really contains “=B6*B7″? It makes no sense - they see one thing, but it does something else. The link is hard to make.

I spent most of my first lesson trying not to headbutt the wall or eat my whiteboard rubber. The second lesson was a repeat of the first, with slightly cleaverer children. We got further. Most of the class understood what a formula was and how to make them. Shame the actual objective was to understand how formulae can be used to predict and model data, but there you go.

It’s all good practice. Although I do want to glue some of the kids to their chairs. It is really irritating when they don’t sit on them properly or spin round and round.

Silicon Heaven

December 4th, 2006 | No Comments | Filed in Technology

And it seems the PSU has died. I probed the laptop end with a multimeter and there was nothing coming out of it. I probed the end of the mains cable and that registered 250v, so the black box in the middle is at fault. It’s definitely at fault now since when plugging it back in there was a loud crack from the PSU.

Well, I found a new one for £25 which isn’t so bad. The machine is also still covered by that PC World warranty they convinced me to buy so I think I’m covered even if the motherboard has died.

And fortunately, my paranoid attitude to taking backups have ensured I’ve not lost any data, and can use my sister’s laptop instead. Mind you, I need to get the off-site backup working properly. I have my really important data stored on a USB pen drive, my server here, my University account and my School account. I’d just like to be able to do the same with the rest of my data.

Lessons have been planned, there are no problems :-)