30 CFGENTRY (String, defaultName, ""); |
30 CFGENTRY (String, defaultName, ""); |
31 CFGENTRY (String, defaultUser, ""); |
31 CFGENTRY (String, defaultUser, ""); |
32 CFGENTRY (Int, defaultLicense, 0); |
32 CFGENTRY (Int, defaultLicense, 0); |
33 |
33 |
34 // List of all LDObjects |
34 // List of all LDObjects |
35 static QMap<long, LDObjectWeakPtr> g_allObjects; |
35 static QMap<long, LDObjectWeakPtr> g_allObjects; |
|
36 static int32 g_idcursor = 1; // 0 shalt be null |
|
37 static constexpr int32 g_maxID = (1 << 24); |
36 |
38 |
37 #define LDOBJ_DEFAULT_CTOR(T,BASE) \ |
39 #define LDOBJ_DEFAULT_CTOR(T,BASE) \ |
38 T :: T (LDObjectPtr* selfptr) : \ |
40 T :: T (LDObjectPtr* selfptr) : \ |
39 BASE (selfptr) {} |
41 BASE (selfptr) {} |
40 |
42 |
75 |
77 |
76 // ============================================================================= |
78 // ============================================================================= |
77 // |
79 // |
78 void LDObject::chooseID() |
80 void LDObject::chooseID() |
79 { |
81 { |
80 int32 id = 1; // 0 shalt be null |
82 // If this is the first pass we can just use a global ID counter for each |
81 |
83 // unique object. Let's nobody goes to create 17 million objects anytime |
82 for (auto it = g_allObjects.begin(); it != g_allObjects.end(); ++it) |
84 // soon. |
83 { |
85 if (g_idcursor < g_maxID) |
84 LDObjectPtr obj = it->toStrongRef(); |
86 { |
85 |
87 setID (g_idcursor++); |
86 assert (obj != this); |
88 return; |
87 assert (obj != null); |
89 } |
88 |
90 |
89 if (obj->id() >= id) |
91 // In case someone does, we cannot really continue execution. We must abort, |
90 id = obj->id() + 1; |
92 // give the user a chance to save their documents though. |
91 } |
93 critical ("Created too many objects. Execution cannot continue. You have a " |
92 |
94 "chance to save any changes to documents, then restart."); |
93 setID (id); |
95 (void) safeToCloseAll(); |
|
96 exit (0); |
94 } |
97 } |
95 |
98 |
96 // ============================================================================= |
99 // ============================================================================= |
97 // |
100 // |
98 void LDObject::setVertexCoord (int i, Axis ax, double value) |
101 void LDObject::setVertexCoord (int i, Axis ax, double value) |