Reset data_out_file when we close it. Add comments and fixup whitespace.

svn path=/trunk/; revision=53343
This commit is contained in:
Gerald Combs 2013-11-15 20:25:33 +00:00
parent 1868bd172b
commit de4c6a2d07
2 changed files with 18 additions and 9 deletions

View File

@ -301,7 +301,13 @@ void FollowStreamDialog::resetStream()
filter_out_filter_.clear();
text_pos_to_packet_.clear();
if (!data_out_filename_.isEmpty()) ws_unlink(data_out_filename_.toUtf8().constData());
if (!data_out_filename_.isEmpty()) {
ws_unlink(data_out_filename_.toUtf8().constData());
}
if (data_out_file) {
fclose(data_out_file);
data_out_file = NULL;
}
for (cur = follow_info_.payload; cur; cur = g_list_next(cur)) {
g_free(cur->data);
}
@ -309,7 +315,6 @@ void FollowStreamDialog::resetStream()
follow_info_.payload = NULL;
}
// XXX We end up calling this twice when we open the dialog.
frs_return_t
FollowStreamDialog::follow_read_stream()
{
@ -873,9 +878,6 @@ bool FollowStreamDialog::follow(QString previous_filter, bool use_tcp_index)
}
}
/* Allocate our new filter. */
/* append the negation */
if(!previous_filter.isEmpty()) {
filter_out_filter_ = QString("%1 and !(%2)")
@ -950,6 +952,16 @@ bool FollowStreamDialog::follow(QString previous_filter, bool use_tcp_index)
return false;
}
/* Go back to the top of the file and read the first tcp_stream_chunk
* to ensure that the IP addresses and port numbers in the drop-down
* list are tied to the correct lines displayed by follow_read_stream()
* later on (which also reads from this file). Close the file when
* we're done.
*
* We read the data now, before we pop up a window, in case the
* read fails. We use the data later.
*/
rewind(data_out_file);
nchars=fread(&sc, 1, sizeof(sc), data_out_file);
if (nchars != sizeof(sc)) {
@ -1122,13 +1134,11 @@ bool FollowStreamDialog::follow(QString previous_filter, bool use_tcp_index)
break;
}
ui->cbDirections->clear();
this->ui->cbDirections->addItem(both_directions_string);
this->ui->cbDirections->addItem(client_to_server_string);
this->ui->cbDirections->addItem(server_to_client_string);
follow_stream();
fillHintLabel(-1);
@ -1137,7 +1147,6 @@ bool FollowStreamDialog::follow(QString previous_filter, bool use_tcp_index)
return true;
}
#define FLT_BUF_SIZE 1024
/*

View File

@ -134,7 +134,7 @@ private:
int client_packet_count_;
int server_packet_count_;
guint32 last_packet_;
bool last_from_server_;
gboolean last_from_server_;
int turns_;
QMap<int,guint32> text_pos_to_packet_;