146 return true; |
146 return true; |
147 } |
147 } |
148 |
148 |
149 // ============================================================================= |
149 // ============================================================================= |
150 // ----------------------------------------------------------------------------- |
150 // ----------------------------------------------------------------------------- |
151 void writeObjects (List<LDObject*>& objects, File& f) |
151 void writeObjects (QList<LDObject*>& objects, File& f) |
152 { for (LDObject * obj : objects) |
152 { for (LDObject * obj : objects) |
153 { if (obj->getType() == LDObject::Subfile) |
153 { if (obj->getType() == LDObject::Subfile) |
154 { LDSubfile* ref = static_cast<LDSubfile*> (obj); |
154 { LDSubfile* ref = static_cast<LDSubfile*> (obj); |
155 List<LDObject*> objs = ref->inlineContents (LDSubfile::DeepInline); |
155 QList<LDObject*> objs = ref->inlineContents (LDSubfile::DeepInline); |
156 |
156 |
157 writeObjects (objs, f); |
157 writeObjects (objs, f); |
158 |
158 |
159 for (LDObject * obj : objs) |
159 for (LDObject * obj : objs) |
160 delete obj; |
160 delete obj; |
164 } |
164 } |
165 } |
165 } |
166 |
166 |
167 // ============================================================================= |
167 // ============================================================================= |
168 // ----------------------------------------------------------------------------- |
168 // ----------------------------------------------------------------------------- |
169 void writeObjects (List<LDObject*>& objects, str fname) |
169 void writeObjects (QList<LDObject*>& objects, str fname) |
170 { // Write the input file |
170 { // Write the input file |
171 File f (fname, File::Write); |
171 File f (fname, File::Write); |
172 |
172 |
173 if (!f) |
173 if (!f) |
174 { critical (fmt ("Couldn't open temporary file %1 for writing.\n", fname)); |
174 { critical (fmt ("Couldn't open temporary file %1 for writing.\n", fname)); |
186 } |
186 } |
187 |
187 |
188 // ============================================================================= |
188 // ============================================================================= |
189 // ----------------------------------------------------------------------------- |
189 // ----------------------------------------------------------------------------- |
190 void writeColorGroup (const short colnum, str fname) |
190 void writeColorGroup (const short colnum, str fname) |
191 { List<LDObject*> objects; |
191 { QList<LDObject*> objects; |
192 |
192 |
193 for (LDObject * obj : LDFile::current()->objects()) |
193 for (LDObject * obj : LDFile::current()->objects()) |
194 { if (obj->isColored() == false || obj->color() != colnum) |
194 { if (obj->isColored() == false || obj->color() != colnum) |
195 continue; |
195 continue; |
196 |
196 |
258 return true; |
258 return true; |
259 } |
259 } |
260 |
260 |
261 // ============================================================================= |
261 // ============================================================================= |
262 // ----------------------------------------------------------------------------- |
262 // ----------------------------------------------------------------------------- |
263 static void insertOutput (str fname, bool replace, List<short> colorsToReplace) |
263 static void insertOutput (str fname, bool replace, QList<short> colorsToReplace) |
264 { |
264 { |
265 #ifndef RELEASE |
265 #ifndef RELEASE |
266 QFile::copy (fname, "./debug_lastOutput"); |
266 QFile::copy (fname, "./debug_lastOutput"); |
267 #endif // RELEASE |
267 #endif // RELEASE |
268 |
268 |
272 if (!f) |
272 if (!f) |
273 { critical (fmt ("Couldn't open temporary file %1 for reading.\n", fname)); |
273 { critical (fmt ("Couldn't open temporary file %1 for reading.\n", fname)); |
274 return; |
274 return; |
275 } |
275 } |
276 |
276 |
277 List<LDObject*> objs = loadFileContents (&f, null); |
277 QList<LDObject*> objs = loadFileContents (&f, null); |
278 |
278 |
279 // If we replace the objects, delete the selection now. |
279 // If we replace the objects, delete the selection now. |
280 if (replace) |
280 if (replace) |
281 g_win->deleteSelection(); |
281 g_win->deleteSelection(); |
282 |
282 |