[gnome-characters/wip/properties: 13/14] libgc, character: Check if detail info is non-null
- From: Daiki Ueno <dueno src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-characters/wip/properties: 13/14] libgc, character: Check if detail info is non-null
- Date: Tue, 10 Feb 2015 10:02:38 +0000 (UTC)
commit 71496ce1f3463569dad98c5b70a7412552f55daf
Author: Daiki Ueno <dueno src gnome org>
Date: Tue Feb 10 18:26:27 2015 +0900
libgc, character: Check if detail info is non-null
lib/gc.c | 8 ++++++++
src/character.js | 15 ++++++++++++---
2 files changed, 20 insertions(+), 3 deletions(-)
---
diff --git a/lib/gc.c b/lib/gc.c
index 2607325..b718e7c 100644
--- a/lib/gc.c
+++ b/lib/gc.c
@@ -426,6 +426,10 @@ const gchar *
gc_character_script (gunichar uc)
{
const uc_script_t *script = uc_script (uc);
+
+ if (!script)
+ return NULL;
+
return script->name;
}
@@ -439,6 +443,10 @@ const gchar *
gc_character_block (gunichar uc)
{
const uc_block_t *block = uc_block (uc);
+
+ if (!block)
+ return NULL;
+
return block->name;
}
diff --git a/src/character.js b/src/character.js
index 65e8584..a973913 100644
--- a/src/character.js
+++ b/src/character.js
@@ -148,9 +148,18 @@ const CharacterDialog = new Lang.Class({
this._codepoint_label.label =
_("U+%04s").format(Util.hexCodepoint(uc));
- this._category_label.label = Gettext.gettext(Gc.character_category(uc));
- this._script_label.label = Gettext.gettext(Gc.character_script(uc));
- this._block_label.label = Gettext.gettext(Gc.character_block(uc));
+
+ let category = Gc.character_category(uc);
+ this._category_label.label =
+ category ? Gettext.gettext(category) : _("Unknown");
+
+ let script = Gc.character_script(uc);
+ this._script_label.label =
+ script ? Gettext.gettext(script) : _("Unknown");
+
+ let block = Gc.character_block(uc);
+ this._block_label.label =
+ block ? Gettext.gettext(block) : _("Unknown");
this._detail_grid.remove_row(4);
let result = Gc.character_decomposition(uc);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]