UI: Avoid having two dock with the same object name
https://doc.qt.io/qt-6/qmainwindow.html#saveState You should make sure that this property is unique for each QToolBar and QDockWidget you add to the QMainWindow.
This commit is contained in:
parent
df3b294fc3
commit
f2fa54120a
3 changed files with 61 additions and 1 deletions
|
|
@ -379,7 +379,23 @@ struct OBSStudioAPI : obs_frontend_callbacks {
|
|||
|
||||
void *obs_frontend_add_dock(void *dock) override
|
||||
{
|
||||
return (void *)main->AddDockWidget((QDockWidget *)dock);
|
||||
QDockWidget *d = reinterpret_cast<QDockWidget *>(dock);
|
||||
|
||||
QString name = d->objectName();
|
||||
if (name.isEmpty() || main->IsDockObjectNameUsed(name)) {
|
||||
blog(LOG_WARNING,
|
||||
"The object name of the added dock is empty or already used,"
|
||||
" a temporary one will be set to avoid conflicts");
|
||||
|
||||
char *uuid = os_generate_uuid();
|
||||
name = QT_UTF8(uuid);
|
||||
bfree(uuid);
|
||||
name.append("_oldExtraDock");
|
||||
|
||||
d->setObjectName(name);
|
||||
}
|
||||
|
||||
return (void *)main->AddDockWidget(d);
|
||||
}
|
||||
|
||||
void obs_frontend_add_event_callback(obs_frontend_event_cb callback,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue