Archive for June, 2007

QDomDocument is not a QObject

Friday, June 29th, 2007

Aha! Here’s one that caught me out for a while. I was writing a class that inherited from QDomDocument and was more than a bit puzzled when I got the error

moc_fdom.cpp:37: error: ‘staticMetaObject’ is not a member of ‘QDomDocument’
moc_fdom.cpp: In member function ‘virtual void*
JsDomDocument::qt_metacast(const char*)’:
moc_fdom.cpp:51: error: ‘qt_metacast’ is not a member of ‘QDomDocument’
moc_fdom.cpp: In member function ‘virtual int
JsDomDocument::qt_metacall(QMetaObject::Call, int, void**)’:
moc_fdom.cpp:56: error: ‘qt_metacall’ is not a member of ‘QDomDocument’
gmake[1]: *** [moc_fdom.o] Error 1
gmake: *** [sub-src-make_default] Error 2
*** Exited with status: 2 ***

Turns out QDomDocument isn’t a QObject so I was making the mistake of including the Q_OBJECT macro at the start of my class definition. D’oh!

class XDomDocument : public QDomDocument
{
Q_OBJECT //Don’t do this!!!
public:
XDomDocument();
}

A side effect of not being a QObject is that you cannot wire up signals and slots in the normal manner. Although googling around should bring up a few workarounds.

The Linux Kernel - An Overview from IBM

Friday, June 29th, 2007

Good things come in small packages packages. But great things are scabable!

One such example is the Linux kernel - it can run on anything from a toaster to a supercomputer; how does it do it? The answer to this, and other interesting questions, can be found in the very readable guide to the Linux kernel by IBM Anatomy of the Linux kernel.

.NET - Develop in Visual Studio, Deploy on Linux

Sunday, June 24th, 2007

Recently, a new product has hit the market for those folks who would like to develop in .NET, and in particular Visual Studio, but prefer to run their application on Linux.

Although you could already code up .NET solutions in MonoDevelop - which itself has made great progress recently - most enterprises will only want to write .NET server and web apps in Visual Studio. Mainsoft has seen the gap in the market and filled it with a free plugin for Visual Studio, called Grasshopper, which lets you deploy to Linux. It achieves this by compiling the application to Java bytecode rather than the .NET intermediate language and also leverages work done in the Mono project, which has already done much work in bringing .NET to Linux.

In other news, Silverlight has been successfully ported to Linux through an incredible hackathon effort by Miguel de Icaza and his Mono team! Going under the name of Moonlight, the port was pretty much wrapped up in 21 days - so it’s amazing to think that with all this going on Miguel has any time to keep his blog updated!

The PHP Header() Trap

Sunday, June 24th, 2007

This is just a quick tip for young players - new to the PHP game. The rather sexy header() function can be used to redirect the user from one page to another. But an important point about this function is that you cannot send ANY html or empty lines or spaces (or anything) to the client browser prior to calling the header() function.

This sounds easy to guard against but it isn’t always obvious. You could include a file using include(), require() or require_once() and it could be the culprit. This hit home particularly hard today when it turned out that out database connection file had empty lines after the closing php tag “?>”

Ironically, if the empty lines had been located before the closing php tag then everything would have been fine, as they would not have been sent to the client - c’est la vie! The solution became apparent after stumbling across this page which spelt the problem out clearly.

Unexpected Javascript Postbacks?

Thursday, June 21st, 2007

This has been driving me bananas for hours. If you’re finding that your javascript function is causing your page to post back to itself unexpectedly, then ensure that it returns false at the end of the function. Also void(0) can be your friend.

Surviving Migration from ASMX to WCF Webservices

Monday, June 11th, 2007

Just when you thought you’d gotten the hang of the good ol’ fashioned .NET webservices (the ASMX variety) those Redmond boys went and changed everything with the release of WCF! The benefits of WCF webservices are that they’re considerably more flexible but the transition can be a lot steeper than you’d expect. Here’s a nice little guide by Dominick Baier on some of the day-to-day areas of the API that can catch you out unawares
Hosting WCF Services in ASP.NET - The Survival Guide
.

Viva Le Gaelic Penguin!

Saturday, June 9th, 2007

Phew! After much fiddling and tweaking I finally managed to get my header image together for this site. All the while I had the song “The Irish Rover” bouncing round in my head - which probably didn’t help matters!

But I think the above header was worth it. Veronica, my glamorous girlfriend and graphic design mentor, didn’t like it much to start with. At least I managed to pacify her by throwing in a cute penguin pic, which I did up in the absolutely fabulous Inkscape. Inkscape has to be one of the best Free Software programs ever. It’s just so easy to use and yet things just always turn out good. It’s magic. And that’s just the kind of thing you’ll be hearing more about on this blog over the coming months along with other news and discussion from the filthy dirty world of Open Source.

Just a heads up for anyone trying to change their WordPress header image - make sure that you haven’t changed the header’s colours or anything previously in WordPress. If you have made changes then you should revert them - which can be done from the dashboard. Otherwise all the image uploading and CSS styling in the world won’t be enough to get that flamin’ header to change! Now there’s an hour of my life that I won’t get back! At least I had The Irish Rover playing away in the back of my head to keep me going…

Doo do doo…