QString crash when moving across a plugin boundary
-
Recently I noticed the following:
- In my application there is a 'core' bit, which has a certain function that accepts a
const QString&
, sayf(const QString&)
(it's actually a function that will popup aQFileDialog
and the string is the caption) - The application loads plugins, and the plugins get access to this function
f
- Recently I was calling this function from within the plugin, without explicitly typing a
QString
, so I was callingf("File Dialog Caption")
- in other words, I tried relying on implicit construction - This caused a crash in the core part, where, as far as I could tell, the internal data of the
QString
object was pointing toNULL
- Then I changed the call by explicitly calling the
QString
constructor:f(QString("File Dialog Caption"))
, which resolved this crash
I'm (almost) sure this has something to do with the magic that happens when moving across dynamic libraries (this is on Windows, but I read that similar problems occur on *nix)
So, can someone explain (or refer to some clear explanation) about this magic? I have been googling quite a bit, but I find it hard to get details about what is happening. Then the obvious next question is, what is the connection with
QString
? - In my application there is a 'core' bit, which has a certain function that accepts a