[Qt-interest] "%" characters in QStrings create havoc

Andreas Pakulat apaku at gmx.de
Fri Feb 26 22:39:30 CET 2010


On 26.02.10 12:30:02, KC Jones wrote:
> My crash was unrelated.  No surprise there. I was calling an object method
> through a null pointer, then accessing a member variable of the null
> object.  I'm surprised that the method call didn't crash immediately -- I
> guess the fact that the method was declared as a slot means it exists in the
> scope of the static metaObject, and can therefor be called through a null
> pointer???  When the debugger told me that the class member variable was
> 'out of scope' I looked up the stack and figured it out.

Its not unusual to be able to execute methods (also non-slots) in C++
even with a 0-pointer. The reason is that the method-code is not stored
with the actual object, but with the class. Hence the code can be found
as long as the type is known and can also be executed. It however
breaks/crashes as soon as that method tries to access some data of the
object. This is also a reason why one might get backtraces from deep
inside Qt (from some dpointer method), there was simply no data-access
up to that point... Or even functions that work without any problem on a
0-pointer, when they don't access the data of the object.

Andreas

-- 
You are going to have a new love affair.



More information about the Qt-interest-old mailing list