Fix a reliance on wxColour failing silently to convert invalid colour strings - in...
authordpage <dpage@a7884b65-44f6-0310-8a51-81a127f17b15>
Mon, 23 Mar 2009 11:57:44 +0000 (11:57 +0000)
committerdpage <dpage@a7884b65-44f6-0310-8a51-81a127f17b15>
Mon, 23 Mar 2009 11:57:44 +0000 (11:57 +0000)
git-svn-id: svn://svn.pgadmin.org/trunk/pgadmin3@7742 a7884b65-44f6-0310-8a51-81a127f17b15

pgadmin/dlg/dlgServer.cpp
pgadmin/schema/pgServer.cpp

index 64ccc810af6acd67bc2c604c3ad1811b2404c1b5..5a0a1d70aa8787e842a2444865c7ba7e7e28bfab 100644 (file)
@@ -156,7 +156,20 @@ void dlgServer::OnOK(wxCommandEvent &ev)
         if (txtColour->GetValue().Trim() == wxEmptyString)
             server->iSetColour(wxEmptyString);
         else
-                   server->iSetColour(wxColour(txtColour->GetValue().Trim()).GetAsString(wxC2S_HTML_SYNTAX));
+        {
+            wxColour colour;
+            wxString sColour = wxEmptyString;
+
+            if (colour.Set(txtColour->GetValue().Trim()))
+                sColour = colour.GetAsString(wxC2S_HTML_SYNTAX);
+            else
+            {
+                wxLogError(_("The colour specified is not valid."));
+                return;
+            }
+
+            server->iSetColour(sColour);
+        }
         mainForm->execSelChange(server->GetId(), true);
         mainForm->GetBrowser()->SetItemText(item, server->GetFullName());
 
@@ -330,6 +343,12 @@ void dlgServer::CheckChange()
 
     if (server)
     {
+        wxColour colour;
+        wxString sColour = wxEmptyString;
+
+        if (colour.Set(server->GetColour()))
+            sColour = colour.GetAsString(wxC2S_HTML_SYNTAX);
+
         enable =  name != server->GetName()
                || txtDescription->GetValue() != server->GetDescription()
                || txtService->GetValue() != server->GetServiceID()
@@ -341,7 +360,7 @@ void dlgServer::CheckChange()
                || chkStorePwd->GetValue() != server->GetStorePwd()
                || chkRestore->GetValue() != server->GetRestore()
                || txtDbRestriction->GetValue() != server->GetDbRestriction()
-                          || txtColour->GetValue() != wxColour(server->GetColour()).GetAsString(wxC2S_HTML_SYNTAX);
+               || txtColour->GetValue() != sColour;
     }
 
 
index 23f533373aa0d1239ad0189b554ca10e3b24a273..1dc5fdecb68782ba69332e8cdf6a4139bdf06ed4 100644 (file)
@@ -1125,7 +1125,15 @@ pgObject *pgServerFactory::CreateObjects(pgCollection *obj, ctlTree *browser, co
         // Sanitize the colour
         colour = colour.Trim();
         if (!colour.IsEmpty())
-            colour = wxColour(colour.Trim()).GetAsString(wxC2S_HTML_SYNTAX);
+        {
+            wxColour cColour;
+            wxString sColour = wxEmptyString;
+
+            if (cColour.Set(colour))
+                colour = cColour.GetAsString(wxC2S_HTML_SYNTAX);
+            else
+                colour = wxEmptyString;
+        }
 
         // SSL mode
 #ifdef SSL