Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scripting: Dialog.SameWidgetRows not working as expected #3607

Closed
eishiya opened this issue Mar 9, 2023 · 2 comments · Fixed by #3638
Closed

Scripting: Dialog.SameWidgetRows not working as expected #3607

eishiya opened this issue Mar 9, 2023 · 2 comments · Fixed by #3638
Assignees
Labels
bug Broken behavior.

Comments

@eishiya
Copy link
Contributor

eishiya commented Mar 9, 2023

When adding various widgets to a Dialog with row mode Dialog.SameWidgetRows (the default), new rows aren't always created when they should be.

It seems that the type of the previous widget is only checked (to potentially add a new row) for the 2nd widget onwards, the first widget in each row will not cause a break no matter what's added after it.

For example, if I make a Dialog like this:

let dialog = new Dialog("Same Widget Rows Test");
dialog.newRowMode = Dialog.SameWidgetRows; //Just for clarity. This is the default newRowMode.

dialog.addTextInput("Text input");
dialog.addTextInput("Text input");
dialog.addButton("Button");
dialog.addTextInput("Text input");
dialog.addButton("Button");
dialog.addCheckBox("Checkbox");
dialog.addTextInput("Text input");
dialog.addCheckBox("Checkbox");
dialog.addCheckBox("Checkbox");
dialog.addButton("Button");
dialog.addButton("Button");
dialog.addCheckBox("Checkbox");
dialog.addCheckBox("Checkbox");
dialog.addButton("Button");
dialog.addButton("Button");
dialog.addCheckBox("Checkbox");
dialog.addComboBox("ComboBox", ["option"]);
dialog.addButton("Button");

dialog.show();

I expect a Dialog that looks like this:
image
But what I actually get is this:
image

I observed this behaviour in 1.9.1 (Qt5) and in a 2023.03.07 nightly (Qt6), on Windows 10.

@eishiya eishiya added the bug Broken behavior. label Mar 9, 2023
bjorn added a commit to bjorn/tiled-dev that referenced this issue Mar 29, 2023
When a new row was created automatically when adding a widget, it was
failing to remember the type of that widget, since addNewRow was called
after setting m_lastWidgetTypeName.

Now the last widget type is set in addDialogWidget instead. Also, we no
longer compare the type names but just compare the QMetaObject pointers
directly.

Also fixed a problem in ScriptDialog::deleteAllDialogs, which iterated
the sDialogInstances container while it was also getting modified as
each dialog was deleted.

Closes mapeditor#3607
@bjorn bjorn self-assigned this Mar 29, 2023
@bjorn
Copy link
Member

bjorn commented Mar 29, 2023

Thanks for the nice reproducible example script! Should be fixed now in linked PR. :-)

@eishiya
Copy link
Contributor Author

eishiya commented Mar 29, 2023

Thanks! I had a go at the new build and removing manual addNewRow() calls from my various Dialogs, and now it looks like only Labels "break" the same widget row rule, just like they're supposed to. Looks like this is fixed.

bjorn added a commit that referenced this issue Mar 29, 2023
When a new row was created automatically when adding a widget, it was
failing to remember the type of that widget, since addNewRow was called
after setting m_lastWidgetTypeName.

Now the last widget type is set in addDialogWidget instead. Also, we no
longer compare the type names but just compare the QMetaObject pointers
directly.

Also fixed a problem in ScriptDialog::deleteAllDialogs, which iterated
the sDialogInstances container while it was also getting modified as
each dialog was deleted.

Closes #3607
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Broken behavior.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants