mirror of
https://github.com/libretro/RetroArch
synced 2025-04-23 11:43:20 +00:00
(Qt) Fix crash when loading content via desktop menu while content is already running (#13595)
This commit is contained in:
parent
e541dd5ab1
commit
412c79862c
@ -2772,6 +2772,7 @@ void MainWindow::loadContent(const QHash<QString, QString> &contentHash)
|
|||||||
QByteArray contentDbNameArray;
|
QByteArray contentDbNameArray;
|
||||||
QByteArray contentCrc32Array;
|
QByteArray contentCrc32Array;
|
||||||
char contentDbNameFull[PATH_MAX_LENGTH];
|
char contentDbNameFull[PATH_MAX_LENGTH];
|
||||||
|
char corePathCached[PATH_MAX_LENGTH];
|
||||||
const char *corePath = NULL;
|
const char *corePath = NULL;
|
||||||
const char *contentPath = NULL;
|
const char *contentPath = NULL;
|
||||||
const char *contentLabel = NULL;
|
const char *contentLabel = NULL;
|
||||||
@ -2782,6 +2783,7 @@ void MainWindow::loadContent(const QHash<QString, QString> &contentHash)
|
|||||||
core_info_t *coreInfo = NULL;
|
core_info_t *coreInfo = NULL;
|
||||||
|
|
||||||
contentDbNameFull[0] = '\0';
|
contentDbNameFull[0] = '\0';
|
||||||
|
corePathCached[0] = '\0';
|
||||||
|
|
||||||
if (m_pendingRun)
|
if (m_pendingRun)
|
||||||
coreSelection = CORE_SELECTION_CURRENT;
|
coreSelection = CORE_SELECTION_CURRENT;
|
||||||
@ -2882,6 +2884,15 @@ void MainWindow::loadContent(const QHash<QString, QString> &contentHash)
|
|||||||
!string_is_empty(coreInfo->path))
|
!string_is_empty(coreInfo->path))
|
||||||
corePath = coreInfo->path;
|
corePath = coreInfo->path;
|
||||||
|
|
||||||
|
/* If a core is currently running, the following
|
||||||
|
* call of 'command_event(CMD_EVENT_UNLOAD_CORE, NULL)'
|
||||||
|
* will free the global core_info struct, which will
|
||||||
|
* in turn free the pointer referenced by coreInfo->path.
|
||||||
|
* This will invalidate corePath, so we have to cache
|
||||||
|
* its current value here. */
|
||||||
|
if (!string_is_empty(corePath))
|
||||||
|
strlcpy(corePathCached, corePath, sizeof(corePathCached));
|
||||||
|
|
||||||
/* Add lpl extension to db_name, if required */
|
/* Add lpl extension to db_name, if required */
|
||||||
if (!string_is_empty(contentDbName))
|
if (!string_is_empty(contentDbName))
|
||||||
{
|
{
|
||||||
@ -2910,7 +2921,7 @@ void MainWindow::loadContent(const QHash<QString, QString> &contentHash)
|
|||||||
command_event(CMD_EVENT_UNLOAD_CORE, NULL);
|
command_event(CMD_EVENT_UNLOAD_CORE, NULL);
|
||||||
|
|
||||||
if (!task_push_load_content_with_new_core_from_companion_ui(
|
if (!task_push_load_content_with_new_core_from_companion_ui(
|
||||||
corePath, contentPath, contentLabel, contentDbNameFull, contentCrc32,
|
corePathCached, contentPath, contentLabel, contentDbNameFull, contentCrc32,
|
||||||
&content_info, NULL, NULL))
|
&content_info, NULL, NULL))
|
||||||
{
|
{
|
||||||
QMessageBox::critical(this, msg_hash_to_str(MSG_ERROR),
|
QMessageBox::critical(this, msg_hash_to_str(MSG_ERROR),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user