aboutsummaryrefslogtreecommitdiff
path: root/qt/common
diff options
context:
space:
mode:
Diffstat (limited to 'qt/common')
-rw-r--r--qt/common/smart-ptr/driver.cxx25
-rw-r--r--qt/common/smart-ptr/test.hxx23
2 files changed, 48 insertions, 0 deletions
diff --git a/qt/common/smart-ptr/driver.cxx b/qt/common/smart-ptr/driver.cxx
index ee53c57..49e2ae1 100644
--- a/qt/common/smart-ptr/driver.cxx
+++ b/qt/common/smart-ptr/driver.cxx
@@ -212,6 +212,31 @@ main (int argc, char* argv[])
t.commit ();
}
+
+ //
+ // Test QSharedPointer as a value wrapper.
+ //
+
+ {
+ obj2 o1 (1);
+ obj2 o2 (2);
+ o2.num = QSharedPointer<unsigned long> (new unsigned long (123));
+
+ transaction t (db->begin ());
+ db->persist (o1);
+ db->persist (o2);
+ t.commit ();
+ }
+
+ {
+ transaction t (db->begin ());
+ QSharedPointer<obj2> o1 (db->load<obj2> (1));
+ QSharedPointer<obj2> o2 (db->load<obj2> (2));
+ t.commit ();
+
+ assert (!o1->num);
+ assert (o2->num && *o2->num == 123);
+ }
}
catch (const odb::exception& e)
{
diff --git a/qt/common/smart-ptr/test.hxx b/qt/common/smart-ptr/test.hxx
index 0a4ce03..86e4fba 100644
--- a/qt/common/smart-ptr/test.hxx
+++ b/qt/common/smart-ptr/test.hxx
@@ -8,6 +8,8 @@
#include <vector>
+#include <QtCore/QSharedPointer>
+
#include <odb/core.hxx>
#include <odb/qt/lazy-ptr.hxx>
@@ -53,4 +55,25 @@ struct obj
QLazySharedPointer<cont> c;
};
+// Test QSharedPointer as a value wrapper.
+//
+#pragma db object
+struct obj2
+{
+ obj2 ()
+ {
+ }
+
+ obj2 (unsigned long id)
+ : id (id)
+ {
+ }
+
+ #pragma db id
+ unsigned long id;
+
+ #pragma db null
+ QSharedPointer<unsigned long> num;
+};
+
#endif // TEST_HXX