No need to report "some files could not be saved".

We've already reported the files that couldn't be saved; no need to tell
the user something they already know by that point.

Change-Id: I8251a46134342df6b40a6324aa76a5237fde7c93
Reviewed-on: https://code.wireshark.org/review/31298
Petri-Dish: Guy Harris <guy@alum.mit.edu>
Tested-by: Petri Dish Buildbot
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
This commit is contained in:
Guy Harris 2019-01-01 14:12:15 -08:00 committed by Peter Wu
parent caa2c0a95e
commit 8059bad284
6 changed files with 12 additions and 34 deletions

View File

@ -105,7 +105,6 @@ eo_draw(void *tapdata)
export_object_list_gui_t *object_list = (export_object_list_gui_t*)tap_object->gui_data; export_object_list_gui_t *object_list = (export_object_list_gui_t*)tap_object->gui_data;
GSList *slist = object_list->entries; GSList *slist = object_list->entries;
export_object_entry_t *entry; export_object_entry_t *entry;
gboolean all_saved = TRUE;
gchar* save_in_path = (gchar*)g_hash_table_lookup(eo_opts, proto_get_protocol_filter_name(get_eo_proto_id(object_list->eo))); gchar* save_in_path = (gchar*)g_hash_table_lookup(eo_opts, proto_get_protocol_filter_name(get_eo_proto_id(object_list->eo)));
GString *safe_filename = NULL; GString *safe_filename = NULL;
gchar *save_as_fullpath = NULL; gchar *save_as_fullpath = NULL;
@ -140,16 +139,11 @@ eo_draw(void *tapdata)
g_string_free(safe_filename, TRUE); g_string_free(safe_filename, TRUE);
} while (g_file_test(save_as_fullpath, G_FILE_TEST_EXISTS) && ++count < 1000); } while (g_file_test(save_as_fullpath, G_FILE_TEST_EXISTS) && ++count < 1000);
count = 0; count = 0;
if (!eo_save_entry(save_as_fullpath, entry)) eo_save_entry(save_as_fullpath, entry);
all_saved = FALSE;
g_free(save_as_fullpath); g_free(save_as_fullpath);
save_as_fullpath = NULL; save_as_fullpath = NULL;
slist = slist->next; slist = slist->next;
} }
if (!all_saved)
fprintf(stderr, "Export objects (%s): Some files could not be saved.\n",
proto_get_protocol_filter_name(get_eo_proto_id(object_list->eo)));
} }
static void static void

View File

@ -27,7 +27,7 @@
#include "export_object_ui.h" #include "export_object_ui.h"
gboolean void
eo_save_entry(const gchar *save_as_filename, export_object_entry_t *entry) eo_save_entry(const gchar *save_as_filename, export_object_entry_t *entry)
{ {
int to_fd; int to_fd;
@ -41,7 +41,7 @@ eo_save_entry(const gchar *save_as_filename, export_object_entry_t *entry)
O_BINARY, 0644); O_BINARY, 0644);
if(to_fd == -1) { /* An error occurred */ if(to_fd == -1) { /* An error occurred */
report_open_failure(save_as_filename, errno, TRUE); report_open_failure(save_as_filename, errno, TRUE);
return FALSE; return;
} }
/* /*
@ -65,24 +65,20 @@ eo_save_entry(const gchar *save_as_filename, export_object_entry_t *entry)
else else
bytes_to_write = (int)bytes_left; bytes_to_write = (int)bytes_left;
bytes_written = ws_write(to_fd, ptr, bytes_to_write); bytes_written = ws_write(to_fd, ptr, bytes_to_write);
if(bytes_written <= 0) { if (bytes_written <= 0) {
if (bytes_written < 0) if (bytes_written < 0)
err = errno; err = errno;
else else
err = WTAP_ERR_SHORT_WRITE; err = WTAP_ERR_SHORT_WRITE;
report_write_failure(save_as_filename, err); report_write_failure(save_as_filename, err);
ws_close(to_fd); ws_close(to_fd);
return FALSE; break;
} }
bytes_left -= bytes_written; bytes_left -= bytes_written;
ptr += bytes_written; ptr += bytes_written;
} }
if (ws_close(to_fd) < 0) { if (ws_close(to_fd) < 0)
report_write_failure(save_as_filename, errno); report_write_failure(save_as_filename, errno);
return FALSE;
}
return TRUE;
} }
/* /*

View File

@ -20,7 +20,7 @@ extern "C" {
/* Common between protocols */ /* Common between protocols */
gboolean eo_save_entry(const gchar *save_as_filename, export_object_entry_t *entry); void eo_save_entry(const gchar *save_as_filename, export_object_entry_t *entry);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -194,15 +194,7 @@ void ExportObjectDialog::saveAllEntries()
if (save_in_path.length() < 1) if (save_in_path.length() < 1)
return; return;
if (!model_.saveAllEntries(save_in_path)) model_.saveAllEntries(save_in_path);
{
QMessageBox::warning(
this,
tr("Object Export"),
tr("Some files could not be saved."),
QMessageBox::Ok
);
}
} }
/* /*

View File

@ -152,12 +152,11 @@ bool ExportObjectModel::saveEntry(QModelIndex &index, QString filename)
return true; return true;
} }
bool ExportObjectModel::saveAllEntries(QString path) void ExportObjectModel::saveAllEntries(QString path)
{ {
if (path.isEmpty()) if (path.isEmpty())
return false; return;
bool all_saved = true;
export_object_entry_t *entry; export_object_entry_t *entry;
for (QList<QVariant>::iterator it = objects_.begin(); it != objects_.end(); ++it) for (QList<QVariant>::iterator it = objects_.begin(); it != objects_.end(); ++it)
@ -190,13 +189,10 @@ bool ExportObjectModel::saveAllEntries(QString path)
safe_filename->str, NULL); safe_filename->str, NULL);
g_string_free(safe_filename, TRUE); g_string_free(safe_filename, TRUE);
} while (g_file_test(save_as_fullpath, G_FILE_TEST_EXISTS) && ++count < 1000); } while (g_file_test(save_as_fullpath, G_FILE_TEST_EXISTS) && ++count < 1000);
if (!eo_save_entry(save_as_fullpath, entry)) eo_save_entry(save_as_fullpath, entry);
all_saved = false;
g_free(save_as_fullpath); g_free(save_as_fullpath);
save_as_fullpath = NULL; save_as_fullpath = NULL;
} }
return all_saved;
} }
void ExportObjectModel::resetObjects() void ExportObjectModel::resetObjects()

View File

@ -45,7 +45,7 @@ public:
void resetObjects(); void resetObjects();
bool saveEntry(QModelIndex &index, QString filename); bool saveEntry(QModelIndex &index, QString filename);
bool saveAllEntries(QString path); void saveAllEntries(QString path);
const char* getTapListenerName(); const char* getTapListenerName();
void* getTapData(); void* getTapData();