VTests: PlayPen_BlitSubTextures - use hardware blit path

the software blitting is easy to test w/o a context in unit tests

--- Tests/VisualTests/PlayPen/src/PlayPenTests.cpp
+++ Tests/VisualTests/PlayPen/src/PlayPenTests.cpp
@@ -1990,14 +1990,13 @@

 void PlayPen_BlitSubTextures::setupContent()
 {
-    Image img;
-    img.load("ogrelogo.png", ASSETS_RESOURCE_GROUP);
+    TexturePtr src = TextureManager::getSingleton().load("ogrelogo.png", ASSETS_RESOURCE_GROUP);

     TexturePtr tex = TextureManager::getSingleton().createManual(
         "testblitdst",
-        TRANSIENT_RESOURCE_GROUP, TEX_TYPE_2D, 1024, 1024, 1, 0, img.getFormat());
-
-    PixelBox srcBox;
+        TRANSIENT_RESOURCE_GROUP, TEX_TYPE_2D, 1024, 1024, 1, 0, src->getFormat());
+
+    Box srcBox;
     // This box should select from halfway through the head, to the
     // 'OG' part of the logo.
     srcBox.left = 376;
@@ -2006,18 +2005,6 @@
     srcBox.bottom = 379 + 278;
     srcBox.back = 1;
     srcBox.front = 0;
-    srcBox.format = img.getFormat();
-    srcBox.data = img.getData();
-    srcBox.rowPitch = img.getWidth();
-    srcBox.slicePitch = img.getWidth() * img.getHeight();
-
-    Box dstBox;
-    dstBox.left = srcBox.left;
-    dstBox.top = srcBox.top;
-    dstBox.right = srcBox.right;
-    dstBox.bottom = srcBox.bottom;
-    dstBox.back = 1;
-    dstBox.front = 0;

     // I was getting uninitialized memory written to the texture
     // buffer, so clear it explicitly.
@@ -2026,7 +2013,7 @@
         HardwareBuffer::HBL_NORMAL), 0, tex->getBuffer()->getSizeInBytes());
     tex->getBuffer()->unlock();

-    tex->getBuffer()->blitFromMemory(srcBox, dstBox);
+    tex->getBuffer()->blit(src->getBuffer(), srcBox, srcBox);

     MaterialPtr mat = MaterialManager::getSingleton().create(
         "testblit",


Fix segfault in case of deque<aggregate>

--- cxx/accessors.bench.cpp
+++ cxx/accessors.bench.cpp
@@ -16,7 +16,7 @@
 template<typename V>
 void BM_advance(benchmark::State& state) {
   int N = state.range(0);
-  V v;
+  V v(N);
   fill_seq(v);
   while (state.KeepRunning()) {
     for (int i = 0; i < N; ++i) {
@@ -31,7 +31,7 @@
 template<typename V>
 void BM_access(benchmark::State& state) {
   int N = state.range(0);
-  V v;
+  V v(N);
   fill_seq(v);
   while (state.KeepRunning()) {
     for (int i = 0; i < N; ++i) {


Getting orientation is not working properly. VideoCaptureImpl::RotationFromDegrees returns -1 in case fails not 0. So we need to change the if statement.

BUG=3869
TEST=Manual
R=glaznev@webrtc.org

Review URL: https://webrtc-codereview.appspot.com/25699004

Cr-Mirrored-From: https://chromium.googlesource.com/external/webrtc
Cr-Mirrored-Commit: 0a256acb67b50e9af188e4be36269ce35d9bdb63

--- modules/video_capture/android/device_info_android.cc
+++ modules/video_capture/android/device_info_android.cc
@@ -222,7 +222,8 @@
     VideoCaptureRotation& orientation) {
   const AndroidCameraInfo* info = FindCameraInfoByName(deviceUniqueIdUTF8);
   if (info == NULL ||
-      !VideoCaptureImpl::RotationFromDegrees(info->orientation, &orientation)) {
+      VideoCaptureImpl::RotationFromDegrees(info->orientation,
+                                            &orientation) != 0) {
     return -1;
   }
   return 0;


Fixed code formatting of LucasCandaePyramidTracker.cpp

--- src/LucasCandaePyramidTracker.cpp
+++ src/LucasCandaePyramidTracker.cpp
@@ -39,14 +39,14 @@
 LucasCandaePyramidTracker::LucasCandaePyramidTracker(const cv::Size &windowSize,
 		const unsigned int &maxLevel, const int &flags,
 		const cv::TermCriteria &terminationCriteria,
-		const double &minEigenvalueThreshold, const double &maxErrorValue):
-			_windowSize(windowSize), _maxLevel(maxLevel), _flags(flags),
-			_minEigenvalueThreshold(minEigenvalueThreshold),
-			_maxErrorThreshold(maxErrorValue), _termCrit(terminationCriteria){
+		const double &minEigenvalueThreshold, const double &maxErrorValue) :
+		_windowSize(windowSize), _maxLevel(maxLevel), _flags(flags), _minEigenvalueThreshold(
+				minEigenvalueThreshold), _maxErrorThreshold(maxErrorValue), _termCrit(
+				terminationCriteria) {

 }

-FeatureTracker *LucasCandaePyramidTracker::constructCopy()const{
+FeatureTracker *LucasCandaePyramidTracker::constructCopy() const {
 	return new LucasCandaePyramidTracker(*this);
 }

@@ -60,8 +60,8 @@
 	for (unsigned int i = 0; i < trackedFeatures.size(); ++i) {
 		oldFeatures[i] = trackedFeatures[i].front();
 	}
-	cv::calcOpticalFlowPyrLK(oldInput, newInput, oldFeatures, newFeatures, status,
-			err, _windowSize, _maxLevel, _termCrit, _flags,
+	cv::calcOpticalFlowPyrLK(oldInput, newInput, oldFeatures, newFeatures,
+			status, err, _windowSize, _maxLevel, _termCrit, _flags,
 			_minEigenvalueThreshold);

 	for (unsigned i = 0; i < newFeatures.size(); ++i) {


Fix variable type for GCC4

Fix variable type for GCC4

--- src/AddRepoWindow.cpp
+++ src/AddRepoWindow.cpp
@@ -118,7 +118,7 @@
 {
 	if (be_clipboard->Lock()) {
 		const char *string;
-		int32 stringLen;
+		ssize_t stringLen;
 	    BMessage *clip = be_clipboard->Data();
 	    clip->FindData("text/plain", B_MIME_TYPE, (const void **)&string,
 	        &stringLen);


BUG: Enable vtkPointwiseMutualInformation filter to handle empty input data gracefully.

--- TextAnalysis/vtkPointwiseMutualInformation.cxx
+++ TextAnalysis/vtkPointwiseMutualInformation.cxx
@@ -35,7 +35,7 @@
 ///////////////////////////////////////////////////////////////////////////////
 // vtkPointwiseMutualInformation

-vtkCxxRevisionMacro(vtkPointwiseMutualInformation, "1.1");
+vtkCxxRevisionMacro(vtkPointwiseMutualInformation, "1.2");
 vtkStandardNewMacro(vtkPointwiseMutualInformation);

 vtkPointwiseMutualInformation::vtkPointwiseMutualInformation()
@@ -67,9 +67,22 @@
     vtkTypedArray<double>* const input_array = vtkTypedArray<double>::SafeDownCast(input_data->GetArray(0));
     if(!input_array)
       throw vtkstd::runtime_error("Unsupported input array type.");
+
+    // Create an output array ...
+    vtkTypedArray<double>* const output_array = vtkTypedArray<double>::SafeDownCast(input_array->DeepCopy());
+    vtkArrayData* const output = vtkArrayData::GetData(outputVector);
+    output->ClearArrays();
+    output->AddArray(output_array);
+    output_array->Delete();

     const vtkIdType dimension_count = input_array->GetDimensions();
     const vtkIdType value_count = input_array->GetNonNullSize();
+
+    if(value_count == 0)
+      {
+      // Allow for an empty input
+      return 1;
+      }

     // This is a portable way to compute log base-2 ...
     static const double ln2 = log(2.0);
@@ -102,13 +115,6 @@
       if(vtkstd::count(dimension_sums[i].begin(), dimension_sums[i].end(), 0))
         throw vtkstd::runtime_error("Cannot compute PMI with zero dimension sums.");
       }
-
-    // Create an output array ...
-    vtkTypedArray<double>* const output_array = vtkTypedArray<double>::SafeDownCast(input_array->DeepCopy());
-    vtkArrayData* const output = vtkArrayData::GetData(outputVector);
-    output->ClearArrays();
-    output->AddArray(output_array);
-    output_array->Delete();

     // Compute the PMI for each array value ...
     for(vtkIdType n = 0; n != value_count; ++n)


added #include facets.h in facets.cpp

added #include facets.h in facets.cpp

git-svn-id: 40192aece4a9e6664bc9a93aa558322db432a344@1253 15ae5fad-cc11-0410-8fac-bce609e504b0

--- cxxtools/src/facets.cpp
+++ cxxtools/src/facets.cpp
@@ -25,6 +25,8 @@
  * License along with this library; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  */
+
+#include <cxxtools/facets.h>

 namespace std {


Fix mem leak with temporary variables in blocks repeatedly executed.

--- hilti/codegen/codegen.cc
+++ hilti/codegen/codegen.cc
@@ -1133,12 +1133,12 @@

 llvm::Value* CodeGen::llvmAddTmp(const string& name, llvm::Type* type, llvm::Value* init, bool reuse, int alignment)
 {
-    if ( ! init )
-        init = llvmConstNull(type);
-
     string tname = "__tmp_" + name;

     if ( reuse ) {
+        if ( ! init )
+            init = llvmConstNull(type);
+
         auto i = _functions.back()->tmps.find(tname);
         if ( i != _functions.back()->tmps.end() ) {
             auto tmp = i->second.first;
@@ -1158,6 +1158,13 @@
     if ( init )
         // Must be done in original block.
         llvmCreateStore(init, tmp);
+    else {
+        // Do init entry block so that we don't overwrite this if the code
+        // gets executed multiple times.
+        pushBuilder(tmp_builder);
+        llvmCreateStore(llvmConstNull(type), tmp);
+        popBuilder();
+    }

     _functions.back()->tmps.insert(make_pair(tname, std::make_pair(tmp, nullptr)));

@@ -1585,8 +1592,7 @@
 {
     auto tmp = llvmAddTmp("dtor", val->getType());

-    llvmCreateStore(val, tmp);
-
+    llvmGCAssign(tmp, val, type, true);
     _functions.back()->dtors_after_ins.push_back(std::make_tuple(std::make_tuple(tmp, is_ptr), type));
 }


Remove stupid print

Remove stupid print

--- src/AndroidClient.cpp
+++ src/AndroidClient.cpp
@@ -138,15 +138,16 @@
     // Gather headers and values
     for (int i = 0; ; i++) {
       jstring jheaderKey = (jstring)env->CallObjectMethod(connection, cache->getHeaderKeyMethod, i);
+      if (jheaderKey == NULL) {
+        break;
+      }
       const char * headerKey = env->GetStringUTFChars(jheaderKey, 0);
       __android_log_print(ANDROID_LOG_INFO, "content", "header key = %s", headerKey);

       jstring jheader = (jstring)env->CallObjectMethod(connection, cache->getHeaderMethodInt, i);
       const char * header = env->GetStringUTFChars(jheader, 0);
       __android_log_print(ANDROID_LOG_INFO, "content", "header value = %s", header);
-      if (headerKey == NULL) {
-	break;
-      }
+
       callback.handleHeader(headerKey, header);
       env->ReleaseStringUTFChars(jheaderKey, headerKey);
       env->ReleaseStringUTFChars(jheader, header);
@@ -171,7 +172,6 @@
       env->DeleteLocalRef(followURL);
     }

-    __android_log_print(ANDROID_LOG_VERBOSE, "AndroidClient", "nope");
     env->DeleteLocalRef(input);
     env->DeleteLocalRef(connection);
 }


adding an extra check for pid-file creation, and making the output more reliable, especially when daemonizing

--- src/clustering/administration/main/command_line.cc
+++ src/clustering/administration/main/command_line.cc
@@ -5,6 +5,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
+#include <libgen.h>
 #include <pwd.h>
 #include <grp.h>
 #include <sys/stat.h>
@@ -52,6 +53,25 @@
     }
 }

+int check_pid_file(const std::string &pid_filepath) {
+    guarantee(pid_filepath.size() > 0);
+
+    if (access(pid_filepath.c_str(), F_OK) == 0) {
+        logERR("The pid-file specified already exists. This might mean that an instance is already running.");
+        return EXIT_FAILURE;
+    }
+
+    // Make a copy of the filename since `dirname` may modify it
+    char pid_dir[PATH_MAX + 1];
+    strncpy(pid_dir, pid_filepath.c_str(), PATH_MAX + 1);
+    if (access(dirname(pid_dir), W_OK) == -1) {
+        logERR("Cannot access the pid-file directory.");
+        return EXIT_FAILURE;
+    }
+
+    return EXIT_SUCCESS;
+}
+
 int write_pid_file(const std::string &pid_filepath) {
     guarantee(pid_filepath.size() > 0);

@@ -59,15 +79,16 @@
     // pid-file only run if the checks here pass. Right now, this is guaranteed by the return on
     // failure here.
     if (!pid_file.empty()) {
-        fprintf(stderr, "ERROR: Attempting to write pid-file twice.\n");
+        logERR("Attempting to write pid-file twice.");
         return EXIT_FAILURE;
     }
-    if (!access(pid_filepath.c_str(), F_OK)) {
-        fprintf(stderr, "ERROR: The pid-file specified already exists. This might mean that an instance is already running.\n");
+
+    if (check_pid_file(pid_filepath) == EXIT_FAILURE) {
         return EXIT_FAILURE;
     }
+
     if (!numwrite(pid_filepath.c_str(), getpid())) {
-        fprintf(stderr, "ERROR: Writing to the specified pid-file failed.\n");
+        logERR("Writing to the specified pid-file failed.");
         return EXIT_FAILURE;
     }
     pid_file = pid_filepath;
@@ -232,6 +253,15 @@
     }
 }

+int check_pid_file(const std::map<std::string, options::values_t> &opts) {
+    boost::optional<std::string> pid_filepath = get_optional_option(opts, "--pid-file");
+    if (!pid_filepath || pid_filepath->empty()) {
+        return EXIT_SUCCESS;
+    }
+
+    return check_pid_file(*pid_filepath);
+}
+
 // Maybe writes a pid file, using the --pid-file option, if it's present.
 int write_pid_file(const std::map<std::string, options::values_t> &opts) {
     boost::optional<std::string> pid_filepath = get_optional_option(opts, "--pid-file");
@@ -320,7 +350,7 @@
 }

 void initialize_logfile(const std::map<std::string, options::values_t> &opts,
-                               const base_path_t& dirpath) {
+                        const base_path_t& dirpath) {
     std::string filename;
     if (exists_option(opts, "--log-file")) {
         filename = get_single_option(opts, "--log-file");
@@ -1145,6 +1175,10 @@
         base_path.make_absolute();
         initialize_logfile(opts, base_path);

+        if (check_pid_file(opts) != EXIT_SUCCESS) {
+            return EXIT_FAILURE;
+        }
+
         if (!maybe_daemonize(opts)) {
             // This is the parent process of the daemon, just exit
             return EXIT_SUCCESS;
@@ -1254,6 +1288,10 @@
         const std::string web_path = get_web_path(opts, argv);
         const int num_workers = get_cpu_count();

+        if (check_pid_file(opts) != EXIT_SUCCESS) {
+            return EXIT_FAILURE;
+        }
+
         if (!maybe_daemonize(opts)) {
             // This is the parent process of the daemon, just exit
             return EXIT_SUCCESS;
@@ -1465,6 +1503,10 @@

         base_path.make_absolute();
         initialize_logfile(opts, base_path);
+
+        if (check_pid_file(opts) != EXIT_SUCCESS) {
+            return EXIT_FAILURE;
+        }

         if (!maybe_daemonize(opts)) {
             // This is the parent process of the daemon, just exit


Updating transform repository error checking

--- UWPOpenIGTLink/Content/TransformRepository.cxx
+++ UWPOpenIGTLink/Content/TransformRepository.cxx
@@ -566,7 +566,12 @@
         continue;
       }
       Platform::String^ matrixString = dynamic_cast<Platform::String^>(nestedElement->Attributes->GetNamedItem(L"Matrix")->NodeValue);
-      if (!matrixString->IsEmpty())
+      if (matrixString->IsEmpty())
+      {
+        numberOfErrors++;
+        continue;
+      }
+      else
       {
         std::wstring matrixStr(matrixString->Data());

@@ -600,102 +605,34 @@
         matrix.m42 = vectorMatrix[13];
         matrix.m43 = vectorMatrix[14];
         matrix.m44 = vectorMatrix[15];
-      }
-      else
-      {
-        numberOfErrors++;
-        continue;
-      }
-
-      try
-      {
-        SetTransform(transformName, matrix, true);
-      }
-      catch (Platform::Exception^ e)
-      {
-        numberOfErrors++;
-        continue;
-      }
-
-      bool isPersistent = true;
-      if (nestedElement->Attributes->GetNamedItem(L"Persistent") != nullptr)
-      {
-        Platform::String^ persistentAttribute = dynamic_cast<Platform::String^>(nestedElement->Attributes->GetNamedItem(L"Persistent")->NodeValue);
-        if (!persistentAttribute->IsEmpty())   // if it exists, then it is non-persistent
-        {
-          std::wstring persistentString(persistentAttribute->Data());
-          std::transform(persistentString.begin(), persistentString.end(), persistentString.begin(), towlower);
-          if (persistentString == L"false")
-          {
-            isPersistent = false;
-          }
-        }
+
         try
         {
-          SetTransformPersistent(transformName, isPersistent);
+          SetTransform(transformName, matrix, true);
+          SetTransformPersistent(transformName, true);
+
+          if (nestedElement->Attributes->GetNamedItem(L"Error") != nullptr)
+          {
+            Platform::String^ errorAttribute = dynamic_cast<Platform::String^>(nestedElement->Attributes->GetNamedItem(L"Error")->NodeValue);
+            if (!errorAttribute->IsEmpty())
+            {
+              SetTransformError(transformName, stod(std::wstring(errorAttribute->Data())));
+            }
+          }
+
+          if (nestedElement->Attributes->GetNamedItem(L"Date") != nullptr)
+          {
+            Platform::String^ dateAttribute = dynamic_cast<Platform::String^>(nestedElement->Attributes->GetNamedItem(L"Date")->NodeValue);
+            if (!dateAttribute->IsEmpty())
+            {
+              SetTransformDate(transformName, dateAttribute);
+            }
+          }
         }
-        catch (Platform::Exception^ e)
+        catch (...)
         {
           numberOfErrors++;
           continue;
-        }
-      }
-
-      bool isValid = true;
-      if (nestedElement->Attributes->GetNamedItem(L"Valid") != nullptr)
-      {
-        Platform::String^ validAttribute = dynamic_cast<Platform::String^>(nestedElement->Attributes->GetNamedItem(L"Valid")->NodeValue);
-        if (!validAttribute->IsEmpty())   // if it exists, then it is non-persistent
-        {
-          std::wstring validString(validAttribute->Data());
-          std::transform(validString.begin(), validString.end(), validString.begin(), towlower);
-          if (validString == L"false")
-          {
-            isValid = false;
-          }
-        }
-        try
-        {
-          SetTransformValid(transformName, isValid);
-        }
-        catch (Platform::Exception^ e)
-        {
-          numberOfErrors++;
-          continue;
-        }
-      }
-
-      if (nestedElement->Attributes->GetNamedItem(L"Error") != nullptr)
-      {
-        Platform::String^ errorAttribute = dynamic_cast<Platform::String^>(nestedElement->Attributes->GetNamedItem(L"Error")->NodeValue);
-        if (!errorAttribute->IsEmpty())
-        {
-          try
-          {
-            SetTransformError(transformName, stod(std::wstring(errorAttribute->Data())));
-          }
-          catch (Platform::Exception^ e)
-          {
-            numberOfErrors++;
-            continue;
-          }
-        }
-      }
-
-      if (nestedElement->Attributes->GetNamedItem(L"Date") != nullptr)
-      {
-        Platform::String^ dateAttribute = dynamic_cast<Platform::String^>(nestedElement->Attributes->GetNamedItem(L"Date")->NodeValue);
-        if (!dateAttribute->IsEmpty())
-        {
-          try
-          {
-            SetTransformDate(transformName, dateAttribute);
-          }
-          catch (Platform::Exception^ e)
-          {
-            numberOfErrors++;
-            continue;
-          }
         }
       }
     }


Blending enum clean-up

Blending enum clean-up

We were previously using a mixture of BLEND and BLENDING in enums.
The order of the BLEND_FACTOR enums & string names was also inconsistent.

As a rule of thumb always use Blend & BLEND for namespaces & enums/constants
(not Blending or BLENDING)

Change-Id: I63f7b59cf7c5c234eda979d55213a2994e90860a

--- adaptors/emscripten/wrappers/dali-wrapper.cpp
+++ adaptors/emscripten/wrappers/dali-wrapper.cpp
@@ -877,23 +877,23 @@
     .value("COMPRESSED_RGB_PVRTC_4BPPV1", Dali::Pixel::Format::COMPRESSED_RGB_PVRTC_4BPPV1)
 ;

-  enum_<Dali::Renderer::FaceCullingMode>("FaceCullingMode")
-    .value("CULL_NONE", Dali::Renderer::CULL_NONE)
-    .value("CULL_BACK", Dali::Renderer::CULL_BACK)
-    .value("CULL_FRONT", Dali::Renderer::CULL_FRONT)
-    .value("CULL_BACK_AND_FRONT", Dali::Renderer::CULL_BACK_AND_FRONT)
-;
-
-  enum_<Dali::Renderer::DepthWriteMode>("DepthWriteMode")
-    .value("DEPTH_WRITE_OFF", Dali::Renderer::DEPTH_WRITE_OFF)
-    .value("DEPTH_WRITE_AUTO", Dali::Renderer::DEPTH_WRITE_AUTO)
-    .value("DEPTH_WRITE_ON", Dali::Renderer::DEPTH_WRITE_ON)
-;
-
-  enum_<Dali::BlendingMode::Type>("BlendingMode")
-    .value("OFF", Dali::BlendingMode::OFF)
-    .value("AUTO", Dali::BlendingMode::AUTO)
-    .value("ON", Dali::BlendingMode::ON)
+  enum_<Dali::FaceCullingMode::Type>("FaceCullingMode")
+    .value("NONE", Dali::FaceCullingMode::NONE)
+    .value("FRONT", Dali::FaceCullingMode::FRONT)
+    .value("BACK", Dali::FaceCullingMode::BACK)
+    .value("FRONT_AND_BACK", Dali::FaceCullingMode::FRONT_AND_BACK)
+;
+
+  enum_<Dali::DepthWriteMode::Type>("DepthWriteMode")
+    .value("OFF", Dali::DepthWriteMode::OFF)
+    .value("AUTO", Dali::DepthWriteMode::AUTO)
+    .value("ON", Dali::DepthWriteMode::ON)
+;
+
+  enum_<Dali::BlendMode::Type>("BlendMode")
+    .value("OFF", Dali::BlendMode::OFF)
+    .value("AUTO", Dali::BlendMode::AUTO)
+    .value("ON", Dali::BlendMode::ON)
 ;

   enum_<Dali::AlphaFunction::BuiltinFunction>("AlphaFunction")


Use initializer list instead of make_pair

--- src/Associativity.cpp
+++ src/Associativity.cpp
@@ -104,10 +104,10 @@
     const Variable *var_a = lhs.as<Variable>();
     if (!var_a || (var_a->name != op_x)) {
         debug(4) << "Can't prove associativity of " << T::make(lhs, rhs) << "\n";
-        return std::make_pair(false, false);
+        return {false, false};
     } else if (expr_uses_var(rhs, op_x)) {
         debug(4) << "Can't prove associativity of " << T::make(lhs, rhs) << "\n";
-        return std::make_pair(false, false);
+        return {false, false};
     } else {
         // op(x, y)
         op.x = {op_x, x_part};
@@ -115,9 +115,9 @@
     }
     if (std::is_same<T, Sub>::value) {
         // Sub is associative but not commutative
-        return std::make_pair(true, false);
-    }
-    return std::make_pair(true, true);
+        return {true, false};
+    }
+    return {true, true};
 }

 // Return a pair of booleans indicating if an operator is associative and commutative
@@ -137,7 +137,7 @@
         op.identity = make_const(t, 0);
         op.x = {"", Expr()};
         op.y = {op_y, e};
-        return std::make_pair(true, false);
+        return {true, false};
     }

     if (const Add *a = e.as<Add>()) {
@@ -172,9 +172,9 @@
         internal_error << "Let should have been substituted before calling this function\n";
     } else {
         debug(4) << "Can't prove associativity of " << e << "\n";
-        return std::make_pair(false, false);
-    }
-    return std::make_pair(false, false);
+        return {false, false};
+    }
+    return {false, false};
 }

 } // anonymous namespace


i feel dumb

i feel dumb

--- Code/ElementSet.cpp
+++ Code/ElementSet.cpp
@@ -59,7 +59,7 @@
 bool Element::MultiplyOnLeft( const Element& element )
 {
 	word.MultiplyOnLeft( element.word );
-	permutation.MultiplyOnleft( element.permutation );
+	permutation.MultiplyOnLeft( element.permutation );
 	return true;
 }

@@ -170,6 +170,15 @@
 		elementQueue.erase( queueIter );

 		// TODO: Despite this conditional, can I prove the correctness of this algorithm?
+		//       One approach is to use an inductive argument on the size of the generating
+		//       set under the condition that our queue be a stack.  I just can't quite see
+		//       the final argument.  We have H<G, and g in G-H.  Will we take H to G using g?
+		//       I think we can argue that we'll get H, gH, ..., g^{|g|-1}H, but the index of
+		//       H in G is not necessarily |g|.  Here's a better argument.  We know the algorithm
+		//       terminates.  Fine.  Now consider the result as an array of elements.  Can we
+		//       argue that for any element in that array, it has been compared with all elements
+		//       left of it and all elements right of it in the array?  I think we can, but that's
+		//       not quite enough.
 		if( !IsMember( newElement ) )
 		{
 			for( ElementSet::const_iterator iter = elementSet.cbegin(); iter != elementSet.cend(); iter++ )


Don't slave graph clock in live mode

Don't slave graph clock in live mode

--- src/AudioRenderer.cpp
+++ src/AudioRenderer.cpp
@@ -359,8 +359,11 @@

         if (m_device)
         {
-            m_myClock->SlaveClockToAudio(m_device->GetClock(), m_startTime + m_startClockOffset);
-            m_startClockOffset = 0;
+            assert(m_live == m_device->IsLive());
+
+            if (!m_live)
+                m_myClock->SlaveClockToAudio(m_device->GetClock(), m_startTime + m_startClockOffset);
+
             m_device->Start();
         }
     }


Cleanup: Remove unused DeferredCallCallback.

BUG=none
TEST=none
R=michaeln

Review URL: http://codereview.chromium.org/9023002

git-svn-id: de016e52bd170d2d4f2344f9bf92d50478b649e0@115543 0039d316-1c4b-4281-b951-d872f2087c98

--- webkit/appcache/appcache_service.cc
+++ webkit/appcache/appcache_service.cc
@@ -65,11 +65,6 @@
     callback_.Reset();
   }

-  static void DeferredCallCallback(const net::CompletionCallback& callback,
-                                   int rv) {
-    callback.Run(rv);
-  }
-
   AppCacheService* service_;
   net::CompletionCallback callback_;
 };


Do 100 sweeps (can be increased)

Do 100 sweeps (can be increased)

--- Code/infer_logx.cpp
+++ Code/infer_logx.cpp
@@ -199,7 +199,7 @@
 	Assignment assignment(data);
 	assignment.initialise();

-	for(int i=0; i<10000000; i++)
+	for(int i=0; i<100; i++)
 	{
 		cout<<assignment.update_all()<<endl;
 		assignment.save();


Added tests for expirations.

Added tests for expirations.

Modified tests to deal with reinsertions.

Made all tables stack-allocated to deal with memory issues.

--- unitTests/testTable2.C
+++ unitTests/testTable2.C
@@ -691,7 +691,13 @@
             }
             // Ensure we did find it
             BOOST_CHECK_MESSAGE(found,
-                                "Results did not contain expected tuple '"
+                                "Error in test line "
+                                << _test._line
+                                << " with suffix "
+                                << "\""
+                                << _remainder
+                                << "\". Results did not contain "
+                                << "expected tuple '"
                                 << _tuple->toString()
                                 << "'.");
           }
@@ -922,6 +928,16 @@
 {
   table2Test t[] =
     {
+      table2Test("i<0,10>;i<0,15>;i<0,20>;i<0,25>;m<0,10>;" // first one flushed
+                 //      >----------------------->
+                 "i<0,15>;"
+                 //      >20, 25, 15>
+                 "i<0,30>;f<0,15>;m<0,20>;" // 15 refreshed, 20 not
+                 //      >25, 15, 30>
+                 "i<0,15>;i<0,15>;i<0,35>;m<0,25>;",
+                 __LINE__,
+                 Table2::KEY01, 3),
+
       table2Test("i<0,10>;i<0,15>;f<0,15>;m<0,10>;d<0,15>;m<0,15>;",
                  __LINE__,
                  Table2::KEY0),
@@ -1054,6 +1070,7 @@
 public:
   intAggTest2(std::string script,
               Table2::Key& key,
+              uint32_t size,
               Table2::Key& groupBy,
               uint aggField,
               std::string func,
@@ -1068,11 +1085,12 @@

 intAggTest2::intAggTest2(std::string script,
                          Table2::Key& key,
+                         uint32_t size,
                          Table2::Key& groupBy,
                          uint aggFieldNo,
                          std::string func,
                          int line)
-  : table2Test(script, line, key),
+  : table2Test(script, line, key, size),
     _groupBy(groupBy),
     _aggFieldNo(aggFieldNo),
     _function(func)
@@ -1156,9 +1174,9 @@
                     << _remainder
                     << "\". Script should expect an update with '"
                     << t->toString()
-                    << "' but contained a '"
+                    << "' but contained the '"
                     << _command
-                    << "' instead.");
+                    << "' command instead.");
         _remainder = std::string();
         return;
       }
@@ -1216,6 +1234,36 @@
 testTable2::testAggregates()
 {
   intAggTest2 t[] = {
+    // Test reinsertion without update but with time upate
+    intAggTest2("i<0,10>;u<0,10>;i<0,5>;u<0,5>;i<0,20>;"
+                // <10, 5, 20<
+                "i<0,3>;u<0,3>;m<0,10>;"
+                // <5, 20, 3<
+                "i<0,8>;i<0,15>;m<0,20>;"
+                // <3, 8, 15<
+                "i<0,4>;u<0,4>;"
+                // <8, 15, 4<
+                "i<0,8>;i<0,20>;"
+                // <4, 8, 20<
+                "i<0,30>;u<0,8>;",
+                // <8, 20, 30<
+                Table2::KEY01, 3,
+                Table2::KEY0, 1, "MIN",
+                __LINE__),
+
+
+    // Here there's an update for every insert that is not identical to
+    // its preceeding one since the primary key is the first field, so
+    // any new insertion removes the old tuple.  When the last entry is
+    // gone, no update is received.
+    intAggTest2("i<0,10>;u<0,10>;i<0,10>;i<0,15>;u<0,15>;i<0,5>;u<0,5>;d<0,5>;",
+                Table2::KEY0, // first field is indexed
+                Table2::DEFAULT_SIZE, // use default max size
+                Table2::KEY0, // first field is group-by
+                1, // second field is aggregated
+                "MIN", // aggregate function is MIN
+                __LINE__),
+
     // The following tests script expects the sequence
     // INSERT <0, 10>
     // UPDATE <0, 10>
@@ -1224,24 +1272,9 @@
     // UPDATE <0, 5>
     // DELETE <0, 5>
     // UPDATE <0, 10>
-    // Scripts must always end with a semicolon!!!!!!!!!
-    // Scripts must always end with a semicolon!!!!!!!!!
-    // Scripts must always end with a semicolon!!!!!!!!!
-    // Scripts must always end with a semicolon!!!!!!!!!
-    // Scripts must always end with a semicolon!!!!!!!!!
     intAggTest2("i<0,10>;u<0,10>;i<0,15>;i<0,5>;u<0,5>;d<0,5>;u<0,10>;",
                 Table2::KEY01, // first field is indexed
-                Table2::KEY0, // first field is group-by
-                1, // second field is aggregated
-                "MIN", // aggregate function is MIN
-                __LINE__),
-
-    // Here there's an update for every insert that is not identical to
-    // its preceeding one since the primary key is the first field, so
-    // any new insertion removes the old tuple.  When the last entry is
-    // gone, no update is received.
-    intAggTest2("i<0,10>;u<0,10>;i<0,10>;i<0,15>;u<0,15>;i<0,5>;u<0,5>;d<0,5>;",
-                Table2::KEY0, // first field is indexed
+                Table2::DEFAULT_SIZE, // use default max size
                 Table2::KEY0, // first field is group-by
                 1, // second field is aggregated
                 "MIN", // aggregate function is MIN
@@ -1253,16 +1286,19 @@
     // INSERT <0, 5>
     // UPDATE <0, 5>
     intAggTest2("i<0,10>;u<0,10>;i<0,5>;u<0,5>;",
-                Table2::KEY01, Table2::KEY0,
+                Table2::KEY01, Table2::DEFAULT_SIZE,
+                Table2::KEY0,
                 1, "MIN",
                 __LINE__),

     intAggTest2("i<0,10>;u<0,10>;i<0,5>;u<0,5>;i<0,20>;i<0,30>;",
-                Table2::KEY01, Table2::KEY0, 1, "MIN",
+                Table2::KEY01, Table2::DEFAULT_SIZE,
+                Table2::KEY0, 1, "MIN",
                 __LINE__),

     intAggTest2("i<0,10>;u<0,10>;i<0,5>;u<0,5>;i<0,20>;i<0,3>;u<0,3>;i<0,4>;",
-                Table2::KEY01, Table2::KEY0, 1, "MIN",
+                Table2::KEY01, Table2::DEFAULT_SIZE,
+                Table2::KEY0, 1, "MIN",
                 __LINE__),

@@ -1270,19 +1306,23 @@
     // MAX

     intAggTest2("i<0,10>;u<0,10>;i<0,5>;",
-                Table2::KEY01, Table2::KEY0, 1, "MAX",
+                Table2::KEY01, Table2::DEFAULT_SIZE,
+                Table2::KEY0, 1, "MAX",
                 __LINE__),

     intAggTest2("i<0,10>;u<0,10>;i<0,15>;u<0,15>;i<0,3>;",
-                Table2::KEY01, Table2::KEY0, 1, "MAX",
+                Table2::KEY01, Table2::DEFAULT_SIZE,
+                Table2::KEY0, 1, "MAX",
                 __LINE__),

     intAggTest2("i<0,10>;u<0,10>;i<0,5>;i<0,15>;u<0,15>;",
-                Table2::KEY01, Table2::KEY0, 1, "MAX",
+                Table2::KEY01, Table2::DEFAULT_SIZE,
+                Table2::KEY0, 1, "MAX",
                 __LINE__),

     intAggTest2("i<0,10>;u<0,10>;i<0,10>;",
-                Table2::KEY01, Table2::KEY0, 1, "MAX",
+                Table2::KEY01, Table2::DEFAULT_SIZE,
+                Table2::KEY0, 1, "MAX",
                 __LINE__)
   };

@@ -1321,87 +1361,88 @@
     t->freeze();
     tpls[i] = t;
   }
-
-  //  First: tuples inserted can be looked up.  Tuples not inserted
-  // cannot be looked up.  Create a very simple table
-  Table2Ptr tbl(new Table2("test_table", Table2::KEY0));
-  for(uint i=0;
-      i < SIZE/2;
-      i++) {
-    tbl->insert(tpls[i]);
-  }
-
-
-  for(uint i = 0;
-      i< SIZE/2;
-      i++) {
-    TuplePtr t = Tuple::mk();
-    t->append(Val_UInt32::mk(i));
-    t->append(Val_UInt32::mk(i/2));
-    t->append(Val_UInt32::mk(i/4));
-    t->append(Val_UInt32::mk(i % (SIZE/2)));
-    t->append(Val_UInt32::mk(i));
-    t->freeze();
-    BOOST_CHECK_MESSAGE(!tbl->lookup(Table2::KEY0, t)->done(),
-                        "Table test. Lookup "
-                        << i
-                        << ".  Tuple is not in the table but should.");
-
-    t = Tuple::mk();
-    t->append(Val_UInt32::mk(i + SIZE/2));
-    t->append(Val_UInt32::mk(i/2));
-    t->append(Val_UInt32::mk(i/4));
-    t->append(Val_UInt32::mk(i % (SIZE/2)));
-    t->append(Val_UInt32::mk(i));
-    t->freeze();
-    BOOST_CHECK_MESSAGE(tbl->lookup(Table2::KEY0, t)->done(),
-                        "Table test. Lookup "
-                        << (i + SIZE/2)
-                        << ".  Tuple is in the table but shouldn't");
-  }
-
-
-  // Check secondary indices
-  tbl.reset(new Table2("test_table", Table2::KEY0, SIZE));
-  tbl->secondaryIndex(Table2::KEY4);
-  for(uint i = 0;
-      i < SIZE;
-      i++) {
-    tbl->insert(tpls[i]);
-  }
-
-  // Now every tuple we find with the first quarter of counters in field
-  // 4 must have four exactly distinct instances in the index
-  for(uint i = 0;
-      i < SIZE / 4;
-      i++) {
-    TuplePtr t = Tuple::mk();
-    t->append(Val_UInt32::mk(i));
-    t->append(Val_UInt32::mk(i));
-    t->append(Val_UInt32::mk(i));
-    t->append(Val_UInt32::mk(i));
-    t->append(Val_UInt32::mk(i));
-    t->freeze();
-    Table2::Iterator iter = tbl->lookup(Table2::KEY4, t);
-    for (uint counter = 0;
-         counter < 4;
-         counter++) {
-      TuplePtr result = iter->next();
-      BOOST_CHECK_MESSAGE(result != NULL,
+
+  {
+    //  First: tuples inserted can be looked up.  Tuples not inserted
+    // cannot be looked up.  Create a very simple table
+    Table2 tbl("test_table", Table2::KEY0);
+    for(uint i=0;
+        i < SIZE/2;
+        i++) {
+      tbl.insert(tpls[i]);
+    }
+
+
+    for(uint i = 0;
+        i< SIZE/2;
+        i++) {
+      TuplePtr t = Tuple::mk();
+      t->append(Val_UInt32::mk(i));
+      t->append(Val_UInt32::mk(i/2));
+      t->append(Val_UInt32::mk(i/4));
+      t->append(Val_UInt32::mk(i % (SIZE/2)));
+      t->append(Val_UInt32::mk(i));
+      t->freeze();
+      BOOST_CHECK_MESSAGE(!tbl.lookup(Table2::KEY0, t)->done(),
+                          "Table test. Lookup "
+                          << i
+                          << ".  Tuple is not in the table but should.");
+
+      t = Tuple::mk();
+      t->append(Val_UInt32::mk(i + SIZE/2));
+      t->append(Val_UInt32::mk(i/2));
+      t->append(Val_UInt32::mk(i/4));
+      t->append(Val_UInt32::mk(i % (SIZE/2)));
+      t->append(Val_UInt32::mk(i));
+      t->freeze();
+      BOOST_CHECK_MESSAGE(tbl.lookup(Table2::KEY0, t)->done(),
+                          "Table test. Lookup "
+                          << (i + SIZE/2)
+                          << ".  Tuple is in the table but shouldn't");
+    }
+  }
+  {
+    // Check secondary indices
+    Table2 tbl("test_table", Table2::KEY0, SIZE);
+    tbl.secondaryIndex(Table2::KEY4);
+    for(uint i = 0;
+        i < SIZE;
+        i++) {
+      tbl.insert(tpls[i]);
+    }
+
+    // Now every tuple we find with the first quarter of counters in field
+    // 4 must have four exactly distinct instances in the index
+    for(uint i = 0;
+        i < SIZE / 4;
+        i++) {
+      TuplePtr t = Tuple::mk();
+      t->append(Val_UInt32::mk(i));
+      t->append(Val_UInt32::mk(i));
+      t->append(Val_UInt32::mk(i));
+      t->append(Val_UInt32::mk(i));
+      t->append(Val_UInt32::mk(i));
+      t->freeze();
+      Table2::Iterator iter = tbl.lookup(Table2::KEY4, t);
+      for (uint counter = 0;
+           counter < 4;
+           counter++) {
+        TuplePtr result = iter->next();
+        BOOST_CHECK_MESSAGE(result != NULL,
+                            "Table test. Key "
+                            << i
+                            << " seems to have too few "
+                            << "tuples in the secondary index");
+      }
+
+      BOOST_CHECK_MESSAGE(iter->done() == true,
                           "Table test. Key "
                           << i
-                          << " seems to have too few "
-                          << "tuples in the secondary index");
+                          << " seems to have too many tuples "
+                          << "in the secondary index");
     }
-
-    BOOST_CHECK_MESSAGE(iter->done() == true,
-                        "Table test. Key "
-                        << i
-                        << " seems to have too many tuples "
-                        << "in the secondary index");
-  }
-}
-
+  }
+}

 void
@@ -1423,24 +1464,24 @@
   }

   // Create a unique index on first field
-  Table2Ptr tbl(new Table2("test_table", Table2::KEY0, SIZE));
+  Table2 tbl("test_table", Table2::KEY0, SIZE);
   for(uint i = 0;
       i < SIZE;
       i++) {
-    tbl->insert(tpls[i]);
+    tbl.insert(tpls[i]);
   }

   for(uint i = 0;
       i < SIZE;
       i++) {
-    tbl->remove(tpls[i]);
+    tbl.remove(tpls[i]);
   }

   // I should be unable to look up any elements at all
   for(uint i = 0;
       i< SIZE;
       i++) {
-    BOOST_CHECK_MESSAGE(tbl->lookup(Table2::KEY0, tpls[i])->done(),
+    BOOST_CHECK_MESSAGE(tbl.lookup(Table2::KEY0, tpls[i])->done(),
                         "Table test. Lookup of removed tuple "
                         << tpls[i]->toString()
                         << " should return no results.");
@@ -1467,24 +1508,24 @@
   }

   // Create a unique index on first two fields
-  Table2Ptr tbl(new Table2("test_table", Table2::KEY01, 200));
+  Table2 tbl("test_table", Table2::KEY01, 200);
   for(uint i = 0;
       i < SIZE;
       i++) {
-    tbl->insert(tpls[i]);
+    tbl.insert(tpls[i]);
   }

   for(uint i = 0;
       i < SIZE;
       i++) {
-    tbl->remove(tpls[i]);
+    tbl.remove(tpls[i]);
   }

   // I should be unable to look up any elements at all
   for(uint i = 0;
       i< SIZE;
       i++) {
-    BOOST_CHECK_MESSAGE(tbl->lookup(Table2::KEY01, tpls[i])->done(),
+    BOOST_CHECK_MESSAGE(tbl.lookup(Table2::KEY01, tpls[i])->done(),
                         "Table test. Lookup of removed tuple "
                         << tpls[i]->toString()
                         << " should return no results.");
@@ -1512,25 +1553,25 @@
   }

   // Create a unique index on all five fields
-  Table2Ptr tbl(new Table2("test_table", Table2::KEY01234, SIZE));
-  tbl->secondaryIndex(Table2::KEY1);
+  Table2 tbl("test_table", Table2::KEY01234, SIZE);
+  tbl.secondaryIndex(Table2::KEY1);
   for(uint i = 0;
       i < SIZE;
       i++) {
-    tbl->insert(tpls[i]);
+    tbl.insert(tpls[i]);
   }

   for(uint i = 0;
       i < SIZE;
       i++) {
-    tbl->remove(tpls[i]);
+    tbl.remove(tpls[i]);
   }

   // I should be unable to look up any elements at all
   for(uint i = 0;
       i< SIZE;
       i++) {
-    BOOST_CHECK_MESSAGE(tbl->lookup(Table2::KEY01234, tpls[i])->done(),
+    BOOST_CHECK_MESSAGE(tbl.lookup(Table2::KEY01234, tpls[i])->done(),
                         "Table test. Lookup of removed tuple "
                         << tpls[i]->toString()
                         << " should return no results.");
@@ -1543,49 +1584,6 @@
 {
   srand(0);

-  {
-    // Create a table with fixed size but not lifetime
-    Table2 t("succ", Table2::KEY2, 100, Table2::NO_EXPIRATION);
-    for (uint i = 0;
-         i < SIZE + EXTRA_TUPLES;
-         i++) {
-      // Make a random tuple
-      TuplePtr tup = Tuple::mk();
-
-      // My tuple name
-      tup->append(Val_Str::mk("succ"));
-
-      // My node address
-      ostringstream nodeID;
-      nodeID << "127.0.0.1:";
-      int port = rand() % 5;
-      nodeID << port;
-      tup->append(Val_Str::mk(nodeID.str()));
-
-      // My Node identifier
-      unsigned int nestedSeed = rand() % 5;
-      uint32_t words[ID::WORDS];
-      for (uint w = 0;
-           w < ID::WORDS;
-           w++) {
-        words[w] = rand_r(&nestedSeed);
-      }
-      tup->append(Val_ID::mk(ID::mk(words)));
-
-      tup->freeze();
-
-      // Choose between insert and delete
-      int r = rand();
-      //    std::cout << "Random number " << r << "\n";
-      if ((r & 1) == 0) {
-        //      std::cout << "Inserting " << tup->toString() << "\n";
-        t.insert(tup);
-      } else {
-        //      std::cout << "Deleting " << tup->toString() << "\n";
-        t.remove(tup);
-      }
-    }
-  }
   {
     // Create a table with fixed lifetime but no size
     boost::posix_time::
@@ -1632,6 +1630,49 @@
     }
   }
   {
+    // Create a table with fixed size but not lifetime
+    Table2 t("succ", Table2::KEY2, 100, Table2::NO_EXPIRATION);
+    for (uint i = 0;
+         i < SIZE + EXTRA_TUPLES;
+         i++) {
+      // Make a random tuple
+      TuplePtr tup = Tuple::mk();
+
+      // My tuple name
+      tup->append(Val_Str::mk("succ"));
+
+      // My node address
+      ostringstream nodeID;
+      nodeID << "127.0.0.1:";
+      int port = rand() % 5;
+      nodeID << port;
+      tup->append(Val_Str::mk(nodeID.str()));
+
+      // My Node identifier
+      unsigned int nestedSeed = rand() % 5;
+      uint32_t words[ID::WORDS];
+      for (uint w = 0;
+           w < ID::WORDS;
+           w++) {
+        words[w] = rand_r(&nestedSeed);
+      }
+      tup->append(Val_ID::mk(ID::mk(words)));
+
+      tup->freeze();
+
+      // Choose between insert and delete
+      int r = rand();
+      //    std::cout << "Random number " << r << "\n";
+      if ((r & 1) == 0) {
+        //      std::cout << "Inserting " << tup->toString() << "\n";
+        t.insert(tup);
+      } else {
+        //      std::cout << "Deleting " << tup->toString() << "\n";
+        t.remove(tup);
+      }
+    }
+  }
+  {
     // Create a table with fixed lifetime and size
     boost::posix_time::
       time_duration expiration(boost::posix_time::milliseconds(200));
@@ -1687,20 +1728,20 @@
 {
   boost::shared_ptr<testTable2> instance(new testTable2());

+  add(BOOST_CLASS_TEST_CASE(&testTable2::testAggregates, instance));
+  add(BOOST_CLASS_TEST_CASE(&testTable2::testInsertRemoveLookupScripts, instance));
+  add(BOOST_CLASS_TEST_CASE(&testTable2::testBatchMultikeyRemovals, instance));
   add(BOOST_CLASS_TEST_CASE(&testTable2::testPseudoRandomInsertDeleteSequences, instance));
   add(BOOST_CLASS_TEST_CASE(&testTable2::testProjectedLookups, instance));
   add(BOOST_CLASS_TEST_CASE(&testTable2::testSecondaryEquivalence, instance));
-  add(BOOST_CLASS_TEST_CASE(&testTable2::testAggregates, instance));
   add(BOOST_CLASS_TEST_CASE(&testTable2::testPrimaryOverwrite, instance));
   add(BOOST_CLASS_TEST_CASE(&testTable2::testCreateDestroy, instance));
   add(BOOST_CLASS_TEST_CASE(&testTable2::testSizeLimitID, instance));
   add(BOOST_CLASS_TEST_CASE(&testTable2::testSuperimposedIndexRemoval, instance));
   add(BOOST_CLASS_TEST_CASE(&testTable2::testSizeLimitSingle, instance));
   add(BOOST_CLASS_TEST_CASE(&testTable2::testSizeLimitMulti, instance));
-  add(BOOST_CLASS_TEST_CASE(&testTable2::testInsertRemoveLookupScripts, instance));
   add(BOOST_CLASS_TEST_CASE(&testTable2::testIndexing, instance));
   add(BOOST_CLASS_TEST_CASE(&testTable2::testBatchRemovals, instance));
-  add(BOOST_CLASS_TEST_CASE(&testTable2::testBatchMultikeyRemovals, instance));
   add(BOOST_CLASS_TEST_CASE(&testTable2::testUniqueTupleRemovals, instance));
 }


Config profile correctives after removing singletone

--- src/components/config_profile/test/profile_test.cc
+++ src/components/config_profile/test/profile_test.cc
@@ -46,183 +46,170 @@

 class ProfileTest : public ::testing::Test {
  protected:
-  virtual void SetUp() {
-    Profile::destroy();
-  }
-  virtual void TearDown() {
-    Profile::destroy();
-  }
-
+  profile::Profile profile_;
 };
-
-TEST_F(ProfileTest, SingletonProfile) {
-  Profile::instance();
-  EXPECT_TRUE(Profile::exists());
-  Profile::destroy();
-  EXPECT_FALSE(Profile::exists());
-}

 TEST_F(ProfileTest, UpdateConfigWithDefaultFile) {
   // Default value
   uint32_t thread_min_stack_size = threads::Thread::kMinStackSize;
   EXPECT_EQ(thread_min_stack_size,
-            Profile::instance()->thread_min_stack_size());
-  EXPECT_FALSE(Profile::instance()->enable_policy());
+            profile_.thread_min_stack_size());
+  EXPECT_FALSE(profile_.enable_policy());
   std::string vr_help_title_ = "";
-  EXPECT_EQ(vr_help_title_, Profile::instance()->vr_help_title());
-  EXPECT_EQ("smartDeviceLink.ini", Profile::instance()->config_file_name());
-
-  Profile::instance()->UpdateValues();
+  EXPECT_EQ(vr_help_title_, profile_.vr_help_title());
+  EXPECT_EQ("smartDeviceLink.ini", profile_.config_file_name());
+
+  profile_.UpdateValues();
   // Value was updated
   thread_min_stack_size = 20480;
   EXPECT_EQ(thread_min_stack_size,
-            Profile::instance()->thread_min_stack_size());
-  EXPECT_TRUE(Profile::instance()->enable_policy());
+            profile_.thread_min_stack_size());
+  EXPECT_TRUE(profile_.enable_policy());
   vr_help_title_ = "Available Vr Commands List";
-  EXPECT_EQ(vr_help_title_, Profile::instance()->vr_help_title());
+  EXPECT_EQ(vr_help_title_, profile_.vr_help_title());
 }

 TEST_F(ProfileTest, SetConfigFileWithoutCallUpdate) {
   // Default value
   uint32_t thread_min_stack_size = threads::Thread::kMinStackSize;
   EXPECT_EQ(thread_min_stack_size,
-            Profile::instance()->thread_min_stack_size());
-  EXPECT_FALSE(Profile::instance()->enable_policy());
+            profile_.thread_min_stack_size());
+  EXPECT_FALSE(profile_.enable_policy());
   std::string vr_help_title_ = "";
-  EXPECT_EQ(vr_help_title_, Profile::instance()->vr_help_title());
-  EXPECT_EQ("smartDeviceLink.ini", Profile::instance()->config_file_name());
-
-  Profile::instance()->config_file_name("smartDeviceLink.ini");
-  EXPECT_EQ("smartDeviceLink.ini", Profile::instance()->config_file_name());
+  EXPECT_EQ(vr_help_title_, profile_.vr_help_title());
+  EXPECT_EQ("smartDeviceLink.ini", profile_.config_file_name());
+
+  profile_.config_file_name("smartDeviceLink.ini");
+  EXPECT_EQ("smartDeviceLink.ini", profile_.config_file_name());

   // Value was updated
   thread_min_stack_size = 20480;
   EXPECT_EQ(thread_min_stack_size,
-            Profile::instance()->thread_min_stack_size());
-  EXPECT_TRUE(Profile::instance()->enable_policy());
+            profile_.thread_min_stack_size());
+  EXPECT_TRUE(profile_.enable_policy());
   vr_help_title_ = "Available Vr Commands List";
-  EXPECT_EQ(vr_help_title_, Profile::instance()->vr_help_title());
+  EXPECT_EQ(vr_help_title_, profile_.vr_help_title());
 }

 TEST_F(ProfileTest, SetConfigFileWithUpdate) {
   // Default value
   uint32_t thread_min_stack_size = threads::Thread::kMinStackSize;
   EXPECT_EQ(thread_min_stack_size,
-            Profile::instance()->thread_min_stack_size());
-  Profile::instance()->config_file_name("smartDeviceLink.ini");
-  EXPECT_EQ("smartDeviceLink.ini", Profile::instance()->config_file_name());
+            profile_.thread_min_stack_size());
+  profile_.config_file_name("smartDeviceLink.ini");
+  EXPECT_EQ("smartDeviceLink.ini", profile_.config_file_name());

   // Value was updated
   thread_min_stack_size = 20480;
   EXPECT_EQ(thread_min_stack_size,
-            Profile::instance()->thread_min_stack_size());
+            profile_.thread_min_stack_size());

   // Update config file again
-  Profile::instance()->UpdateValues();
+  profile_.UpdateValues();

   // Value should be the same
   EXPECT_EQ(thread_min_stack_size,
-            Profile::instance()->thread_min_stack_size());
+            profile_.thread_min_stack_size());
 }

 TEST_F(ProfileTest, UpdateManyTimesDefaultFile) {
   //using for check logger's work - core dump when this test was started and log4cxx exists in test derictory
-  Profile::instance()->config_file_name("smartDeviceLink.ini");
-  EXPECT_EQ("smartDeviceLink.ini", Profile::instance()->config_file_name());
+  profile_.config_file_name("smartDeviceLink.ini");
+  EXPECT_EQ("smartDeviceLink.ini", profile_.config_file_name());
   // Update config many times
   for (int i = 0; i < 10; i++) {
-    Profile::instance()->UpdateValues();
+    profile_.UpdateValues();
   }
 }

 TEST_F(ProfileTest, UpdateIntValues) {
   // Default value
-  EXPECT_EQ("smartDeviceLink.ini", Profile::instance()->config_file_name());
+  EXPECT_EQ("smartDeviceLink.ini", profile_.config_file_name());
   uint32_t thread_min_stack_size = threads::Thread::kMinStackSize;
   EXPECT_EQ(thread_min_stack_size,
-            Profile::instance()->thread_min_stack_size());
+            profile_.thread_min_stack_size());

   // Set config file with default name
-  Profile::instance()->config_file_name("smartDeviceLink.ini");
-  EXPECT_EQ("smartDeviceLink.ini", Profile::instance()->config_file_name());
+  profile_.config_file_name("smartDeviceLink.ini");
+  EXPECT_EQ("smartDeviceLink.ini", profile_.config_file_name());

   // Value changes
   thread_min_stack_size = 20480;
   EXPECT_EQ(thread_min_stack_size,
-            Profile::instance()->thread_min_stack_size());
+            profile_.thread_min_stack_size());

   // Update config file again
-  Profile::instance()->UpdateValues();
+  profile_.UpdateValues();
   // Values are same
   EXPECT_EQ(thread_min_stack_size,
-            Profile::instance()->thread_min_stack_size());
+            profile_.thread_min_stack_size());

   // Set new config file
-  Profile::instance()->config_file_name("smartDeviceLink_test.ini");
-  EXPECT_EQ("smartDeviceLink_test.ini",
-            Profile::instance()->config_file_name());
+  profile_.config_file_name("smartDeviceLink_test.ini");
+  EXPECT_EQ("smartDeviceLink_test.ini",
+            profile_.config_file_name());

   // Value changes
   thread_min_stack_size = 21000;
   EXPECT_EQ(thread_min_stack_size,
-            Profile::instance()->thread_min_stack_size());
+            profile_.thread_min_stack_size());

   // Update config file again
-  Profile::instance()->UpdateValues();
-  EXPECT_EQ("smartDeviceLink_test.ini",
-            Profile::instance()->config_file_name());
+  profile_.UpdateValues();
+  EXPECT_EQ("smartDeviceLink_test.ini",
+            profile_.config_file_name());

   // Value should be the same
   EXPECT_EQ(thread_min_stack_size,
-            Profile::instance()->thread_min_stack_size());
+            profile_.thread_min_stack_size());

   // Set config file with default name again
-  Profile::instance()->config_file_name("smartDeviceLink.ini");
-  EXPECT_EQ("smartDeviceLink.ini", Profile::instance()->config_file_name());
+  profile_.config_file_name("smartDeviceLink.ini");
+  EXPECT_EQ("smartDeviceLink.ini", profile_.config_file_name());

   // Value should be changed
   thread_min_stack_size = 20480;
   EXPECT_EQ(thread_min_stack_size,
-            Profile::instance()->thread_min_stack_size());
+            profile_.thread_min_stack_size());
 }

 TEST_F(ProfileTest, UpdateBoolValues) {
   // Default values
-  EXPECT_EQ("smartDeviceLink.ini", Profile::instance()->config_file_name());
-  EXPECT_TRUE(Profile::instance()->launch_hmi());
-  EXPECT_FALSE(Profile::instance()->enable_policy());
+  EXPECT_EQ("smartDeviceLink.ini", profile_.config_file_name());
+  EXPECT_TRUE(profile_.launch_hmi());
+  EXPECT_FALSE(profile_.enable_policy());

   // Set config file
-  Profile::instance()->config_file_name("smartDeviceLink.ini");
+  profile_.config_file_name("smartDeviceLink.ini");
   // Check values
-  EXPECT_TRUE(Profile::instance()->launch_hmi());
-  EXPECT_TRUE(Profile::instance()->enable_policy());
-  EXPECT_FALSE(Profile::instance()->is_redecoding_enabled());
+  EXPECT_TRUE(profile_.launch_hmi());
+  EXPECT_TRUE(profile_.enable_policy());
+  EXPECT_FALSE(profile_.is_redecoding_enabled());

   // Update config file again
-  Profile::instance()->UpdateValues();
+  profile_.UpdateValues();
   // Values are same
-  EXPECT_TRUE(Profile::instance()->launch_hmi());
-  EXPECT_TRUE(Profile::instance()->enable_policy());
-  EXPECT_FALSE(Profile::instance()->is_redecoding_enabled());
-
-  // Change config file
-  Profile::instance()->config_file_name("smartDeviceLink_test.ini");
-  EXPECT_EQ("smartDeviceLink_test.ini",
-            Profile::instance()->config_file_name());
+  EXPECT_TRUE(profile_.launch_hmi());
+  EXPECT_TRUE(profile_.enable_policy());
+  EXPECT_FALSE(profile_.is_redecoding_enabled());
+
+  // Change config file
+  profile_.config_file_name("smartDeviceLink_test.ini");
+  EXPECT_EQ("smartDeviceLink_test.ini",
+            profile_.config_file_name());

   // Parameters after updating
-  EXPECT_FALSE(Profile::instance()->launch_hmi());
-  EXPECT_FALSE(Profile::instance()->enable_policy());
-  EXPECT_TRUE(Profile::instance()->is_redecoding_enabled());
-
-  // Update config file
-  Profile::instance()->UpdateValues();
+  EXPECT_FALSE(profile_.launch_hmi());
+  EXPECT_FALSE(profile_.enable_policy());
+  EXPECT_TRUE(profile_.is_redecoding_enabled());
+
+  // Update config file
+  profile_.UpdateValues();

   // Parameters are same
-  EXPECT_FALSE(Profile::instance()->launch_hmi());
-  EXPECT_FALSE(Profile::instance()->enable_policy());
-  EXPECT_TRUE(Profile::instance()->is_redecoding_enabled());
+  EXPECT_FALSE(profile_.launch_hmi());
+  EXPECT_FALSE(profile_.enable_policy());
+  EXPECT_TRUE(profile_.is_redecoding_enabled());
 }

 TEST_F(ProfileTest, UpdateStringValue) {
@@ -230,82 +217,83 @@
   std::string recording_file_name = "record.wav";
   std::string tts_delimiter_ = "";
   std::string vr_help_title_ = "";
+  std::string app_resource_folder = "";
   std::string server_address = "127.0.0.1";
-  std::string app_resource_folder = "";
-  EXPECT_EQ(app_resource_folder, Profile::instance()->app_resource_folder());
-  EXPECT_EQ(server_address, profile::Profile::instance()->server_address());
-
-  Profile::instance()->config_file_name("smartDeviceLink.ini");
-  EXPECT_EQ("smartDeviceLink.ini", Profile::instance()->config_file_name());
+
+  EXPECT_EQ(recording_file_name, profile_.recording_file_name());
+  EXPECT_EQ(server_address, profile_.server_address());
+
+  profile_.config_file_name("smartDeviceLink.ini");
+  EXPECT_EQ("smartDeviceLink.ini", profile_.config_file_name());

   // Check values
   app_resource_folder = file_system::CurrentWorkingDirectory();
-  EXPECT_EQ(app_resource_folder, Profile::instance()->app_resource_folder());
+  EXPECT_EQ(app_resource_folder, profile_.app_resource_folder());
   tts_delimiter_ = ",";
-  EXPECT_EQ(tts_delimiter_, Profile::instance()->tts_delimiter());
+  EXPECT_EQ(tts_delimiter_, profile_.tts_delimiter());
   vr_help_title_ = "Available Vr Commands List";
-  EXPECT_EQ(vr_help_title_, Profile::instance()->vr_help_title());
-
-  // Update config file
-  Profile::instance()->UpdateValues();
+  EXPECT_EQ(vr_help_title_, profile_.vr_help_title());
+  EXPECT_EQ(server_address, profile_.server_address());
+
+  // Update config file
+  profile_.UpdateValues();

   // Values are the same
-  EXPECT_EQ(app_resource_folder, Profile::instance()->app_resource_folder());
-  EXPECT_EQ(tts_delimiter_, Profile::instance()->tts_delimiter());
-  EXPECT_EQ(vr_help_title_, Profile::instance()->vr_help_title());
-  EXPECT_EQ(server_address, Profile::instance()->server_address());
+  EXPECT_EQ(tts_delimiter_, profile_.tts_delimiter());
+  EXPECT_EQ(vr_help_title_, profile_.vr_help_title());
+  EXPECT_EQ(server_address, profile_.server_address());
 }

 TEST_F(ProfileTest, UpdateInt_ValueAppearsInFileTwice) {
   // Default values
   uint32_t server_port = 8087;
-  EXPECT_EQ(server_port, Profile::instance()->server_port());
-  // Change config file
-  Profile::instance()->config_file_name("smartDeviceLink_test.ini");
-  EXPECT_EQ("smartDeviceLink_test.ini",
-            Profile::instance()->config_file_name());
+  EXPECT_EQ(server_port, profile_.server_port());
+  // Change config file
+  profile_.config_file_name("smartDeviceLink_test.ini");
+  EXPECT_EQ("smartDeviceLink_test.ini",
+            profile_.config_file_name());
   // Update config file
   // First server_port = 8088
   server_port = 8088;
-  EXPECT_EQ(server_port, Profile::instance()->server_port());
+  EXPECT_EQ(server_port, profile_.server_port());
 }

 TEST_F(ProfileTest, UpdateBool_ValueAppearsInFileTwice) {
   // Default values
-  EXPECT_FALSE(Profile::instance()->is_mixing_audio_supported());
-  // Change config file
-  Profile::instance()->config_file_name("smartDeviceLink_test.ini");
-  EXPECT_EQ("smartDeviceLink_test.ini",
-            Profile::instance()->config_file_name());
+  EXPECT_FALSE(profile_.is_mixing_audio_supported());
+  // Change config file
+  profile_.config_file_name("smartDeviceLink_test.ini");
+  EXPECT_EQ("smartDeviceLink_test.ini",
+            profile_.config_file_name());
   // Update config file
   // First value is false
-  EXPECT_FALSE(Profile::instance()->is_mixing_audio_supported());
+  EXPECT_FALSE(profile_.is_mixing_audio_supported());
 }

 TEST_F(ProfileTest, UpdateVectorOfString_ValueAppearsInFileTwice) {
   // Default values
   std::vector < std::string > time_out_promt;
-  EXPECT_EQ(time_out_promt, Profile::instance()->time_out_promt());
-  // Change config file
-  Profile::instance()->config_file_name("smartDeviceLink_test.ini");
-  EXPECT_EQ("smartDeviceLink_test.ini",
-            Profile::instance()->config_file_name());
+  EXPECT_EQ(time_out_promt, profile_.time_out_promt());
+  // Change config file
+  profile_.config_file_name("smartDeviceLink_test.ini");
+  EXPECT_EQ("smartDeviceLink_test.ini",
+            profile_.config_file_name());
   // Update config file
   time_out_promt.push_back("Please say a command,");
-  EXPECT_EQ(time_out_promt, Profile::instance()->time_out_promt());
+  EXPECT_EQ(time_out_promt, profile_.time_out_promt());
 }

 TEST_F(ProfileTest, UpdateString_ValueAppearsInFileTwice) {
   // Default values
   std::string recording_file_name = "record.wav";
-  EXPECT_EQ(recording_file_name, Profile::instance()->recording_file_name());
-  // Change config file
-  Profile::instance()->config_file_name("smartDeviceLink_test.ini");
-  EXPECT_EQ("smartDeviceLink_test.ini",
-            Profile::instance()->config_file_name());
+  EXPECT_EQ(recording_file_name, profile_.recording_file_name());
+  // Change config file
+  profile_.config_file_name("smartDeviceLink_test.ini");
+  EXPECT_EQ("smartDeviceLink_test.ini",
+            profile_.config_file_name());
   // Update config file
   recording_file_name = "video.wav";
-  EXPECT_EQ(recording_file_name, Profile::instance()->recording_file_name());
+  EXPECT_EQ(recording_file_name, profile_.recording_file_name());
 }

 TEST_F(ProfileTest, UpdatePairsValue) {
@@ -313,18 +301,18 @@
   std::pair < uint32_t, int32_t > value;
   value.first = 0;
   value.second = 0;
-  EXPECT_EQ(value, Profile::instance()->get_vehicle_data_frequency());
-
-  Profile::instance()->config_file_name("smartDeviceLink.ini");
-  EXPECT_EQ("smartDeviceLink.ini", Profile::instance()->config_file_name());
+  EXPECT_EQ(value, profile_.get_vehicle_data_frequency());
+
+  profile_.config_file_name("smartDeviceLink.ini");
+  EXPECT_EQ("smartDeviceLink.ini", profile_.config_file_name());

   value.first = 5;
   value.second = 1;
-  EXPECT_EQ(value, Profile::instance()->get_vehicle_data_frequency());
-
-  // Update config file
-  Profile::instance()->UpdateValues();
-  EXPECT_EQ(value, Profile::instance()->get_vehicle_data_frequency());
+  EXPECT_EQ(value, profile_.get_vehicle_data_frequency());
+
+  // Update config file
+  profile_.UpdateValues();
+  EXPECT_EQ(value, profile_.get_vehicle_data_frequency());
 }

 // Section with negative tests
@@ -334,55 +322,55 @@
   std::pair < uint32_t, int32_t > value;
   value.first = 0;
   value.second = 0;
-  EXPECT_EQ(value, Profile::instance()->read_did_frequency());
-
-  Profile::instance()->config_file_name("smartDeviceLink_invalid_pairs.ini");
+  EXPECT_EQ(value, profile_.read_did_frequency());
+
+  profile_.config_file_name("smartDeviceLink_invalid_pairs.ini");
   EXPECT_EQ("smartDeviceLink_invalid_pairs.ini",
-            Profile::instance()->config_file_name());
+            profile_.config_file_name());

   // Default values
   value.first = 5;
   value.second = 1;
-  EXPECT_EQ(value, Profile::instance()->read_did_frequency());
-
-  // Update config file
-  Profile::instance()->UpdateValues();
+  EXPECT_EQ(value, profile_.read_did_frequency());
+
+  // Update config file
+  profile_.UpdateValues();
   // Values are same
-  EXPECT_EQ(value, Profile::instance()->read_did_frequency());
+  EXPECT_EQ(value, profile_.read_did_frequency());
 }

 TEST_F(ProfileTest, CharValueInPairInsteadOfInt) {
   std::pair < uint32_t, int32_t > value;
   value.first = 0;
   value.second = 0;
-  EXPECT_EQ(value, Profile::instance()->get_vehicle_data_frequency());
-
-  Profile::instance()->config_file_name("smartDeviceLink_invalid_string.ini");
+  EXPECT_EQ(value, profile_.get_vehicle_data_frequency());
+
+  profile_.config_file_name("smartDeviceLink_invalid_string.ini");
   EXPECT_EQ("smartDeviceLink_invalid_string.ini",
-            Profile::instance()->config_file_name());
-
-  EXPECT_EQ(value, Profile::instance()->get_vehicle_data_frequency());
-
-  // Update config file
-  Profile::instance()->UpdateValues();
+            profile_.config_file_name());
+
+  EXPECT_EQ(value, profile_.get_vehicle_data_frequency());
+
+  // Update config file
+  profile_.UpdateValues();
   // Values are same
-  EXPECT_EQ(value, Profile::instance()->get_vehicle_data_frequency());
+  EXPECT_EQ(value, profile_.get_vehicle_data_frequency());
 }

 TEST_F(ProfileTest, EmptyValuesInPair) {
-  Profile::instance()->config_file_name("smartDeviceLink_invalid_pairs.ini");
+  profile_.config_file_name("smartDeviceLink_invalid_pairs.ini");
   EXPECT_EQ("smartDeviceLink_invalid_pairs.ini",
-            Profile::instance()->config_file_name());
+            profile_.config_file_name());

   std::pair < uint32_t, int32_t > value;
   value.first = 0;
   value.second = 0;
-  EXPECT_EQ(value, Profile::instance()->get_vehicle_data_frequency());
-
-  // Update config file
-  Profile::instance()->UpdateValues();
+  EXPECT_EQ(value, profile_.get_vehicle_data_frequency());
+
+  // Update config file
+  profile_.UpdateValues();
   // Values are same
-  EXPECT_EQ(value, Profile::instance()->get_vehicle_data_frequency());
+  EXPECT_EQ(value, profile_.get_vehicle_data_frequency());
 }

 TEST_F(ProfileTest, IntInsteadOfPair) {
@@ -390,268 +378,259 @@
   std::pair < uint32_t, int32_t > value;
   value.first = 0;
   value.second = 0;
-  EXPECT_EQ(value, Profile::instance()->start_stream_retry_amount());
-
-  Profile::instance()->config_file_name("smartDeviceLink_invalid_pairs.ini");
+  EXPECT_EQ(value, profile_.start_stream_retry_amount());
+
+  profile_.config_file_name("smartDeviceLink_invalid_pairs.ini");
   EXPECT_EQ("smartDeviceLink_invalid_pairs.ini",
-            Profile::instance()->config_file_name());
+            profile_.config_file_name());
   // Ini file includes only one element
   value.first = 9;
   value.second = 0;
-  EXPECT_EQ(value, Profile::instance()->start_stream_retry_amount());
-
-  // Update config file
-  Profile::instance()->UpdateValues();
+  EXPECT_EQ(value, profile_.start_stream_retry_amount());
+
+  // Update config file
+  profile_.UpdateValues();
   // Values are same
-  EXPECT_EQ(value, Profile::instance()->start_stream_retry_amount());
+  EXPECT_EQ(value, profile_.start_stream_retry_amount());
 }

 TEST_F(ProfileTest, WrongIntValue) {
   // Default value
   uint32_t heart_beat_timeout = 0;
-  EXPECT_EQ(heart_beat_timeout, Profile::instance()->heart_beat_timeout());
-
-  // Change config file
-  Profile::instance()->config_file_name("smartDeviceLink_invalid_int.ini");
+  EXPECT_EQ(heart_beat_timeout, profile_.heart_beat_timeout());
+
+  // Change config file
+  profile_.config_file_name("smartDeviceLink_invalid_int.ini");
   EXPECT_EQ("smartDeviceLink_invalid_int.ini",
-            Profile::instance()->config_file_name());
+            profile_.config_file_name());

   // Value in file includes letters. Check that value is default
   heart_beat_timeout = 0;
-  EXPECT_EQ(heart_beat_timeout, Profile::instance()->heart_beat_timeout());
-
-  // Update config file
-  Profile::instance()->UpdateValues();
-  EXPECT_EQ(heart_beat_timeout, Profile::instance()->heart_beat_timeout());
+  EXPECT_EQ(heart_beat_timeout, profile_.heart_beat_timeout());
+
+  // Update config file
+  profile_.UpdateValues();
+  EXPECT_EQ(heart_beat_timeout, profile_.heart_beat_timeout());
 }

 TEST_F(ProfileTest, WrongMaxIntValue) {
   // Default value
   uint32_t maxvalue = 2000000000;
-  EXPECT_EQ(maxvalue, Profile::instance()->max_cmd_id());
-
-  // Change config file
-  Profile::instance()->config_file_name("smartDeviceLink_invalid_int.ini");
+  EXPECT_EQ(maxvalue, profile_.max_cmd_id());
+
+  // Change config file
+  profile_.config_file_name("smartDeviceLink_invalid_int.ini");
   EXPECT_EQ("smartDeviceLink_invalid_int.ini",
-            Profile::instance()->config_file_name());
+            profile_.config_file_name());

   // Value in file is more than could be saved.
   // Check that value is default
-  EXPECT_EQ(maxvalue, Profile::instance()->max_cmd_id());
-
-  // Update config file
-  Profile::instance()->UpdateValues();
-  EXPECT_EQ(maxvalue, Profile::instance()->max_cmd_id());
+  EXPECT_EQ(maxvalue, profile_.max_cmd_id());
+
+  // Update config file
+  profile_.UpdateValues();
+  EXPECT_EQ(maxvalue, profile_.max_cmd_id());
 }

 TEST_F(ProfileTest, WrongMinIntValue) {
   // Default value
   uint32_t minvalue = threads::Thread::kMinStackSize;
-  EXPECT_EQ(minvalue, Profile::instance()->thread_min_stack_size());
+  EXPECT_EQ(minvalue, profile_.thread_min_stack_size());

   uint16_t server_port = 8087;
-  EXPECT_EQ(server_port, Profile::instance()->server_port());
-
-  // Change config file
-  Profile::instance()->config_file_name("smartDeviceLink_invalid_int.ini");
+  EXPECT_EQ(server_port, profile_.server_port());
+
+  // Change config file
+  profile_.config_file_name("smartDeviceLink_invalid_int.ini");
   EXPECT_EQ("smartDeviceLink_invalid_int.ini",
-            Profile::instance()->config_file_name());
+            profile_.config_file_name());

   //File include 0, value should be lefted as default
-  EXPECT_EQ(minvalue, Profile::instance()->thread_min_stack_size());
+  EXPECT_EQ(minvalue, profile_.thread_min_stack_size());
   //File include -1, value should be lefted as default
-  EXPECT_EQ(server_port, Profile::instance()->server_port());
-
-  // Update config file
-  Profile::instance()->UpdateValues();
+  EXPECT_EQ(server_port, profile_.server_port());
+
+  // Update config file
+  profile_.UpdateValues();

   // Default value should be lefted
-  EXPECT_EQ(minvalue, Profile::instance()->thread_min_stack_size());
-  EXPECT_EQ(server_port, Profile::instance()->server_port());
+  EXPECT_EQ(minvalue, profile_.thread_min_stack_size());
+  EXPECT_EQ(server_port, profile_.server_port());
 }

 TEST_F(ProfileTest, CheckCorrectValueWhenOtherValueInvalid) {
   // Default value
   uint32_t maxvalue = 2000000000;
-  EXPECT_EQ(maxvalue, Profile::instance()->max_cmd_id());
+  EXPECT_EQ(maxvalue, profile_.max_cmd_id());

   uint32_t thread_min_stack_size = threads::Thread::kMinStackSize;
   EXPECT_EQ(thread_min_stack_size,
-            Profile::instance()->thread_min_stack_size());
-
-  // Change config file
-  Profile::instance()->config_file_name("smartDeviceLink_test.ini");
-  EXPECT_EQ("smartDeviceLink_test.ini",
-            Profile::instance()->config_file_name());
+            profile_.thread_min_stack_size());
+
+  // Change config file
+  profile_.config_file_name("smartDeviceLink_test.ini");
+  EXPECT_EQ("smartDeviceLink_test.ini",
+            profile_.config_file_name());

   // Check that value is default
   maxvalue = 2000000000;
-  EXPECT_EQ(maxvalue, Profile::instance()->max_cmd_id());
+  EXPECT_EQ(maxvalue, profile_.max_cmd_id());

   // Other value is correct
   thread_min_stack_size = 21000;
   EXPECT_EQ(thread_min_stack_size,
-            Profile::instance()->thread_min_stack_size());
-
-  // Update config file
-  Profile::instance()->UpdateValues();
+            profile_.thread_min_stack_size());
+
+  // Update config file
+  profile_.UpdateValues();

   // In file the number is bigger than can be, default value should be lefted
-  EXPECT_EQ(maxvalue, Profile::instance()->max_cmd_id());
-  EXPECT_EQ(thread_min_stack_size,
-            Profile::instance()->thread_min_stack_size());
+  EXPECT_EQ(maxvalue, profile_.max_cmd_id());
+  EXPECT_EQ(thread_min_stack_size,
+            profile_.thread_min_stack_size());
 }

 TEST_F(ProfileTest, PairsValueInsteadOfInt) {
   // Set new config file
-  Profile::instance()->config_file_name("smartDeviceLink_invalid_int.ini");
+  profile_.config_file_name("smartDeviceLink_invalid_int.ini");
   EXPECT_EQ("smartDeviceLink_invalid_int.ini",
-            Profile::instance()->config_file_name());
+            profile_.config_file_name());
   // Get first number
   uint32_t list_files_in_none = 5;
-  EXPECT_EQ(list_files_in_none, Profile::instance()->list_files_in_none());
-
-  // Update config file
-  Profile::instance()->UpdateValues();
+  EXPECT_EQ(list_files_in_none, profile_.list_files_in_none());
+
+  // Update config file
+  profile_.UpdateValues();
   // Values are same
-  EXPECT_EQ(list_files_in_none, Profile::instance()->list_files_in_none());
+  EXPECT_EQ(list_files_in_none, profile_.list_files_in_none());
 }

 TEST_F(ProfileTest, StringValueIncludeSlashesAndRussianLetters) {
   // Default values
   std::string config_folder = "";
-  EXPECT_EQ(config_folder, Profile::instance()->app_resource_folder());
+  EXPECT_EQ(config_folder, profile_.app_resource_folder());
   std::string tts_delimiter_ = "";
-  std::string app_resource_folder = "";
   std::string app_storage_folder = "";
-
-  std::string current_dir =  file_system::CurrentWorkingDirectory();
-  Profile::instance()->config_file_name("smartDeviceLink_invalid_string.ini");
+  std::string current_dir = file_system::CurrentWorkingDirectory();
+
+  profile_.config_file_name("smartDeviceLink_invalid_string.ini");
   EXPECT_EQ("smartDeviceLink_invalid_string.ini",
-            Profile::instance()->config_file_name());
+            profile_.config_file_name());

   // Check values
   tts_delimiter_ = "coma and point";
-  EXPECT_EQ(tts_delimiter_, Profile::instance()->tts_delimiter());
+  EXPECT_EQ(tts_delimiter_, profile_.tts_delimiter());
   std::string server_address = "127.0.0.1 + слово";
-  EXPECT_EQ(server_address, profile::Profile::instance()->server_address());
-  app_resource_folder = "/new folder/";
-  EXPECT_EQ(current_dir+app_resource_folder, Profile::instance()->app_resource_folder());
+  EXPECT_EQ(server_address, profile_.server_address());
   app_storage_folder = "/\" \"";
-  EXPECT_EQ(current_dir+app_storage_folder, Profile::instance()->app_storage_folder());
-
-  // Update config file
-  Profile::instance()->UpdateValues();
+  EXPECT_EQ(current_dir+app_storage_folder, profile_.app_storage_folder());
+
+  // Update config file
+  profile_.UpdateValues();

   // Values are the same
-  EXPECT_EQ(tts_delimiter_, Profile::instance()->tts_delimiter());
-  EXPECT_EQ(server_address, profile::Profile::instance()->server_address());
-  EXPECT_EQ(current_dir+app_resource_folder, Profile::instance()->app_resource_folder());
+  EXPECT_EQ(tts_delimiter_, profile_.tts_delimiter());
+  EXPECT_EQ(server_address, profile_.server_address());
 }

 TEST_F(ProfileTest, StringUpperBoundValue) {
   // Default values
   std::string vr_help_title = "";
   std::string recording_file_name = "record.wav";
-  EXPECT_EQ(vr_help_title, Profile::instance()->vr_help_title());
-  EXPECT_EQ(recording_file_name, Profile::instance()->recording_file_name());
-
-  Profile::instance()->config_file_name("smartDeviceLink_invalid_string.ini");
+  EXPECT_EQ(vr_help_title, profile_.vr_help_title());
+  EXPECT_EQ(recording_file_name, profile_.recording_file_name());
+
+  profile_.config_file_name("smartDeviceLink_invalid_string.ini");
   EXPECT_EQ("smartDeviceLink_invalid_string.ini",
-            Profile::instance()->config_file_name());
+            profile_.config_file_name());

   // Total count of elements in ini file's string will be less 512
   vr_help_title =
       "0/0/0/1/2345678'90abc!def@ghi#jkl$mno%pqr^stu*vwx:yz()ABC-DEF_GHIJKL+MNO|PQR~STU{}WXY[]Z,01234567890a00012345678'90abc!def@ghi#jkl$mno%pqr^stu*vwx:yz()ABC-DEF_GHIJKL+MNO|PQR~STU{}WXY[]Z,01234567890a00012345678'90abc!def@ghi#jkl$mno%pqr^stu*vwx:yz()ABC-DEF_GHIJKL+MNO|PQR~STU{}WXY[]Z,01234567890a00012345678'90abc!def@ghi#jkl$mno%pqr^stu*vwx:yz()ABC-DEF_GHIJKL+MNO|PQR~STU{}WXY[]Z,01234567890a00012345678'90abc!def@ghi#jkl$mno%pqr^stu*vwx:yz()ABC-DEF_GHIJKL+MNO|PQR~STU{}WXY[]Z,01234567890abc!def@ghi";
-  EXPECT_EQ(vr_help_title, Profile::instance()->vr_help_title());
-  EXPECT_NE(vr_help_title, Profile::instance()->recording_file_name());
+  EXPECT_EQ(vr_help_title, profile_.vr_help_title());
+  EXPECT_NE(vr_help_title, profile_.recording_file_name());
   recording_file_name =
       "0/0/0/1/2345678'90abc!def@ghi#jkl$mno%pqr^stu*vwx:yz()ABC-DEF_GHIJKL+MNO|PQR~STU{}WXY[]Z,01234567890a00012345678'90abc!def@ghi#jkl$mno%pqr^stu*vwx:yz()ABC-DEF_GHIJKL+MNO|PQR~STU{}WXY[]Z,01234567890a00012345678'90abc!def@ghi#jkl$mno%pqr^stu*vwx:yz()ABC-DEF_GHIJKL+MNO|PQR~STU{}WXY[]Z,01234567890a00012345678'90abc!def@ghi#jkl$mno%pqr^stu*vwx:yz()ABC-DEF_GHIJKL+MNO|PQR~STU{}WXY[]Z,01234567890a00012345678'90abc!def@ghi#jkl$mno%pqr^stu*vwx:yz()ABC-DEF_GHIJKL+MNO|PQR~STU{}WXY[]Z,01234567890abc";
-  EXPECT_EQ(recording_file_name, Profile::instance()->recording_file_name());
-  // Update config file
-  Profile::instance()->UpdateValues();
+  EXPECT_EQ(recording_file_name, profile_.recording_file_name());
+  // Update config file
+  profile_.UpdateValues();
   // Values are the same
-  EXPECT_EQ(vr_help_title, Profile::instance()->vr_help_title());
-  EXPECT_EQ(recording_file_name, Profile::instance()->recording_file_name());
+  EXPECT_EQ(vr_help_title, profile_.vr_help_title());
+  EXPECT_EQ(recording_file_name, profile_.recording_file_name());
 }

 TEST_F(ProfileTest, CapitalLetterInBoolValue) {
   // Default values
-  EXPECT_EQ("smartDeviceLink.ini", Profile::instance()->config_file_name());
-  EXPECT_TRUE(Profile::instance()->launch_hmi());
-  EXPECT_FALSE(Profile::instance()->enable_policy());
+  EXPECT_EQ("smartDeviceLink.ini", profile_.config_file_name());
+  EXPECT_TRUE(profile_.launch_hmi());
+  EXPECT_FALSE(profile_.enable_policy());

   // Set config file
-  Profile::instance()->config_file_name("smartDeviceLink.ini");
+  profile_.config_file_name("smartDeviceLink.ini");
   // Check values
-  EXPECT_TRUE(Profile::instance()->launch_hmi());
-  EXPECT_TRUE(Profile::instance()->enable_policy());
-  EXPECT_FALSE(Profile::instance()->is_redecoding_enabled());
-
-  // Change config file
-  Profile::instance()->config_file_name("smartDeviceLink_invalid_boolean.ini");
+  EXPECT_TRUE(profile_.launch_hmi());
+  EXPECT_TRUE(profile_.enable_policy());
+  EXPECT_FALSE(profile_.is_redecoding_enabled());
+
+  // Change config file
+  profile_.config_file_name("smartDeviceLink_invalid_boolean.ini");
   EXPECT_EQ("smartDeviceLink_invalid_boolean.ini",
-            Profile::instance()->config_file_name());
+            profile_.config_file_name());

   // Parameters after updating
   // Parameter launch_hmi = True
-  EXPECT_FALSE(Profile::instance()->launch_hmi());
+  EXPECT_FALSE(profile_.launch_hmi());
   // EnablePolicy = TRUE
-  EXPECT_FALSE(Profile::instance()->enable_policy());
+  EXPECT_FALSE(profile_.enable_policy());
   // EnableRedecoding = FALSE
-  EXPECT_FALSE(Profile::instance()->is_redecoding_enabled());
+  EXPECT_FALSE(profile_.is_redecoding_enabled());
 }

 TEST_F(ProfileTest, CheckReadStringValue) {
   // Set new config file
-  Profile::instance()->config_file_name("smartDeviceLink_test.ini");
-  EXPECT_EQ("smartDeviceLink_test.ini",
-            Profile::instance()->config_file_name());
+  profile_.config_file_name("smartDeviceLink_test.ini");
+  EXPECT_EQ("smartDeviceLink_test.ini",
+            profile_.config_file_name());

   std::string app_storage_folder_;
-  profile::Profile::instance()->ReadStringValue(
-      &app_storage_folder_, file_system::CurrentWorkingDirectory().c_str(),
+  profile_.ReadStringValue(
+      &app_storage_folder_, "",
       "MAIN", "AppStorageFolder");
   // Get default value
   EXPECT_EQ("storage", app_storage_folder_);

   // Get value from file
   std::string server_address;
-  Profile::instance()->ReadStringValue(&server_address, "", "HMI",
+  profile_.ReadStringValue(&server_address, "", "HMI",
                                                 "ServerAddress");
   EXPECT_EQ("127.0.0.1", server_address);
 }

 TEST_F(ProfileTest, CheckReadBoolValue) {
   // Set new config file
-  Profile::instance()->config_file_name("smartDeviceLink_test.ini");
-  EXPECT_EQ("smartDeviceLink_test.ini",
-            Profile::instance()->config_file_name());
+  profile_.config_file_name("smartDeviceLink_test.ini");
+  EXPECT_EQ("smartDeviceLink_test.ini",
+            profile_.config_file_name());

   bool enable_policy;
-  Profile::instance()->ReadBoolValue(&enable_policy, false, "Policy",
+  profile_.ReadBoolValue(&enable_policy, false, "Policy",
                                               "EnablePolicy");
   EXPECT_FALSE(enable_policy);

-  // Change config back
-  Profile::destroy();
-  EXPECT_EQ("smartDeviceLink.ini", Profile::instance()->config_file_name());
-
-  //get default value
-  bool launch_hmi;
-  Profile::instance()->ReadBoolValue(&launch_hmi, true, "HMI",
-                                              "LaunchHMI");
-  EXPECT_TRUE(launch_hmi);
+  bool use_last_state;
+  profile_.ReadBoolValue(&use_last_state, true, "MAIN",
+                                              "UseLastState");
+  EXPECT_TRUE(use_last_state);
 }

 TEST_F(ProfileTest, CheckReadIntValue) {
   // Set new config file
-  Profile::instance()->config_file_name("smartDeviceLink_test.ini");
-  EXPECT_EQ("smartDeviceLink_test.ini",
-            Profile::instance()->config_file_name());
+  profile_.config_file_name("smartDeviceLink_test.ini");
+  EXPECT_EQ("smartDeviceLink_test.ini",
+            profile_.config_file_name());

   int server_port = 0;
-  Profile::instance()->ReadIntValue(&server_port, 0, "HMI",
+  profile_.ReadIntValue(&server_port, 0, "HMI",
                                              "ServerPort");

   EXPECT_EQ(8088, server_port);
@@ -659,13 +638,13 @@

 TEST_F(ProfileTest, CheckIntContainer) {
   // Set new config file
-  Profile::instance()->config_file_name("smartDeviceLink_test.ini");
-  EXPECT_EQ("smartDeviceLink_test.ini",
-            Profile::instance()->config_file_name());
+  profile_.config_file_name("smartDeviceLink_test.ini");
+  EXPECT_EQ("smartDeviceLink_test.ini",
+            profile_.config_file_name());

   bool isread = false;
   std::vector<int> diagmodes_list =
-      Profile::instance()->ReadIntContainer("MAIN",
+      profile_.ReadIntContainer("MAIN",
                                                      "SupportedDiagModes",
                                                      &isread);
   EXPECT_TRUE(isread);
@@ -690,17 +669,16 @@
 }

 TEST_F(ProfileTest, CheckVectorContainer) {
-  Profile::instance()->config_file_name("smartDeviceLink_test.ini");
-  EXPECT_EQ("smartDeviceLink_test.ini",
-            Profile::instance()->config_file_name());
+  profile_.config_file_name("smartDeviceLink_test.ini");
+  EXPECT_EQ("smartDeviceLink_test.ini",
+            profile_.config_file_name());

   // Get diag_modes after updating
-  const std::vector<uint32_t> &diag_modes = Profile::instance()
-      ->supported_diag_modes();
+  const std::vector<uint32_t> &diag_modes = profile_.supported_diag_modes();

   bool isread = false;
   std::vector<int> diagmodes_list =
-      Profile::instance()->ReadIntContainer("MAIN",
+      profile_.ReadIntContainer("MAIN",
                                                      "SupportedDiagModes",
                                                      &isread);
   EXPECT_TRUE(isread);
@@ -723,13 +701,13 @@

 TEST_F(ProfileTest, CheckStringContainer) {
   // Set new config file
-  Profile::instance()->config_file_name("smartDeviceLink_test.ini");
-  EXPECT_EQ("smartDeviceLink_test.ini",
-            Profile::instance()->config_file_name());
+  profile_.config_file_name("smartDeviceLink_test.ini");
+  EXPECT_EQ("smartDeviceLink_test.ini",
+            profile_.config_file_name());

   bool isread = false;
-  std::vector < std::string > diagmodes_list = Profile::instance()
-      ->ReadStringContainer("MAIN", "SupportedDiagModes", &isread);
+  std::vector < std::string > diagmodes_list =
+          profile_.ReadStringContainer("MAIN", "SupportedDiagModes", &isread);
   EXPECT_TRUE(isread);

   std::vector<std::string>::iterator diag_mode =
@@ -753,16 +731,16 @@
 #ifdef ENABLE_SECURITY
 TEST_F(ProfileTest, CheckIntContainerInSecurityData) {
   // Set new config file
-  Profile::instance()->config_file_name("smartDeviceLink_test.ini");
-  EXPECT_EQ("smartDeviceLink_test.ini",
-      Profile::instance()->config_file_name());
+  profile_.config_file_name("smartDeviceLink_test.ini");
+  EXPECT_EQ("smartDeviceLink_test.ini",
+      profile_.config_file_name());

   std::vector<int> force_unprotected_list =
-  Profile::instance()->ReadIntContainer(
+  profile_.ReadIntContainer(
       "Security Manager", "ForceUnprotectedService", NULL);

   std::vector<int> force_protected_list =
-  Profile::instance()->ReadIntContainer(
+  profile_.ReadIntContainer(
       "Security Manager", "ForceProtectedService", NULL);

   std::vector<int>::iterator res_unprotect = std::find(force_unprotected_list.begin(), force_unprotected_list.end(), 0x07);


Adding newline

Adding newline

--- src/condor_contrib/condor_cached/cached_server.cpp
+++ src/condor_contrib/condor_cached/cached_server.cpp
@@ -269,7 +269,7 @@
 	for (std::list<std::string>::iterator it = completed_torrents.begin(); it != completed_torrents.end(); it++)
 	{

-		dprintf(D_FULLDEBUG, "Completed torrent %s", (*it).c_str());
+		dprintf(D_FULLDEBUG, "Completed torrent %s\n", (*it).c_str());
 		SetCacheUploadStatus(*it, COMMITTED);

 	}


Fixing download cache code.

Fixing download cache code.

--- src/condor_contrib/condor_cached/cached_server.cpp
+++ src/condor_contrib/condor_cached/cached_server.cpp
@@ -739,9 +739,9 @@
 	std::string cache_owner;
 	cache_ad->EvalString(ATTR_OWNER, NULL, cache_owner);

-	if ( (cmd != CACHED_REPLICA_DOWNLOAD_FILES) || (authenticated_user != cache_owner) ) {
+	if ( (cmd != CACHED_REPLICA_DOWNLOAD_FILES) && (authenticated_user != cache_owner) ) {
 		dprintf(D_FAILURE | D_ALWAYS, "Download Files authentication error: authenticated: %s != cache: %s, denying download\n", authenticated_user.c_str(), cache_owner.c_str());
-		return PutErrorAd(sock, 1, "DownloadFiles", "Error, cache owner does not match authenticated owner. Client may only upload to their own cache.");
+		return PutErrorAd(sock, 1, "DownloadFiles", "Error, cache owner does not match authenticated owner. Client may only download their own cache.");
 	}

 	if ( GetUploadStatus(dirname) != COMMITTED ) {


Update help text

Update help text

--- src/app/help.cpp
+++ src/app/help.cpp
@@ -19,8 +19,8 @@

 const string helpMenu(
   "Usage: primecount x [OPTION]...\n"
-  "Count the primes below x < 2^63 using the prime counting function, by\n"
-  "default uses the Deleglise & Rivat algorithm (-d).\n"
+  "Count the primes below x <= 10^27 using the prime counting function,\n"
+  "by default the Deleglise-Rivat algorithm (-d) is used.\n"
   "\n"
   "Options:\n"
   "  -d,    --deleglise_rivat  LMO with Deleglise and Rivat improvements\n"


tcp: fix assertion failure on connection reset

The connection reset code posted an exception on the _data_received promise
to break a waiter (if any), but left the optional<promise<>> engaged.  This
caused the connection destructor to attempt to post a new exception on the
same promise, which is not legal.

Fix by disengaging the optional promise, and give the same treatment to
_all_data_acked_promise.

--- net/tcp.hh
+++ net/tcp.hh
@@ -469,9 +469,11 @@
             cleanup();
             if (_rcv._data_received_promise) {
                 _rcv._data_received_promise->set_exception(tcp_reset_error());
+                _rcv._data_received_promise = std::experimental::nullopt;
             }
             if (_snd._all_data_acked_promise) {
                 _snd._all_data_acked_promise->set_exception(tcp_reset_error());
+                _snd._all_data_acked_promise = std::experimental::nullopt;
             }
         }
         void do_time_wait() {


tcp: Improve merge_out_of_order

tcp: Improve merge_out_of_order

In case of seg_beg > _rcv.need, we can stop looking since seg_beg can
grow only.

--- net/tcp.hh
+++ net/tcp.hh
@@ -952,8 +952,10 @@
             // This segment has been receive already, drop it
             it = _rcv.out_of_order.erase(it);
         } else {
-            // seg_beg > _rcv.need, can not merge
+            // seg_beg > _rcv.need, can not merge. Note, seg_beg can grow only,
+            // so we can stop looking here.
             it++;
+            break;
         }
     }
 }


Fix for GitHub issue #33 - Problem with multi-dimensional arrays.

normalize_variable_unpacked() was not correctly calculating the
minimum expression width required to calculate the canonical
index.

--- netmisc.cc
+++ netmisc.cc
@@ -594,12 +594,12 @@
 	      // losses. So calculate a min_wid width.
 	    unsigned tmp_wid;
 	    unsigned min_wid = tmp->expr_width();
-	    if (use_stride != 1 && ((tmp_wid = num_bits(use_stride)) >= min_wid))
-		  min_wid = tmp_wid + 1;
 	    if (use_base != 0 && ((tmp_wid = num_bits(use_base)) >= min_wid))
 		  min_wid = tmp_wid + 1;
 	    if ((tmp_wid = num_bits(dims[idx].width()+1)) >= min_wid)
 		  min_wid = tmp_wid + 1;
+	    if (use_stride != 1)
+		  min_wid += num_bits(use_stride);

 	    tmp = pad_to_width(tmp, min_wid, *net);


Apply the transformation to the static type as well as the dynamic type. It doesn't make sense to carry along an untransformed static type

git-svn-id: 4c4cc70b1ef44ba2b7963015e681894188cea27e@227166 91177308-0d34-0410-b5e6-96231b3b80d8

--- source/Symbol/Type.cpp
+++ source/Symbol/Type.cpp
@@ -1141,7 +1141,7 @@
     {
         if (m_dynamic_type.IsValid())
         {
-            return TypeImpl(m_static_type, m_dynamic_type.GetPointerType());
+            return TypeImpl(m_static_type.GetPointerType(), m_dynamic_type.GetPointerType());
         }
         return TypeImpl(m_static_type.GetPointerType());
     }
@@ -1156,7 +1156,7 @@
     {
         if (m_dynamic_type.IsValid())
         {
-            return TypeImpl(m_static_type, m_dynamic_type.GetPointeeType());
+            return TypeImpl(m_static_type.GetPointeeType(), m_dynamic_type.GetPointeeType());
         }
         return TypeImpl(m_static_type.GetPointeeType());
     }
@@ -1171,7 +1171,7 @@
     {
         if (m_dynamic_type.IsValid())
         {
-            return TypeImpl(m_static_type, m_dynamic_type.GetLValueReferenceType());
+            return TypeImpl(m_static_type.GetReferenceType(), m_dynamic_type.GetLValueReferenceType());
         }
         return TypeImpl(m_static_type.GetReferenceType());
     }
@@ -1186,7 +1186,7 @@
     {
         if (m_dynamic_type.IsValid())
         {
-            return TypeImpl(m_static_type, m_dynamic_type.GetTypedefedType());
+            return TypeImpl(m_static_type.GetTypedefedType(), m_dynamic_type.GetTypedefedType());
         }
         return TypeImpl(m_static_type.GetTypedefedType());
     }
@@ -1201,7 +1201,7 @@
     {
         if (m_dynamic_type.IsValid())
         {
-            return TypeImpl(m_static_type, m_dynamic_type.GetNonReferenceType());
+            return TypeImpl(m_static_type.GetDereferencedType(), m_dynamic_type.GetNonReferenceType());
         }
         return TypeImpl(m_static_type.GetDereferencedType());
     }
@@ -1216,7 +1216,7 @@
     {
         if (m_dynamic_type.IsValid())
         {
-            return TypeImpl(m_static_type, m_dynamic_type.GetFullyUnqualifiedType());
+            return TypeImpl(m_static_type.GetUnqualifiedType(), m_dynamic_type.GetFullyUnqualifiedType());
         }
         return TypeImpl(m_static_type.GetUnqualifiedType());
     }
@@ -1231,7 +1231,7 @@
     {
         if (m_dynamic_type.IsValid())
         {
-            return TypeImpl(m_static_type, m_dynamic_type.GetCanonicalType());
+            return TypeImpl(m_static_type.GetCanonicalType(), m_dynamic_type.GetCanonicalType());
         }
         return TypeImpl(m_static_type.GetCanonicalType());
     }


Fix buffer issue with receiving data from a socket.

--- source/http_server.cpp
+++ source/http_server.cpp
@@ -11,7 +11,7 @@

 using namespace std;

-#define BUFFER_SIZE 32
+#define BUFFER_SIZE 128

 HTTPServer::HTTPServer(unsigned short port) : Server(port) {

@@ -31,12 +31,12 @@

 	string message = "";
 	received_size = client.receive(BUFFER_SIZE, buffer);
-    message.append(buffer);
+    message.append(buffer, received_size);

     while (!is_valid_http_message(message) && received_size > 0) {
 	    memset(buffer, 0, BUFFER_SIZE);
 		received_size = client.receive(BUFFER_SIZE, buffer);
-	    message.append(buffer);
+	    message.append(buffer, received_size);
     }

     return message;


Create main component data, to avoid warning in KGlobal::locale() later.

KGlobal::locale(): Warning your global KLocale is being recreated with a valid main component instead of a fake component, this usually means you tried to call i18n related functions before your main component was created. You should not do that since it most likely will not work

KF5 solves this, but kdelibs4 requires a main component data, for many things.

REVIEW: 120840

--- src/app/main.cpp
+++ src/app/main.cpp
@@ -31,9 +31,8 @@

 #include <KConfigGroup>
 #include <KSharedConfig>
-
-#include <KDE/KConfigGroup>
-#include <KDE/KMainWindow>
+#include <KComponentData>
+#include <KMainWindow>

 #include "widgets/applicationcomponents.h"
 #include "widgets/availablepagesview.h"
@@ -53,6 +52,8 @@
     App::initializeDependencies();

     QApplication app(argc, argv);
+
+    KComponentData mainComponentData("zanshin");

     KSharedConfig::Ptr config = KSharedConfig::openConfig("zanshin-migratorrc");
     KConfigGroup group = config->group("Migrations");


remove startup error messages from plugins that are disabled by user
User can still see errors in About Plugins for disabled ones, too

Reviewed-by: mae

--- src/app/main.cpp
+++ src/app/main.cpp
@@ -295,8 +295,9 @@
     {
         QStringList errors;
         foreach (ExtensionSystem::PluginSpec *p, pluginManager.plugins())
-            if (p->hasError())
-                errors.append(p->errorString());
+            // only show errors on startup if plugin is enabled.
+            if (p->hasError() && p->isEnabled() && !p->isDisabledByDependency())
+                errors.append(p->name() + "\n" + p->errorString());
         if (!errors.isEmpty())
             QMessageBox::warning(0,
                 QCoreApplication::translate("Application", "Qt Creator - Plugin loader messages"),


fix CheckWalletOwnsKey

fix CheckWalletOwnsKey

Former-commit-id: f55786597bb60462df77daff473aac99ad10fde0

--- src/rpc/rpcevo.cpp
+++ src/rpc/rpcevo.cpp
@@ -882,7 +882,7 @@
     }.Check(request);
 }

-static bool CheckWalletOwnsKey(CWallet* pwallet, const WitnessV0KeyHash& keyID) {
+static bool CheckWalletOwnsKey(CWallet* pwallet, const CKeyID& keyID) {
 #ifndef ENABLE_WALLET
     return false;
 #else
@@ -891,7 +891,7 @@
     }
     LegacyScriptPubKeyMan& spk_man = EnsureLegacyScriptPubKeyMan(*pwallet);
     LOCK2(pwallet->cs_wallet, spk_man.cs_KeyStore);
-    return spk_man.IsMine(GetScriptForDestination(CTxDestination(keyID)));
+    return spk_man.IsMine(GetScriptForDestination(CTxDestination(WitnessV0KeyHash(keyID))));
 #endif
 }


fix locks

fix locks

Former-commit-id: 03d9d40aa2616814399d21241ff388ecf064d65c

--- src/rpc/rpcevo.cpp
+++ src/rpc/rpcevo.cpp
@@ -987,7 +987,7 @@
             throw std::runtime_error("\"protx list wallet\" not supported when wallet is disabled");
         }
 #ifdef ENABLE_WALLET
-        LOCK(cs_main);
+        LOCK2(cs_main, pwallet->cs_wallet);

         if (request.params.size() > 4) {
             protx_list_help(request);
@@ -1023,7 +1023,7 @@
             protx_list_help(request);
         }

-        LOCK2(cs_main, pwallet->cs_wallet);
+        LOCK(cs_main);

         bool detailed = !request.params[2].isNull() ? request.params[2].get_bool() : false;


Debugging

Debugging

--- nj-v11.cpp
+++ nj-v11.cpp
@@ -84,7 +84,11 @@
                Local<Array> row  = Array::New(I,size1);

                dest->Set(i,row);
-               for(size_t j = 0;j < size1;j++) row->Set(j,Number::New(I,*(p + size0*j + i)));
+               for(size_t j = 0;j < size1;j++)
+               {
+                  printf("Storing X(%zu,%zu) = %f\n",i,j,p[size0*j + i]);
+                  row->Set(j,Number::New(I,*(p + size0*j + i)));
+               }
             }
             arg = dest;
          }


UiAPI crash bug: Check headless mode when AddWidget*() functions are called, stupid code might call this even in headless mode and we crashed to graphics scene ptr being null. Make a informative print and ask the user to check his code ;)

--- src/Core/Ui/UiAPI.cpp
+++ src/Core/Ui/UiAPI.cpp
@@ -71,7 +71,6 @@
     graphicsView(0),
     graphicsScene(0)
 {
-
     if (owner_->IsHeadless())
     {
         owner_->Asset()->RegisterAssetTypeFactory(AssetTypeFactoryPtr(new NullAssetFactory("QtUiFile")));
@@ -100,7 +99,7 @@

     viewportWidget = new SuppressedPaintWidget();
     graphicsView->setViewport(viewportWidget);
-//    viewportWidget->setAttribute(Qt::WA_DontShowOnScreen, true);
+    //viewportWidget->setAttribute(Qt::WA_DontShowOnScreen, true);
     viewportWidget->setGeometry(0, 0, graphicsView->width(), graphicsView->height());
     viewportWidget->setContentsMargins(0,0,0,0);

@@ -170,6 +169,11 @@

 UiProxyWidget *UiAPI::AddWidgetToScene(QWidget *widget, Qt::WindowFlags flags)
 {
+    if (owner->IsHeadless())
+    {
+        LogWarning("UiAPI: You are trying to add widgets to scene on a headless run, check your code!");
+        return 0;
+    }
     if (!widget)
     {
         LogError("AddWidgetToScene called with a null proxy widget!");
@@ -199,6 +203,12 @@

 bool UiAPI::AddProxyWidgetToScene(UiProxyWidget *widget)
 {
+    if (owner->IsHeadless())
+    {
+        LogWarning("UiAPI: You are trying to add widgets to scene on a headless run, check your code!");
+        return false;
+    }
+
     if (!widget)
     {
         LogError("AddWidgetToScene called with a null proxy widget!");
@@ -242,6 +252,12 @@

 void UiAPI::RemoveWidgetFromScene(QWidget *widget)
 {
+    if (owner->IsHeadless())
+    {
+        LogWarning("UiAPI: You are trying to remove widgets from scene on a headless run, check your code!");
+        return;
+    }
+
     if (!widget)
         return;

@@ -253,6 +269,11 @@

 void UiAPI::RemoveWidgetFromScene(QGraphicsProxyWidget *widget)
 {
+    if (owner->IsHeadless())
+    {
+        LogWarning("UiAPI: You are trying to remove widgets from scene on a headless run, check your code!");
+        return;
+    }
     if (!widget)
         return;

@@ -329,7 +350,12 @@
     }

     if (addToScene && widget)
-        AddWidgetToScene(widget);
+    {
+        if (!owner->IsHeadless())
+            AddWidgetToScene(widget);
+        else
+            LogWarning("UiAPI::LoadFromFile: You have addToScene = true, but this is a headless run (hence no ui scene).");
+    }

     return widget;
 }


Fixed a bug in density gradient for color images.

--- code/cmt/src/tools.cpp
+++ code/cmt/src/tools.cpp
@@ -854,8 +854,8 @@
 					patch(outputIndices[c][l].first, outputIndices[c][l].second) +=
 						outputGradients(offOut + l, k);

-				offIn += inputIndices.size();
-				offOut += outputIndices.size();
+				offIn += inputIndices[c].size();
+				offOut += outputIndices[c].size();
 			}
 		}


Change plot dialogs to be non-modal

Change plot dialogs to be non-modal

This changes the plot dialogs to be non-modal so multiple
data dialogs can be used simultaneously.

Change-Id: Ib9ba623737e562f87e3f27b33a8e5fceccadcd28

--- chemdata/mainwindow.cpp
+++ chemdata/mainwindow.cpp
@@ -254,30 +254,30 @@

 void MainWindow::showGraphs()
 {
-  GraphDialog dialog(this);
-
-  dialog.exec();
+  GraphDialog *dialog = new GraphDialog(this);
+
+  dialog->show();
 }

 void MainWindow::showHistogram()
 {
-  HistogramDialog dialog(this);
-
-  dialog.exec();
+  HistogramDialog *dialog = new HistogramDialog(this);
+
+  dialog->show();
 }

 void MainWindow::showPlotMatrix()
 {
-  PlotMatrixDialog dialog(this);
-
-  dialog.exec();
+  PlotMatrixDialog *dialog = new PlotMatrixDialog(this);
+
+  dialog->show();
 }

 void MainWindow::showParallelCoordinates()
 {
-  ParallelCoordinatesDialog dialog(this);
-
-  dialog.exec();
+  ParallelCoordinatesDialog *dialog = new ParallelCoordinatesDialog(this);
+
+  dialog->show();
 }

 void MainWindow::showMoleculeDetailsDialog(const QModelIndex &index)