[Solved] QSharedPointer::matrixData() and QSharedPointer::data() on OSX and iOS
-
Hi,
I've been developing a cross-platform Qt 5.2 app for Mac OSX and iOs. My app uses QSharedPointers. I noticed that the function matrixData() is defined for OSX but not for iOS. On iOS the function that gives the pointer to the shared object is named data() and not matrixData().
This is frustrating because now I have subclassed QSharedPointer and I use a compile-time conditional that defines data() on OSX only (which simply calls the matrixData() method) so that I can use the same function name regardless of the OS.
If I remember correctly the function name was data() on Qt 4.8 but it changed to matrixData() on Qt5. Did you forget to also rename the function for iOS?
Still, I believe that Qt5 rocks! And this is a minor problem that is quickly fixed both from the user side and from your side in a future release.
Great work guys. Thanks
-
Hi,
Where did you find matrixData() ?
From a quick grep through qtbase's sources there's not function named like that
-
Well frankly, I have no idea where I found it... I think it must have appeared on the autocomplete pop-up or something like that.
I agree with you. The Qt5.2 documentation talks about the data() function, and there is no reference about matrixData(). However data() does not exist on OSX. I get a compile error. matrixData() seems to compile and work fine but it's not documented.
The qsharedpointer_impl.h file defines both functions although data() seems more generic than matrixData() from a quick glance.
Am I missing something?
-
Again where did you get these ? Are you really sure you are not having some other libraries mixing in ?
Looking at the stable branch there's no matrixData anywhere in the sources and the code for QSharedPointer doesn't contain any OS specific stuff.
-
Thank you for your quick replies.
I simply downloaded the Mac QT5.2 SDK bundle for OSX and iOS from the website. I did not compile Qt from source. There are no other Qt versions installed on my system and I verified that the qsharedpointer_impl.h file is pointing to the Qt5.2 library. I'm pretty sure the installation on my computer is done by the book.
The qsharedpointer_impl.h file I'm talking about appears on QtCreator when I cmd+click on a QSharedPointer class.
-
Really strange, can you post the the content of that qsharedpointer_impl.h ? You can use e.g. "pastebin":http://pastebin.com for that
-
It is strange and it feels strange too...
I pasted qsharedpointer_impl.h on http://pastebin.com/5AA96SPV
-
I've check the 5.2.1 iOS installer and qsharedpointer_impl.h looks good
-
Sure everything works fine. It's just that on line 304 you can see the matrixData() function which is public and undocumented and I can not find the data() function anywhere on OSX. Besides not being conform with the docs (and a little bit less cross-platform), there's no problem at all.
I came over this by defining a helper function that returns either matrixData() or data() depending on the platform.
BTW I have Qt5.2.0, not 5.2.1, maybe there's a difference?
-
Indeed, but it's really something strange. I've looked at the file's history and at no time there's a matrixData in it.
It might have been modify externally (e.g. a wild search/replace)
Can you reinstall your 5.2.0 to see if it's still the case ?
-
ooooh, perhaps you're right. Maybe a refactor, I have plenty of functions named data operating on shared pointers. Maybe I refactored one of them while using a . instead of a -> thus refactoring the shared pointer's function.
Shouldn't QtCreator warn before modifying external files?
Anyway, I'll reinstall and keep you informed. Thanks for the insight.
Cheers
-
I don't know if all version have it but in recent ones, you should get a message at the top of the text editor that warns you about that. However if you are doing this using a global search/replace that modifies several unfocused documents you won't see it for these.
-
That was the problem. The modification date of qsharedpointer_impl.h does not lie.
I simply refactored it back to its original name and removed my helper function. Everything back to normal now.
Thank you for your time. My app would have compiled only on my computer otherwise.
-
You're welcome !
Now that you have Qt back to normal and working, please update the thread title prepending [solved] so other forum users may know a solution has been found :)