[haiku-commits] r37575 - haiku/trunk/src/apps/terminal

  • From: stefano.ceccherini@xxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Mon, 19 Jul 2010 08:17:52 +0200 (CEST)

Author: jackburton
Date: 2010-07-19 08:17:52 +0200 (Mon, 19 Jul 2010)
New Revision: 37575
Changeset: http://dev.haiku-os.org/changeset/37575

Modified:
   haiku/trunk/src/apps/terminal/AppearPrefView.cpp
   haiku/trunk/src/apps/terminal/Colors.cpp
   haiku/trunk/src/apps/terminal/Colors.h
Log:
Style.
Add NULL guard to the color schemes struct, although the code was safe
neverthless (for now)


Modified: haiku/trunk/src/apps/terminal/AppearPrefView.cpp
===================================================================
--- haiku/trunk/src/apps/terminal/AppearPrefView.cpp    2010-07-19 01:41:31 UTC 
(rev 37574)
+++ haiku/trunk/src/apps/terminal/AppearPrefView.cpp    2010-07-19 06:17:52 UTC 
(rev 37575)
@@ -95,12 +95,12 @@
        fFont = new BMenuField(B_TRANSLATE("Font:"), fontMenu);
        fFontSize = new BMenuField(B_TRANSLATE("Size:"), sizeMenu);
 
-       BPopUpMenu *schemasPopUp 
=_MakeColorSchemaMenu(MSG_COLOR_SCHEMA_CHANGED, gPredefinedSchemas,
+       BPopUpMenu* schemasPopUp 
=_MakeColorSchemaMenu(MSG_COLOR_SCHEMA_CHANGED, gPredefinedSchemas,
                gPredefinedSchemas[0]);
        fColorSchemaField = new BMenuField(B_TRANSLATE("Color schema:"),
                schemasPopUp);
 
-       BPopUpMenu *colorsPopUp =_MakeMenu(MSG_COLOR_FIELD_CHANGED, kColorTable,
+       BPopUpMenu* colorsPopUp =_MakeMenu(MSG_COLOR_FIELD_CHANGED, kColorTable,
                kColorTable[0]);
 
        fColorField = new BMenuField(B_TRANSLATE("Color:"),
@@ -242,14 +242,17 @@
 
                case MSG_COLOR_SCHEMA_CHANGED:
                {
-                       color_schema *newSchema = NULL;
-                       msg->FindPointer("color_schema", (void**)&newSchema);
-                       if (newSchema == &gCustomSchema)
-                               _EnableCustomColors(true);
-                       else
-                               _EnableCustomColors(false);
-                       _ChangeColorSchema(newSchema);
-                       modified = true;
+                       color_schema* newSchema = NULL;
+                       if (msg->FindPointer("color_schema",
+                               (void**)&newSchema) == B_OK) {
+
+                               if (newSchema == &gCustomSchema)
+                                       _EnableCustomColors(true);
+                               else
+                                       _EnableCustomColors(false);
+                               _ChangeColorSchema(newSchema);
+                               modified = true;
+                       }
                        break;
                }
 
@@ -283,7 +286,7 @@
 void
 AppearancePrefView::_ChangeColorSchema(color_schema* schema)
 {
-       PrefHandler *pref = PrefHandler::Default();
+       PrefHandler* pref = PrefHandler::Default();
 
        pref->setRGB(PREF_TEXT_FORE_COLOR, schema->text_fore_color);
        pref->setRGB(PREF_TEXT_BACK_COLOR, schema->text_back_color);
@@ -295,9 +298,9 @@
 
 
 void
-AppearancePrefView::_SetCurrentColorSchema(BMenuField *field)
+AppearancePrefView::_SetCurrentColorSchema(BMenuField* field)
 {
-       PrefHandler *pref = PrefHandler::Default();
+       PrefHandler* pref = PrefHandler::Default();
 
        gCustomSchema.text_fore_color = pref->getRGB(PREF_TEXT_FORE_COLOR);
        gCustomSchema.text_back_color = pref->getRGB(PREF_TEXT_BACK_COLOR);
@@ -306,9 +309,9 @@
        gCustomSchema.select_fore_color = pref->getRGB(PREF_SELECT_FORE_COLOR);
        gCustomSchema.select_back_color = pref->getRGB(PREF_SELECT_BACK_COLOR);
 
-       const char *currentSchemaName = NULL;
+       const char* currentSchemaName = NULL;
 
-       color_schema **schemas = const_cast<color_schema**>(gPredefinedSchemas);
+       color_schema** schemas = const_cast<color_schema**>(gPredefinedSchemas);
        while (*schemas) {
                if (gCustomSchema == **schemas) {
                        currentSchemaName = (*schemas)->name;
@@ -319,7 +322,7 @@
 
        bool found = false;
        for (int32 i = 0; i < fColorSchemaField->Menu()->CountItems(); i++) {
-               BMenuItem *item = fColorSchemaField->Menu()->ItemAt(i);
+               BMenuItem* item = fColorSchemaField->Menu()->ItemAt(i);
                if (!strcmp(item->Label(), currentSchemaName)) {
                        item->SetMarked(true);
                        found = true;

Modified: haiku/trunk/src/apps/terminal/Colors.cpp
===================================================================
--- haiku/trunk/src/apps/terminal/Colors.cpp    2010-07-19 01:41:31 UTC (rev 
37574)
+++ haiku/trunk/src/apps/terminal/Colors.cpp    2010-07-19 06:17:52 UTC (rev 
37575)
@@ -34,15 +34,16 @@
        "Custom"
 };
 
-const color_schema *gPredefinedSchemas[] = {
+const color_schema* gPredefinedSchemas[] = {
                &kBlackOnWhite,
                &kWhiteOnBlack,
                &gCustomSchema,
+               NULL
 };
 
 
 bool
-color_schema::operator==(const color_schema &schema)
+color_schema::operator==(const color_schema& schema)
 {
        if (text_fore_color == schema.text_fore_color
                && text_back_color == schema.text_back_color

Modified: haiku/trunk/src/apps/terminal/Colors.h
===================================================================
--- haiku/trunk/src/apps/terminal/Colors.h      2010-07-19 01:41:31 UTC (rev 
37574)
+++ haiku/trunk/src/apps/terminal/Colors.h      2010-07-19 06:17:52 UTC (rev 
37575)
@@ -8,14 +8,14 @@
 #include <InterfaceDefs.h>
 
 struct color_schema {
-       const char *name;
+       const char* name;
        rgb_color text_fore_color;
        rgb_color text_back_color;
        rgb_color cursor_fore_color;
        rgb_color cursor_back_color;
        rgb_color select_fore_color;
        rgb_color select_back_color;
-       bool operator==(const color_schema &color);
+       bool operator==(const color_schema& color);
 };
 
 
@@ -23,7 +23,7 @@
 extern const rgb_color kWhite;
 
 extern color_schema gCustomSchema;
-extern const color_schema *gPredefinedSchemas[];
+extern const color_schema* gPredefinedSchemas[];
 
 
 #endif // _COLORS_H


Other related posts:

  • » [haiku-commits] r37575 - haiku/trunk/src/apps/terminal - stefano . ceccherini