Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Valentin Platzgummer
qgroundcontrol
Commits
d9bc4cb2
Commit
d9bc4cb2
authored
Jul 07, 2014
by
Don Gagne
Browse files
Better timeout handling
parent
973b9c0c
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/uas/QGCUASFileManager.cc
View file @
d9bc4cb2
...
...
@@ -471,15 +471,19 @@ void QGCUASFileManager::_clearAckTimeout(void)
/// @brief Called when ack timeout timer fires
void
QGCUASFileManager
::
_ackTimeout
(
void
)
{
_emitErrorMessage
(
tr
(
"Timeout waiting for ack"
));
// Make sure to set _currentOperation state before emitting error message. Code may respond
// to error message signal by sending another command, which will fail if state is not back
// to idle. FileView UI works this way with the List command.
switch
(
_currentOperation
)
{
case
kCORead
:
_currentOperation
=
kCOAck
;
_emitErrorMessage
(
tr
(
"Timeout waiting for ack: Sending Terminate command"
));
_sendTerminateCommand
();
break
;
default:
_currentOperation
=
kCOIdle
;
_emitErrorMessage
(
tr
(
"Timeout waiting for ack"
));
break
;
}
}
...
...
src/ui/QGCUASFileView.cc
View file @
d9bc4cb2
...
...
@@ -40,7 +40,9 @@ QGCUASFileView::QGCUASFileView(QWidget *parent, QGCUASFileManager *manager) :
Q_ASSERT
(
success
);
success
=
connect
(
_ui
.
treeWidget
,
SIGNAL
(
currentItemChanged
(
QTreeWidgetItem
*
,
QTreeWidgetItem
*
)),
this
,
SLOT
(
_currentItemChanged
(
QTreeWidgetItem
*
,
QTreeWidgetItem
*
)));
Q_ASSERT
(
success
);
Q_UNUSED
(
success
);
success
=
connect
(
&
_listCompleteTimer
,
SIGNAL
(
timeout
()),
this
,
SLOT
(
_listCompleteTimeout
()));
Q_ASSERT
(
success
);
Q_UNUSED
(
success
);
// Silence retail unused variable error
}
void
QGCUASFileView
::
_downloadFiles
(
void
)
...
...
@@ -88,8 +90,7 @@ void QGCUASFileView::_refreshTree(void)
// Don't queue up more than once
_ui
.
listFilesButton
->
setEnabled
(
false
);
qDebug
()
<<
"List: /"
;
_manager
->
listDirectory
(
"/"
);
_requestDirectoryList
(
"/"
);
}
void
QGCUASFileView
::
_treeStatusMessage
(
const
QString
&
msg
)
...
...
@@ -128,6 +129,8 @@ void QGCUASFileView::_treeErrorMessage(const QString& msg)
void
QGCUASFileView
::
_listComplete
(
void
)
{
_clearListCompleteTimeout
();
// Walk the current items, traversing down into directories
Again:
...
...
@@ -159,8 +162,7 @@ Again:
QTreeWidgetItem
*
item
=
_walkItemStack
[
i
];
dir
.
append
(
"/"
+
item
->
text
(
0
));
}
qDebug
()
<<
"List:"
<<
dir
;
_manager
->
listDirectory
(
dir
);
_requestDirectoryList
(
dir
);
}
else
{
// We have run out of items at the this level, pop the stack and keep going at that level
_walkIndexStack
.
removeLast
();
...
...
@@ -192,3 +194,30 @@ void QGCUASFileView::_currentItemChanged(QTreeWidgetItem* current, QTreeWidgetIt
Q_UNUSED
(
previous
);
_ui
.
downloadButton
->
setEnabled
(
current
?
(
current
->
type
()
==
_typeFile
)
:
false
);
}
void
QGCUASFileView
::
_setupListCompleteTimeout
(
void
)
{
Q_ASSERT
(
!
_listCompleteTimer
.
isActive
());
_listCompleteTimer
.
setSingleShot
(
true
);
_listCompleteTimer
.
start
(
_listCompleteTimerTimeoutMsecs
);
}
void
QGCUASFileView
::
_clearListCompleteTimeout
(
void
)
{
Q_ASSERT
(
_listCompleteTimer
.
isActive
());
_listCompleteTimer
.
stop
();
}
void
QGCUASFileView
::
_listCompleteTimeout
(
void
)
{
_treeErrorMessage
(
tr
(
"Timeout waiting for listComplete signal"
));
}
void
QGCUASFileView
::
_requestDirectoryList
(
const
QString
&
dir
)
{
qDebug
()
<<
"List:"
<<
dir
;
_setupListCompleteTimeout
();
_manager
->
listDirectory
(
dir
);
}
src/ui/QGCUASFileView.h
View file @
d9bc4cb2
...
...
@@ -48,12 +48,20 @@ private slots:
void
_listComplete
(
void
);
void
_downloadStatusMessage
(
const
QString
&
msg
);
void
_currentItemChanged
(
QTreeWidgetItem
*
current
,
QTreeWidgetItem
*
previous
);
void
_listCompleteTimeout
(
void
);
private:
void
_setupListCompleteTimeout
(
void
);
void
_clearListCompleteTimeout
(
void
);
void
_requestDirectoryList
(
const
QString
&
dir
);
static
const
int
_typeFile
=
QTreeWidgetItem
::
UserType
+
1
;
static
const
int
_typeDir
=
QTreeWidgetItem
::
UserType
+
2
;
static
const
int
_typeError
=
QTreeWidgetItem
::
UserType
+
3
;
QTimer
_listCompleteTimer
;
///> Used to signal a timeout waiting for a listComplete signal
static
const
int
_listCompleteTimerTimeoutMsecs
=
5000
;
///> Timeout in msecs for listComplete timer
QList
<
int
>
_walkIndexStack
;
QList
<
QTreeWidgetItem
*>
_walkItemStack
;
Ui
::
QGCUASFileView
_ui
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment