Fix crash when adding resources to resources tab

A crash could occur if the plugin window was closed and reopened and a
new resource was added to either the Variable, Action queue, Websocket,
or Twitch tab.

No context object was provided to the signal handlers.
The signal provider is intentionally not deleted when the UI is closed.
Because of this, the signal connections were never cleared when the
underlying tab widget was destroyed.
So, in the case of closing and reopening the settings window, the old
connection with the outdated widget pointers would be called again.
This commit is contained in:
WarmUpTill 2024-06-03 21:07:36 +02:00 committed by WarmUpTill
parent 45967a090f
commit b7516cac5b
4 changed files with 12 additions and 11 deletions

View File

@ -220,14 +220,15 @@ static void setupTab(QTabWidget *tab)
}
QWidget::connect(ActionQueueSignalManager::Instance(),
&ActionQueueSignalManager::Rename,
&ActionQueueSignalManager::Rename, tab,
[](const QString &oldName, const QString &newName) {
RenameItemTableRow(tabWidget->Table(), oldName,
newName);
});
QWidget::connect(
ActionQueueSignalManager::Instance(),
&ActionQueueSignalManager::Add, [tab](const QString &name) {
&ActionQueueSignalManager::Add, tab,
[tab](const QString &name) {
AddItemTableRow(
tabWidget->Table(),
getCellLabels(GetWeakActionQueueByQString(name)
@ -238,7 +239,7 @@ static void setupTab(QTabWidget *tab)
setTabVisible(tab, true);
});
QWidget::connect(ActionQueueSignalManager::Instance(),
&ActionQueueSignalManager::Remove,
&ActionQueueSignalManager::Remove, tab,
[](const QString &name) {
RemoveItemTableRow(tabWidget->Table(), name);
if (tabWidget->Table()->rowCount() == 0) {

View File

@ -273,14 +273,14 @@ static void setupTab(QTabWidget *tab)
}
QWidget::connect(VariableSignalManager::Instance(),
&VariableSignalManager::Rename,
&VariableSignalManager::Rename, tab,
[](const QString &oldName, const QString &newName) {
RenameItemTableRow(tabWidget->Table(), oldName,
newName);
});
QWidget::connect(
VariableSignalManager::Instance(), &VariableSignalManager::Add,
[tab](const QString &name) {
tab, [tab](const QString &name) {
AddItemTableRow(
tabWidget->Table(),
getCellLabels(GetVariableByQString(name)));
@ -289,7 +289,7 @@ static void setupTab(QTabWidget *tab)
setTabVisible(tab, true);
});
QWidget::connect(VariableSignalManager::Instance(),
&VariableSignalManager::Remove,
&VariableSignalManager::Remove, tab,
[](const QString &name) {
RemoveItemTableRow(tabWidget->Table(), name);
if (tabWidget->Table()->rowCount() == 0) {

View File

@ -207,14 +207,14 @@ static void setupTab(QTabWidget *tab)
}
QWidget::connect(ConnectionSelectionSignalManager::Instance(),
&ConnectionSelectionSignalManager::Rename,
&ConnectionSelectionSignalManager::Rename, tab,
[](const QString &oldName, const QString &newName) {
RenameItemTableRow(tabWidget->Table(), oldName,
newName);
});
QWidget::connect(
ConnectionSelectionSignalManager::Instance(),
&ConnectionSelectionSignalManager::Add,
&ConnectionSelectionSignalManager::Add, tab,
[tab](const QString &name) {
AddItemTableRow(
tabWidget->Table(),
@ -224,7 +224,7 @@ static void setupTab(QTabWidget *tab)
setTabVisible(tab, true);
});
QWidget::connect(ConnectionSelectionSignalManager::Instance(),
&ConnectionSelectionSignalManager::Remove,
&ConnectionSelectionSignalManager::Remove, tab,
[](const QString &name) {
RemoveItemTableRow(tabWidget->Table(), name);
if (tabWidget->Table()->rowCount() == 0) {

View File

@ -196,7 +196,7 @@ static void setupTab(QTabWidget *tab)
QWidget::connect(
TwitchConnectionSignalManager::Instance(),
&TwitchConnectionSignalManager::Add,
&TwitchConnectionSignalManager::Add, tab,
[tab](const QString &name) {
AddItemTableRow(
tabWidget->Table(),
@ -208,7 +208,7 @@ static void setupTab(QTabWidget *tab)
setTabVisible(tab, true);
});
QWidget::connect(TwitchConnectionSignalManager::Instance(),
&TwitchConnectionSignalManager::Remove,
&TwitchConnectionSignalManager::Remove, tab,
[](const QString &name) {
RemoveItemTableRow(tabWidget->Table(), name);
if (tabWidget->Table()->rowCount() == 0) {