Skip to content

Commit

Permalink
Fix view switch FactTextField validation checks
Browse files Browse the repository at this point in the history
Can't call signal handlers in Qt 6.8
  • Loading branch information
DonLakeFlyer authored and HTRamsey committed Jan 9, 2025
1 parent 539459e commit 0085c5c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/FactSystem/FactControls/FactTextField.qml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ QGCTextField {

property Fact fact: null

onEditingFinished: {
onEditingFinished: _onEditingFinished()

function _onEditingFinished() {
var errorString = fact.validate(text, false /* convertOnly */)
if (errorString === "") {
clearValidationError()
Expand Down
5 changes: 3 additions & 2 deletions src/UI/MainRootWindow.qml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import QtQuick.Window
import QGroundControl
import QGroundControl.Palette
import QGroundControl.Controls
import QGroundControl.FactControls
import QGroundControl.ScreenTools
import QGroundControl.FlightDisplay
import QGroundControl.FlightMap
Expand Down Expand Up @@ -113,8 +114,8 @@ ApplicationWindow {
// This function is used to prevent view switching if there are validation errors
function allowViewSwitch(previousValidationErrorCount = 0) {
// Run validation on active focus control to ensure it is valid before switching views
if (mainWindow.activeFocusControl instanceof QGCTextField) {
mainWindow.activeFocusControl.onEditingFinished()
if (mainWindow.activeFocusControl instanceof FactTextField) {
mainWindow.activeFocusControl._onEditingFinished()
}
return globals.validationErrorCount <= previousValidationErrorCount
}
Expand Down

0 comments on commit 0085c5c

Please sign in to comment.