128 tmp.close(); |
128 tmp.close(); |
129 return true; |
129 return true; |
130 } |
130 } |
131 |
131 |
132 // ============================================================================= |
132 // ============================================================================= |
133 void writeObjects (vector<LDObject*>& objects, File& f) { |
133 void writeObjects (List<LDObject*>& objects, File& f) { |
134 for (LDObject* obj : objects) { |
134 for (LDObject* obj : objects) { |
135 if (obj->getType() == LDObject::Subfile) { |
135 if (obj->getType() == LDObject::Subfile) { |
136 vector<LDObject*> objs = static_cast<LDSubfileObject*> (obj)->inlineContents (true, false); |
136 List<LDObject*> objs = static_cast<LDSubfileObject*> (obj)->inlineContents (true, false); |
137 |
137 |
138 writeObjects (objs, f); |
138 writeObjects (objs, f); |
139 |
139 |
140 for (LDObject* obj : objs) |
140 for (LDObject* obj : objs) |
141 delete obj; |
141 delete obj; |
142 } else |
142 } else |
143 f.write (obj->raw() + "\r\n"); |
143 f.write (obj->raw() + "\r\n"); |
144 } |
144 } |
145 } |
145 } |
146 |
146 |
147 void writeObjects (vector<LDObject*>& objects, str fname) { |
147 void writeObjects (List<LDObject*>& objects, str fname) { |
148 // Write the input file |
148 // Write the input file |
149 File f (fname, File::Write); |
149 File f (fname, File::Write); |
150 |
150 |
151 if (!f) { |
151 if (!f) { |
152 critical (fmt ("Couldn't open temporary file %1 for writing.\n", fname)); |
152 critical (fmt ("Couldn't open temporary file %1 for writing.\n", fname)); |
162 writeObjects (g_win->sel(), fname); |
162 writeObjects (g_win->sel(), fname); |
163 } |
163 } |
164 |
164 |
165 // ============================================================================= |
165 // ============================================================================= |
166 void writeColorGroup (const short colnum, str fname) { |
166 void writeColorGroup (const short colnum, str fname) { |
167 vector<LDObject*> objects; |
167 List<LDObject*> objects; |
168 |
168 |
169 for (LDObject* obj : *LDOpenFile::current()) { |
169 for (LDObject* obj : *LDOpenFile::current()) { |
170 if (obj->isColored() == false || obj->color() != colnum) |
170 if (obj->isColored() == false || obj->color() != colnum) |
171 continue; |
171 continue; |
172 |
172 |
230 |
230 |
231 return true; |
231 return true; |
232 } |
232 } |
233 |
233 |
234 // ================================================================================================ |
234 // ================================================================================================ |
235 static void insertOutput (str fname, bool replace, vector<short> colorsToReplace) { |
235 static void insertOutput (str fname, bool replace, List<short> colorsToReplace) { |
236 #ifndef RELEASE |
236 #ifndef RELEASE |
237 QFile::copy (fname, "./debug_lastOutput"); |
237 QFile::copy (fname, "./debug_lastOutput"); |
238 #endif // RELEASE |
238 #endif // RELEASE |
239 |
239 |
240 // Read the output file |
240 // Read the output file |
243 if (!f) { |
243 if (!f) { |
244 critical (fmt ("Couldn't open temporary file %1 for reading.\n", fname)); |
244 critical (fmt ("Couldn't open temporary file %1 for reading.\n", fname)); |
245 return; |
245 return; |
246 } |
246 } |
247 |
247 |
248 vector<LDObject*> objs = loadFileContents (&f, null); |
248 List<LDObject*> objs = loadFileContents (&f, null); |
249 |
249 |
250 // If we replace the objects, delete the selection now. |
250 // If we replace the objects, delete the selection now. |
251 if (replace) |
251 if (replace) |
252 g_win->deleteSelection(); |
252 g_win->deleteSelection(); |
253 |
253 |