Things would go weird if a plugin opens a new file dialog in the file callback, prevent this by clearing the string before the callback.pull/162/head
@@ -780,8 +780,9 @@ struct Window::PrivateData { | |||||
#if defined(DISTRHO_OS_WINDOWS) && !defined(DGL_FILE_BROWSER_DISABLED) | #if defined(DISTRHO_OS_WINDOWS) && !defined(DGL_FILE_BROWSER_DISABLED) | ||||
if (fSelectedFile.isNotEmpty()) | if (fSelectedFile.isNotEmpty()) | ||||
{ | { | ||||
fView->fileSelectedFunc(fView, fSelectedFile.buffer()); | |||||
fSelectedFile.clear(); | |||||
char* const buffer = fSelectedFile.getAndReleaseBuffer(); | |||||
fView->fileSelectedFunc(fView, buffer); | |||||
std::free(buffer); | |||||
} | } | ||||
#endif | #endif | ||||
@@ -568,6 +568,18 @@ public: | |||||
return fBuffer; | return fBuffer; | ||||
} | } | ||||
/* | |||||
* Get and release the string buffer, while also clearing this string. | |||||
* Result must be freed. | |||||
*/ | |||||
char* getAndReleaseBuffer() noexcept | |||||
{ | |||||
char* const ret = fBuffer; | |||||
fBuffer = _null(); | |||||
fBufferLen = 0; | |||||
return ret; | |||||
} | |||||
// ------------------------------------------------------------------- | // ------------------------------------------------------------------- | ||||
// base64 stuff, based on http://www.adp-gmbh.ch/cpp/common/base64.html | // base64 stuff, based on http://www.adp-gmbh.ch/cpp/common/base64.html | ||||
// Copyright (C) 2004-2008 René Nyffenegger | // Copyright (C) 2004-2008 René Nyffenegger | ||||