253
|
1 /**
|
|
2 *
|
|
3 * Copyright: Copyright QtD Team, 2008-2009
|
|
4 * License: <a href="http://www.boost.org/LICENSE_1_0.txt>Boost License 1.0</a>
|
|
5 *
|
|
6 * Copyright QtD Team, 2008-2009
|
|
7 * Distributed under the Boost Software License, Version 1.0.
|
|
8 * (See accompanying file boost-license-1.0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
|
9 *
|
|
10 */
|
|
11
|
|
12 module qt.QtdObject;
|
|
13
|
|
14 import qt.Signal;
|
|
15 //import tango.io.Stdout;
|
|
16
|
|
17 enum QtdObjectFlags : ubyte
|
|
18 {
|
|
19 none,
|
|
20 nativeOwnership = 0x1,
|
|
21 dOwnership = 0x2,
|
|
22 dynamicEntity = 0x4
|
|
23 //gcManaged = 0x4
|
|
24 }
|
|
25
|
|
26 package abstract class QtdObject
|
|
27 {
|
|
28 protected QtdObjectFlags __flags_;
|
|
29 void* __nativeId;
|
256
|
30
|
253
|
31 mixin SignalHandlerOps;
|
256
|
32
|
253
|
33 this(void* nativeId, QtdObjectFlags flags = QtdObjectFlags.none)
|
|
34 {
|
|
35 //Stdout.formatln("Created D object {} {:x}", nativeId, flags).newline;
|
|
36 __nativeId = nativeId;
|
|
37 __flags_ = flags;
|
|
38 }
|
|
39
|
|
40 final QtdObjectFlags __flags()
|
|
41 {
|
|
42 return __flags_;
|
|
43 }
|
|
44
|
|
45 /+ final +/ void __setFlags(QtdObjectFlags flags, bool value)
|
|
46 {
|
|
47 if (value)
|
|
48 __flags_ |= flags;
|
|
49 else
|
|
50 __flags_ &= ~flags;
|
|
51 }
|
|
52
|
|
53 // COMPILER BUG: 3206
|
|
54 protected void __deleteNative()
|
|
55 {
|
|
56 assert(false);
|
|
57 }
|
|
58
|
|
59 ~this()
|
|
60 {
|
|
61 //Stdout.formatln("Deleting D object {}", __nativeId);
|
|
62 if (!(__flags_ & QtdObjectFlags.nativeOwnership))
|
|
63 {
|
|
64 // avoid deleting D object twice.
|
|
65 //Stdout.formatln("About to delete native object {}", __nativeId);
|
|
66 __flags_ |= QtdObjectFlags.dOwnership;
|
|
67 __deleteNative;
|
|
68 }
|
|
69 //Stdout.formatln("Deleted native D object {}", __nativeId);
|
|
70 }
|
|
71 } |