fix: improve defensive cstring copying

Intended to prevent Nim from inopportunely garbage collecting cstrings passed
through signal_handler/dos_signal as they make their way back to the main
thread
This commit is contained in:
Michael Bradley, Jr 2021-03-10 16:18:29 -06:00 committed by Eric Mastro
parent 81ea295cc2
commit 25e70373f8

View File

@ -864,8 +864,9 @@ bool dos_qurl_isValid(const ::DosQUrl *vptr)
void dos_signal(::DosQObject *vptr, const char *signal, const char *slot) //
{
auto qobject = static_cast<QObject *>(vptr);
std::string copy = signal; // signal comes from nim, and might be GC. Creating a copy (QT will handle the freeing)
QMetaObject::invokeMethod(qobject, slot, Qt::QueuedConnection, Q_ARG(QString, copy.c_str()));
std::string signal_copy = signal;
std::string slot_copy = slot;
QMetaObject::invokeMethod(qobject, slot_copy.c_str(), Qt::QueuedConnection, Q_ARG(QString, signal_copy.c_str()));
}
void dos_qmetaobject_delete(::DosQMetaObject *vptr)