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

Fix crash when switching serial ports #19

Merged
merged 1 commit into from
Mar 7, 2018

Conversation

shiftee
Copy link
Contributor

@shiftee shiftee commented Mar 5, 2018

Switching port after sending a message was crashing the program

How:
Open QModbus and select the RTU tab.
Make it active, select a valid port and hit send (If the first port was not valid you will need to toggle active checkbox).
The message should be sent and a response or timeout received.
Switch to another port (the program should crash).

Why:
Toggling active checkbox causes mainwindow to fetch modbus_t pointer from rtu widget.
If a valid port was selected then modbus_t should be valid.
Changing serial port settings frees modbus_t and allocates a new one.
mainwindow is not informed so modbus_poll() uses the freed one and causes a crash.

Fix:
When changing the serial port we now emit serialPortActive(true).
This causes mainwindow to update modbus_t thereby avoiding the crash.

This solution also means we do not need to toggle the active checkbox when we change the serial port.

Maybe related to #10

@tobydox
Copy link
Contributor

tobydox commented Mar 6, 2018

Thanks for your contribution! There seems to be a merge conflict. Can you fix this so I can merge your changes?

Switching port after sending a message was crashing the program
@shiftee shiftee force-pushed the fix_serial_change_crash branch from 12ae26f to 6ae6ec3 Compare March 6, 2018 16:37
@shiftee
Copy link
Contributor Author

shiftee commented Mar 6, 2018

Sorry, that should be fixed now

@tobydox tobydox merged commit 3cdf426 into ed-chemnitz:master Mar 7, 2018
@shiftee shiftee deleted the fix_serial_change_crash branch March 7, 2018 15:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants