[gnome-photos/wip/rishi/misc-fixes: 3/26] item-manager: Fix a pre-condition check
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-photos/wip/rishi/misc-fixes: 3/26] item-manager: Fix a pre-condition check
- Date: Tue, 22 Dec 2015 19:34:36 +0000 (UTC)
commit 9de03c1914df10929c01909396aad755476fcd89
Author: Debarshi Ray <debarshir gnome org>
Date: Tue Dec 22 13:32:18 2015 +0100
item-manager: Fix a pre-condition check
The check is supposed to fail if self->mode isn't
PHOTOS_WINDOW_MODE_PREVIEW when mode is PHOTOS_WINDOW_MODE_EDIT.
Otherwise, self->mode should never be PHOTOS_WINDOW_MODE_PREVIEW.
The old code wasn't doing that. eg., it would pass if
- self->mode == PHOTOS_WINDOW_MODE_OVERVIEW, and
- mode == PHOTOS_WINDOW_MODE_EDIT
Splitting up the check also makes it easier to read.
src/photos-item-manager.c | 11 ++++++++---
1 files changed, 8 insertions(+), 3 deletions(-)
---
diff --git a/src/photos-item-manager.c b/src/photos-item-manager.c
index 4931a70..9ea97ef 100644
--- a/src/photos-item-manager.c
+++ b/src/photos-item-manager.c
@@ -774,11 +774,16 @@ photos_mode_controller_set_window_mode (PhotosModeController *self, PhotosWindow
g_return_if_fail (mode != PHOTOS_WINDOW_MODE_NONE);
g_return_if_fail (mode != PHOTOS_WINDOW_MODE_PREVIEW);
- g_return_if_fail (self->mode != PHOTOS_WINDOW_MODE_PREVIEW
- || (self->mode == PHOTOS_WINDOW_MODE_PREVIEW && mode == PHOTOS_WINDOW_MODE_EDIT));
if (mode == PHOTOS_WINDOW_MODE_EDIT)
- g_return_if_fail (self->load_state == PHOTOS_LOAD_STATE_FINISHED);
+ {
+ g_return_if_fail (self->load_state == PHOTOS_LOAD_STATE_FINISHED);
+ g_return_if_fail (self->mode == PHOTOS_WINDOW_MODE_PREVIEW);
+ }
+ else
+ {
+ g_return_if_fail (self->mode != PHOTOS_WINDOW_MODE_PREVIEW);
+ }
if (!photos_item_manager_set_window_mode_internal (self, mode, &old_mode))
return;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]