Archive

Archive for December, 2009

On the ambiguity of “upload” and “download”

December 26th, 2009 Comments off

A few days ago, I finally got a cable that would allow me to connect my universal remote control to my computer so that I could tweak the settings that had been programmed into my control by the people who installed our home theatre system. Those people had actually done a very sophisticated job to make this particular remote work very well with a lot of devices hooked up to the screen.

So I connected the remote, launched the programming app, and clicked on the “download” button. Within a few seconds, my remote control was completely overwritten with default settings from a demo configuration file.

This happened on Christmas Eve so of course nobody was around to come by and fix it so I was left to try and figure out the programming application by myself (no manual and not a particularly intuitive user interface) to get things working again.

Anyhow, I started thinking about why I just automatically hit the “download” button, even though in past careers, I have written software for embedded systems where one cross-compiled code on a PC and then “downloaded” it to the embedded device.

However, on our PCs, we have all gotten used to the term “download” to mean “put something into the PC”. These days, when we “upload” something, we’re copying from our machine to some other computer, typically a server on the internet. The problem of course is that “download” and “upload” are relative. The behavior depends on from where you initiate the command.

So I propose that the words “download” and “upload” (whatever they mean) be replaced with “inload” and “outload”. The former means to load something into the device initiating the command and, well, I’ll leave it to you to figure out what “outload” should mean.

 

Categories: Uncategorized Tags:

When NULL == false in QVariant

December 21st, 2009 Comments off
I (Nebojsa) spent some time hunting down a problem where our QSettings (a Qt framework settings class) derived convenience class would not read Boolean values properly.
We wrapped the “Read” function with a code similar to this
  
template  T Read(ConstString name, T defaultValue)
{
   T result = defaultValue;  // Assume
     if (Exists(name))
        then QVariant v = this->value(name);
     if (v != NULL)
        then result = v.value();

   return result;
}
The idea is simple – if the value exists we read it, if not we use the supplied default value.
The line
   If (v != NULL)
fails miserably if v is a Boolean value.
If v is a boolean type and its value is false – then the v == NULL expression evaluates to true.
This is understandable since NULL expands to 0 and 0 is considered false. I wish NULL would be reserved for pointers in C++ so that the compiler could complain whenever one tried to use it for anything else but to signify a NULL POINTER!
So rather than testing the QVariant for NULL – use its member function isNull to test if it is really null.
The if statement above should be written as
   If (!v.isNull())   ...
Everything works perfectly afterwards.
Btw. If you are wondering what is a Pascal style “then” doing in our C++ if statements – we believe that “then” is making our if statements much more readable. It is simply defined as nothing
#define then
Categories: Software Development Tags:

iMac shutdown (and resurrection)

December 4th, 2009 Comments off

My trusty Intel dual core, 24″ iMac just shut down on me today. Out of the blue and after no particular provocation from my side.

I thought that it might have overheated and that once cooled – it might come back up, but no luck.

I was sure it was the power supply – there’s no “peep” coming out of the thing so I set out to find how to replace it. I found a bunch of interesting things, but mostly wanted to figure out a proper way to open it up.

A video I found on YouTube was good enough to let me know what I am up against. You can find the video here

Once I opened the thing – I disconnected the LCD, took out the memory modules and then the power supply. I could not see any signs of damage on it. I know – it’s not always visible, but when a power supply goes bad – there is usually a strong smell coming out of it or other noticeable signs of damage.

I put it back in and thought to try to power it now with everything else disconnected. It worked – the fans started to spin, showing the signs of life. I soon figured out that plugging in the monitor inverter was the source of trouble so it went bad and was most likely surging the power supply which in turn correctly shut down everything.

So – I went to the store, got myself a mini DVI->DVI cable (not the $65 Apple one, but the $18 one) and plugged the iMac into my regular 24″ LCD  – worked like a charm.

I’m going to miss the nice LCD, but at least I have my iMac back and will most likely get a new 24″ for it since that is far cheaper and more modular than repairing the current LCD.

So – next time your computer dies – don’t assume it’s the power supply. Plug everything you can out of it and test it before you make you final verdict.

PS. You are backing up your files are you? Anything can go wrong at any time – back up your important data. If I didn’t get my mac running – I would have to get another one, but my data was never in jeopardy.

Categories: Uncategorized Tags: