Bug 1316279 - Part 2: Fix gfxPrefs::PrefGet string when using default value; r=dvander
authorDaosheng Mu <daoshengmu@gmail.com>
Fri, 25 Nov 2016 16:23:25 +0800
changeset 324580 211067e97639eeb01b42c3fefd74e6f1c86595e8
parent 324579 48164669baec8e7bfe78bff9a44731f383d35bd2
child 324581 1ffaa7af4c67350cf80586894e43f21ed12446c6
push id24
push usermaklebus@msu.edu
push dateTue, 20 Dec 2016 03:11:33 +0000
reviewersdvander
bugs1316279
milestone53.0a1
Bug 1316279 - Part 2: Fix gfxPrefs::PrefGet string when using default value; r=dvander MozReview-Commit-ID: AfPFlBo3h7t
gfx/thebes/gfxPrefs.cpp
--- a/gfx/thebes/gfxPrefs.cpp
+++ b/gfx/thebes/gfxPrefs.cpp
@@ -187,23 +187,27 @@ uint32_t gfxPrefs::PrefGet(const char* a
 }
 
 float gfxPrefs::PrefGet(const char* aPref, float aDefault)
 {
   MOZ_ASSERT(IsPrefsServiceAvailable());
   return Preferences::GetFloat(aPref, aDefault);
 }
 
-
 std::string gfxPrefs::PrefGet(const char* aPref, std::string aDefault)
 {
   MOZ_ASSERT(IsPrefsServiceAvailable());
 
   nsAdoptingCString result;
   Preferences::GetCString(aPref, &result);
+
+  if (result.IsEmpty()) {
+    return aDefault;
+  }
+
   return result.get();
 }
 
 void gfxPrefs::PrefSet(const char* aPref, bool aValue)
 {
   MOZ_ASSERT(IsPrefsServiceAvailable());
   Preferences::SetBool(aPref, aValue);
 }