Archive for September, 2009

“When it rains, it pours”

September 28th 2009

So last month my daughter died. My grandfather has been in the hospital for a week but his condition has deteriorated and now he’s not expected to live longer than a day or two. :(

2009 started off so nice but it’s ending up a horribly rotten year for me. Of course my thoughts now are with my family, especially my Grandma. I’m glad that my Grandpa was at least able to hold Emma this year.

Posted by mpyne under Personal | 7 Comments »

Car batteries

September 28th 2009

I now hate side-post car batteries. My wife’s car battery died today and since she has appointments to take Ian to and I have work to go to I needed it fixed today. Since it’s just a car battery I opted to do it myself.

Anyways, it’s all fixed now. The estimate was 30 minutes for the trained car shop repairman who has replaced a million of these. It took me 45 minutes (and with crappy tools to boot) so I feel OK about it. I just wish my fingers would quit feeling sore…

Posted by mpyne under Personal | 3 Comments »

Tooling around

September 24th 2009

Some minor things:

Temporary confusion: On a mailing list the other day someone was having issues with the following type of code:

const char *name = m_obj.byteArray().constData();
printf("%s", name); // kaBOOM

So what was wrong? In this case, usage of a pointer that was freed. Freed, in this case, by the QByteArray object that was created and destroyed all on the same line. In other words, this part: m_obj.byteArray() returns a new QByteArray (called a temporary object since it is not named by the programmer). The .constData() tacked onto it grabs the address of the data in that QByteArray.

Unfortunately, by the time you’ve used the pointer on the next line, the temporary QByteArray has been destroyed. Now that pointer you have is dangling into unallocated memory and who knows what will happen. Maybe it will work, maybe it won’t, but it’s technically undefined behavior.

The solution is to assign that QByteArray to some local variable first, that way the compiler won’t destroy it on you. Also note that passing this pointer to an enclosing function is also fine, like this:

printf("%s", m_obj.byteArray().constData());

The compiler will make sure that all of the temporaries invoked to handle a function call will be alive until after that function has run (destroying temporaries is done as the last step of that entire expression). This is what makes the qPrintable() function useful.

Also I saw a interesting link about GCC optimization on Hacker News. Basically the -Os (optimize for size) flag ends up being the fastest compilation option in many cases. This is due to the fact that it takes so long to access data that is not in the cache for modern day architectures (in comparison to CPU speed) that it is often better to do a lot of extra work for the CPU if it will mean that the code size is smaller. I’ve used this flag for awhile with no ill effects (on the other hand, no blindingly obvious speedups either ;) It’s something to think about when you’re playing with your compilation flags.

Posted by mpyne under C++ & Tutorial & Useful Tricks | 4 Comments »

Keep moving

September 19th 2009

So, I’ve been trying to keep working and moving and generally being productive. It helps me feel a bit better and besides, it’s easier doing something than to do nothing.

Since the most distracting type of “doing something” for me is coding, I set myself the task of changing the system tray icon implementation for JuK to the newly-added KNotificationItem. This was involved enough in JuK’s case to be worth doing without being so involved that I’d get fed up. It was a nice distraction for a day.

I noticed that the KDE 4.3.1 release was dedicated to the memory of Emma, which is something Mary and I appreciated.

I went back to work last week, but it was too early as it turned out. I tried again yesterday and it seemed to go better so I think I’m on track to resume my qualification process for instructor duty. Obviously the support provided to me by my command has been invaluable in helping Mary and I get through the grieving process.

I had (finally) informed our bank/insurance company of Emma’s passing last week. I received a package in the mail from them yesterday, but with no forms or anything to fill out, just a short letter and a short pamphlet. Kind of a nice touch, I thought. The pamphlet mentions that the grieving process begins after the shock, numbness, and disbelief subside. In my case I know I’ve been grieving and I know that Emma is gone and yet depending on what I’m thinking it still doesn’t “register” sometimes that she is dead. It’s gotten to where it feels more eerie than painful but it is still disconcerting to simultaneously know that your baby is gone and feel that she is right there.

I also finally got around to moving some of our broken-down cardboard boxes to a recycling facility. I had thought it required showing up during business hours, which is difficult when those hours coincide with my working hours. And I didn’t feel like doing it when I was on emergency leave somehow. But it turned out there are collection facilities where you can just drop it off at your leisure, so now our garage has much less crap in it.

I am in graduate school now so although I will be trying to increase my programming-related activity if only for my own peace of mind, I’m not sure how much of that time I’ll be able to contribute to maintenance of my current KDE projects (as few as those already are). kdesvn-build will probably be my priority due to the shift (someday) to the Git source control system and because few KDE coders are familiar with Perl. (Even if kdesvn-build gets obsoleted I hear there is another possibility being worked on by a different Michael…)

I’ll probably try to blog more often as well. I usually feel better and I used to post entries quite frequently (when I was in college and had tons of time at least!)

Posted by mpyne under KDE & Personal | 1 Comment »