@@ -196,14 +196,17 @@ std::vector<Object> Patch::getObjects(bool onlyGui) noexcept
196196std::unique_ptr<Object> Patch::createGraphOnParent (int x, int y)
197197{
198198 t_pd* pdobject = nullptr ;
199+ std::atomic<bool > done = false ;
200+
199201 instance->enqueueFunction (
200- [this , x, y, &pdobject]() mutable
202+ [this , x, y, &pdobject, &done ]() mutable
201203 {
202204 setCurrent ();
203205 pdobject = libpd_creategraphonparent (getPointer (), x, y);
206+ done = true ;
204207 });
205208
206- while (!pdobject )
209+ while (!done )
207210 {
208211 instance->waitForStateUpdate ();
209212 }
@@ -216,14 +219,17 @@ std::unique_ptr<Object> Patch::createGraphOnParent(int x, int y)
216219std::unique_ptr<Object> Patch::createGraph (const String& name, int size, int x, int y)
217220{
218221 t_pd* pdobject = nullptr ;
222+ std::atomic<bool > done = false ;
223+
219224 instance->enqueueFunction (
220- [this , name, size, x, y, &pdobject]() mutable
225+ [this , name, size, x, y, &pdobject, &done ]() mutable
221226 {
222227 setCurrent ();
223228 pdobject = libpd_creategraph (getPointer (), name.toRawUTF8 (), size, x, y);
229+ done = true ;
224230 });
225231
226- while (!pdobject )
232+ while (!done )
227233 {
228234 instance->waitForStateUpdate ();
229235 }
@@ -304,14 +310,17 @@ std::unique_ptr<Object> Patch::createObject(const String& name, int x, int y, bo
304310 }
305311
306312 t_pd* pdobject = nullptr ;
313+ std::atomic<bool > done = false ;
314+
307315 instance->enqueueFunction (
308- [this , argc, argv, undoable, typesymbol, &pdobject]() mutable
316+ [this , argc, argv, undoable, typesymbol, &pdobject, &done ]() mutable
309317 {
310318 setCurrent ();
311319 pdobject = libpd_createobj (getPointer (), typesymbol, argc, argv.data (), undoable);
320+ done = true ;
312321 });
313322
314- while (!pdobject )
323+ while (!done )
315324 {
316325 instance->waitForStateUpdate ();
317326 }
0 commit comments