chris all is working as it should now, you were right but i found some weird behavior.

everytime i pass float types or double or long double, etc qvariant class emit a crash, i tried with almost any other type including QT ones and it work perfectly it just crash with floating point values

here is the back trace

#0 0x00007ffff6787383 in QVariant::~QVariant() () from /usr/lib/libQtCore.so.4
#1 0x00007ffff7bd9935 in RDCI::RDebugData::~RDebugData (this=0x60a940, __in_chrg=<value optimized out>) at rdcitypes_p.hpp:9
#2 0x00007ffff7bd9a07 in QSharedDataPointer<RDCI::RDebugData>::~QSharedData Pointer (this=0x7fffffffe008,
__in_chrg=<value optimized out>) at /usr/include/qt4/QtCore/qshareddata.h:90
#3 0x00007ffff7bd938e in RDCI::RDebug::~RDebug (this=0x7fffffffe000, __in_chrg=<value optimized out>) at rdcitypes.cpp:5
#4 0x000000000040189e in main (argc=1, argv=0x7fffffffe178) at ../rdcitest/main.cpp:10

my code

main.cpp
Qt Code:
  1. #include <QtCore/QCoreApplication>
  2. #include "rdcitypes.hpp"
  3. int main(int argc, char *argv[])
  4. {
  5. QCoreApplication a(argc, argv);
  6. using namespace std;
  7. using namespace RDCI;
  8. QString var = "hola";
  9. float var2 = 500;
  10. RDebug prueba;
  11. cout << prueba.saveValues(var2) << endl;
  12. cout << prueba.getSourceLocation().toStdString() << endl;
  13. cout << prueba.getSize() << endl;
  14. return 0;
  15. }
To copy to clipboard, switch view to plain text mode 

rdcitypes_p.hpp
Qt Code:
  1. #ifndef RDCITYPES_P_H
  2. #define RDCITYPES_P_H
  3.  
  4. #include "definitions.hpp"
  5.  
  6. namespace RDCI
  7. {
  8. class SO_LOCAL RDebugData : public QSharedData
  9. {
  10. public:
  11. RDebugData()
  12. {}
  13. RDebugData(const RDebugData &other)
  14. : QSharedData(other), fileName(other.fileName), sourceLocation(other.sourceLocation), varName(other.varName), lineNumber(other.lineNumber), Value(other.Value), size(other.size)
  15. { }
  16. ~RDebugData()
  17. {}
  18. QString fileName, sourceLocation, varName;
  19. quint64 lineNumber, size;
  20. QVariant Value;
  21. };
  22. }
  23. #endif
To copy to clipboard, switch view to plain text mode 

rdcitypes.hpp
Qt Code:
  1. #ifndef RDCITYPES_H
  2. #define RDCITYPES_H
  3.  
  4. #include "rdcitypes_p.hpp"
  5.  
  6. namespace RDCI
  7. {
  8. class RDebugData;
  9. class SO_PUBLIC RDebug
  10. {
  11. public:
  12. RDebug()
  13. {
  14. d = new RDebugData;
  15. }
  16. RDebug(const RDebug &other): d (other.d)
  17. {}
  18. virtual ~RDebug();
  19. bool isEmpty();
  20. QVariant getValue() const
  21. {
  22. return d->Value;
  23. }
  24. QString getFileName() const
  25. {
  26. return d->fileName;
  27. }
  28. QString getSourceLocation() const
  29. {
  30. return d->sourceLocation;
  31. }
  32. QString getVarName() const
  33. {
  34. return d->varName;
  35. }
  36. quint64 getLineNumber() const
  37. {
  38. return d->lineNumber;
  39. }
  40. quint64 getSize() const
  41. {
  42. return d->size;
  43. }
  44. template <typename U>
  45. U saveValues_p(U const &value, const QString &varname, quint64 linenumber, const QString &filename, const QString &sourcelocation, const quint64 size)
  46. {
  47. d->varName = varname;
  48. d->lineNumber = linenumber;
  49. d->fileName = filename;
  50. d->sourceLocation = sourcelocation;
  51. d->Value = value;
  52. d->size = size;
  53. return value;
  54. }
  55. private:
  56. QSharedDataPointer<RDebugData> d;
  57. };
  58.  
  59. }
  60. #endif // RDCITYPES_H
To copy to clipboard, switch view to plain text mode 

definition.hpp
Qt Code:
  1. ifndef DEFINITIONS_H
  2. #define DEFINITIONS_H
  3.  
  4. #include <QtPlugin>
  5. #include <QObject>
  6. #include <QMetaType>
  7. #include <QSharedData>
  8. #include <QSharedDataPointer>
  9. #include <QtCore/QVariant>
  10. #include <QtDBus/QDBusConnection>
  11. #include <QtDBus/QDBusMessage>
  12. #include <QtDBus/QtDBus>
  13. #include <QtCore/QList>
  14.  
  15. #include <sys/types.h>
  16. #include <iostream>
  17. #include <algorithm>
  18.  
  19. namespace RDCI
  20. {
  21.  
  22. #if __GNUC__ >= 4
  23. #define SO_PUBLIC __attribute__ ((visibility("default")))
  24. #define SO_LOCAL __attribute__ ((visibility("hidden")))
  25. #define saveValues(value) \
  26. saveValues_p( value, #value, __LINE__, __FILE__, __PRETTY_FUNCTION__, sizeof(value))
  27. #endif
  28. }
  29. #endif /* DEFINITIONS_H */
To copy to clipboard, switch view to plain text mode