avoid loop for normals of capsule

avoid loop for normals of capsule

--- src/Core/Mesh/MeshPrimitives.cpp
+++ src/Core/Mesh/MeshPrimitives.cpp
@@ -281,13 +281,17 @@
     for ( uint i = 0; i < nFaces; ++i )
     {
         const Scalar theta = i * thetaInc;
-        Scalar x = std::cos( theta ) * radius;
-        Scalar y = std::sin( theta ) * radius;
+        Vector3 normal( std::cos( theta ), std::sin( theta ), 0 );

         // Create 3 circles
-        result.m_vertices.emplace_back( x, y, -l );
-        result.m_vertices.emplace_back( x, y, 0.0 );
-        result.m_vertices.emplace_back( x, y, l );
+        Vector3 vertex = radius*normal;
+        result.m_vertices.emplace_back( vertex[0], vertex[1], -l );
+        result.m_vertices.emplace_back( vertex[0], vertex[1], 0.0 );
+        result.m_vertices.emplace_back( vertex[0], vertex[1], l );
+
+        result.m_normals.push_back( normal );
+        result.m_normals.push_back( normal );
+        result.m_normals.push_back( normal );
     }

     // Cylinder side faces
@@ -320,15 +324,20 @@
         {
             const Scalar theta = i * thetaInc;

-            const Scalar x = radius * std::cos( theta ) * std::sin( phi );
-            const Scalar y = radius * std::sin( theta ) * std::sin( phi );
-            const Scalar z = radius * std::cos( phi );
-
-            result.m_vertices.emplace_back( x, y, z - l );
+            const Vector3 normal( std::cos( theta ) * std::sin( phi ),
+                                  std::sin( theta ) * std::sin( phi ),
+                                  std::cos( phi ) );
+
+            Vector3 vertex = radius * normal;
+            vertex[2] -= l;
+
+            result.m_vertices.push_back( vertex );
+            result.m_normals.push_back( normal );
         }
     }
     // Add bottom point (south pole)
     result.m_vertices.emplace_back( 0, 0, -( l + radius ) );
+    result.m_normals.emplace_back( 0, 0, -1 );

     // First ring of sphere triangles (joining with the cylinder)
     for ( uint i = 0; i < nFaces; ++i )
@@ -381,16 +390,21 @@
         {
             const Scalar theta = i * thetaInc;

-            const Scalar x = radius * std::cos( theta ) * std::sin( phi );
-            const Scalar y = radius * std::sin( theta ) * std::sin( phi );
-            const Scalar z = radius * std::cos( phi );
-
-            result.m_vertices.emplace_back( x, y, z + l );
+            const Vector3 normal( std::cos( theta ) * std::sin( phi ),
+                                  std::sin( theta ) * std::sin( phi ),
+                                  std::cos( phi ) );
+
+            Vector3 vertex = radius * normal;
+            vertex[2] += l;
+
+            result.m_vertices.push_back( vertex );
+            result.m_normals.push_back( normal );
         }
     }

     // Add top point (north pole)
     result.m_vertices.emplace_back( 0, 0, ( l + radius ) );
+    result.m_normals.emplace_back( 0, 0, 1 );

     // First ring of sphere triangles (joining with the cylinder)
     for ( uint i = 0; i < nFaces; ++i )
@@ -432,7 +446,6 @@
     }

     // Compute normals and check results.
-    getAutoNormals( result, result.m_normals );
     checkConsistency( result );
     return result;
 }


avoid loop for normals of parametric sphere

--- src/Core/Mesh/MeshPrimitives.inl
+++ src/Core/Mesh/MeshPrimitives.inl
@@ -26,6 +26,8 @@
             result.m_vertices.push_back( Vector3( radius * std::cos( theta ) * std::sin( phi ),
                                                   radius * std::sin( theta ) * std::sin( phi ),
                                                   radius * std::cos( phi ) ) );
+            result.m_normals.push_back(result.m_vertices.back().normalized());
+
             // Regular triangles
             if ( v > 1 )
             {
@@ -42,8 +44,10 @@
     // Add the pole vertices.
     uint northPoleIdx = result.m_vertices.size();
     result.m_vertices.push_back( Vector3( 0, 0, radius ) );
+    result.m_normals.push_back( Vector3( 0, 0, 1 ) );
     uint southPoleIdx = result.m_vertices.size();
     result.m_vertices.push_back( Vector3( 0, 0, -radius ) );
+    result.m_normals.push_back( Vector3( 0, 0, -1 ) );

     // Add the polar caps triangles.
     for ( uint u = 0; u < slices; ++u )
@@ -55,12 +59,6 @@
             Triangle( southPoleIdx, nextSlice + stacks - 2, baseSlice + stacks - 2 ) );
     }

-    // Compute normals.
-    for ( const auto v : result.m_vertices )
-    {
-        const Vector3 n = v.normalized();
-        result.m_normals.push_back( n );
-    }
     checkConsistency( result );
     return result;
 }


Replaced TRI_VOC_ATTRIBUTE_ID by static string

--- arangod/Aql/Functions.cpp
+++ arangod/Aql/Functions.cpp
@@ -54,8 +54,6 @@

 using namespace arangodb;
 using namespace arangodb::aql;
-
-using VertexId = arangodb::traverser::VertexId;

 /// @brief thread-local cache for compiled regexes
 thread_local std::unordered_map<std::string, RegexMatcher*>* RegexCache =
@@ -477,7 +475,7 @@
     vertexId = vertexSlice.copyString();
   } else if (vertexSlice.isObject()) {
     vertexId = arangodb::basics::VelocyPackHelper::getStringValue(vertexSlice,
-                                                                  TRI_VOC_ATTRIBUTE_ID, "");
+                                                                  StaticStrings::IdString, "");
   } else {
     // Nothing to do.
     // Return (error for illegal input is thrown outside


Improve formatting of "killing current process"

--- killaction.c++
+++ killaction.c++
@@ -28,7 +28,7 @@
 }

 void KillAction::act(JNIEnv* jniEnv, jint resourceExhaustionFlags) {
-	fprintf(stderr, "killing current process\n");
+	fprintf(stderr, "\nKilling current process\n");
     kill(getpid(), signal);
 }


Ooops, forgot #include <config.h>

Ooops, forgot #include <config.h>

svn path=/trunk/kdenetwork/kmail/; revision=10193

--- kmail/kpgp.cpp
+++ kmail/kpgp.cpp
@@ -22,6 +22,8 @@

 #include <kapp.h>
 #include <kiconloader.h>
+
+#include <config.h>

 /* TODO :
   --  When there is no output from PGP, a warning dialog should


comment update

comment update

--- src/GUI/Plater/PresetChooser.cpp
+++ src/GUI/Plater/PresetChooser.cpp
@@ -66,7 +66,7 @@
             current_list = grep(current_list, [] (const Preset& x) -> bool { return !x.default_preset; });
         }

-        // # Read the current defaults from the settings file
+        // Read the current defaults from the settings file
         const auto& settings_defaults {_settings->default_presets.at(get_preset(group))};

         size_t i {0};


Call _on_select_preset from _on_change_combobox

--- src/GUI/Plater/PresetChooser.cpp
+++ src/GUI/Plater/PresetChooser.cpp
@@ -88,9 +88,11 @@

     // Prompt for unsaved changes and undo selections if cancelled and return early
     // Callback to close preset editor tab, close editor tabs, reload presets.
-    wxTheApp->CallAfter([this](){
-
-//        this->_on_select_preset(preset);
+    //
+    if (!this->prompt_unsaved_changes()) return;
+    wxTheApp->CallAfter([this,preset]()
+    {
+        this->_on_select_preset(preset);
         // reload presets; removes the modified mark
         this->load();
     });


only tile unfloated window if roles match

--- kwm/window.cpp
+++ kwm/window.cpp
@@ -973,7 +973,7 @@
     if(AXLibHasFlags(Window, AXWindow_Floating))
     {
         AXLibClearFlags(Window, AXWindow_Floating);
-        AddWindowToNodeTree(Display, Window->ID);
+        TileWindow(Display, Window);
         if((KWMSettings.StandbyOnFloat) &&
            (KWMSettings.Focus != FocusModeDisabled))
             KWMSettings.Focus = FocusModeAutoraise;


Add missing header.

Add missing header.

--- src/Index/src/TermTreatments.cpp
+++ src/Index/src/TermTreatments.cpp
@@ -21,6 +21,7 @@
 // THE SOFTWARE.

 #include <iostream>             // TODO: Remove this temporary include.
+#include <math.h>

 #include "BitFunnel/Term.h"
 #include "TermTreatments.h"


insert left-most if the focused window is not a valid insertion point

--- kwm/window.cpp
+++ kwm/window.cpp
@@ -708,7 +708,8 @@
             DEBUG("INSERT AT FOCUSED WINDOW");
             CurrentNode = GetTreeNodeFromWindowIDOrLinkNode(RootNode, Window->ID);
         }
-        else
+
+        if(!CurrentNode)
         {
             DEBUG("INSERT AT LEFT-MOST WINDOW");
             GetFirstLeafNode(RootNode, (void**)&CurrentNode);


backend: start GRPC server before connecting

This changes the initialization logic to first start the GRPC server and
then try to connect it all.

This is based on the assumption that we can initialize the GRPC server
and the plugin it has using the default/dummy system and we don't have
to have anything connected yet. Once something connects, the system gets
updated and the plugins start to "work".

--- backend/src/backend_api.cpp
+++ backend/src/backend_api.cpp
@@ -5,8 +5,8 @@
 void runBackend(const int mavlink_listen_port, void (*onServerStarted)(void *), void *context)
 {
     dronecode_sdk::backend::DronecodeSDKBackend backend;
+    backend.startGRPCServer();
     backend.connect(mavlink_listen_port);
-    backend.startGRPCServer();

     if (onServerStarted != nullptr) {
         onServerStarted(context);


Fix: remove space in node names

Fix: remove space in node names

Former-commit-id: d63b20faa0509b9ac9bfec91849f33c551161be1

--- applications/plugins/ColladaSceneLoader/SceneColladaLoader.cpp
+++ applications/plugins/ColladaSceneLoader/SceneColladaLoader.cpp
@@ -255,7 +255,7 @@
                 for(unsigned int j = 0; j < currentAiNode->mNumMeshes; ++j, ++meshId)
                 {
                     std::stringstream meshNameStream;
-                    meshNameStream << "mesh " << (int)meshId;
+                    meshNameStream << "mesh_" << (int)meshId;

                     Node::SPtr meshNode = getSimulation()->createNewNode(meshNameStream.str());
                     currentNode->addChild(meshNode);
@@ -409,9 +409,9 @@

 					std::stringstream rigidNameStream;
 					if(currentAiMesh->HasBones())
-						rigidNameStream << "skinning " << (int)meshId;
+						rigidNameStream << "skinning_" << (int)meshId;
 					else
-						rigidNameStream << "rigid " << (int)meshId;
+						rigidNameStream << "rigid_" << (int)meshId;

 					Node::SPtr rigidNode = getSimulation()->createNewNode(rigidNameStream.str());
 					currentSubNode->addChild(rigidNode);


INTEGRATION: CWS aw024 (1.15.2); FILE MERGED 2006/03/21 13:23:28 fs 1.15.2.1: #i62854# cache the editor's control container

--- basctl/source/inc/dlged.hxx
+++ basctl/source/inc/dlged.hxx
@@ -4,9 +4,9 @@
  *
  *  $RCSfile: dlged.hxx,v $
  *
- *  $Revision: 1.15 $
- *
- *  last change: $Author: rt $ $Date: 2005-09-07 20:18:38 $
+ *  $Revision: 1.16 $
+ *
+ *  last change: $Author: ihi $ $Date: 2006-11-14 15:29:26 $
  *
  *  The Contents of this file are made available subject to
  *  the terms of GNU Lesser General Public License Version 2.1.
@@ -39,6 +39,9 @@
 #ifndef _COM_SUN_STAR_CONTAINER_XNAMECONTAINER_HPP_
 #include <com/sun/star/container/XNameContainer.hpp>
 #endif
+#ifndef _COM_SUN_STAR_AWT_XCONTROLCONTAINER_HPP_
+#include <com/sun/star/awt/XControlContainer.hpp>
+#endif
 #ifndef _COM_SUN_STAR_DATATRANSFER_DATAFLAVOR_HPP_
 #include <com/sun/star/datatransfer/DataFlavor.hpp>
 #endif
@@ -61,7 +64,6 @@
 #ifndef _SFXBRDCST_HXX
 #include <svtools/brdcst.hxx>
 #endif
-

 #define DLGED_PAGE_WIDTH_MIN    1280
 #define DLGED_PAGE_HEIGHT_MIN   1024
@@ -132,6 +134,7 @@
     DlgEdView*          pDlgEdView;
     DlgEdForm*          pDlgEdForm;
     ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >     m_xUnoControlDialogModel;
+    ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlContainer >        m_xControlContainer;
     ::com::sun::star::uno::Sequence< ::com::sun::star::datatransfer::DataFlavor >       m_ClipboardDataFlavors;
     ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier >  m_xSupplier;
     DlgEdFactory*       pObjFac;
@@ -156,6 +159,13 @@
     void            SetWindow( Window* pWindow );
     Window*         GetWindow() const { return pWindow; }

+    /** returns the control container associated with our window
+        @see GetWindow
+        @see SetWindow
+    */
+    ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlContainer >
+                    GetWindowControlContainer();
+
     void            SetDlgEdForm( DlgEdForm* pForm ) { pDlgEdForm = pForm; }
     DlgEdForm*      GetDlgEdForm() const { return pDlgEdForm; }


Enable disabled BoundsUpdated test. Set smaller window size
so that they fit actual desktop size.

This test should pass because aura sets the root window's size immediately and doesn't wait for configure notify.
I think the issue is that WM enforces minimum size and the
test now sees this minimum size after sync.

BUG=none
TEST=bots stays green

Review URL: https://chromiumcodereview.appspot.com/10914070

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

--- ash/display/display_controller_unittest.cc
+++ ash/display/display_controller_unittest.cc
@@ -42,8 +42,10 @@
 // TOD(oshima): Windows creates a window with smaller client area.
 // Fix this and enable tests.
 #define MAYBE_SecondaryDisplayLayout DISABLED_SecondaryDisplayLayout
+#define MAYBE_BoundsUpdated DISABLED_BoundsUpdated
 #else
 #define MAYBE_SecondaryDisplayLayout SecondaryDisplayLayout
+#define MAYBE_BoundsUpdated BoundsUpdated
 #endif

 TEST_F(DisplayControllerTest, MAYBE_SecondaryDisplayLayout) {
@@ -77,40 +79,36 @@
   EXPECT_EQ("5,-395 390x390", GetSecondaryDisplay().work_area().ToString());
 }

-// TODO(oshima,erg): I suspect this test is now failing because I've changed
-// the timing of the RootWindow::Show to be synchronous. If true, this test has
-// always been incorrect, but is now visibly broken now that we're processing
-// X11 configuration events while waiting for the MapNotify.
-TEST_F(DisplayControllerTest, DISABLED_BoundsUpdated) {
+TEST_F(DisplayControllerTest, MAYBE_BoundsUpdated) {
   SetSecondaryDisplayLayout(DisplayLayout::BOTTOM);
-  UpdateDisplay("500x500,400x400");
+  UpdateDisplay("200x200,300x300");
   gfx::Display* secondary_display =
       aura::Env::GetInstance()->display_manager()->GetDisplayAt(1);
   gfx::Insets insets(5, 5, 5, 5);
   secondary_display->UpdateWorkAreaFromInsets(insets);

-  EXPECT_EQ("0,0 500x500", GetPrimaryDisplay().bounds().ToString());
-  EXPECT_EQ("0,500 400x400", GetSecondaryDisplay().bounds().ToString());
-  EXPECT_EQ("5,505 390x390", GetSecondaryDisplay().work_area().ToString());
+  EXPECT_EQ("0,0 200x200", GetPrimaryDisplay().bounds().ToString());
+  EXPECT_EQ("0,200 300x300", GetSecondaryDisplay().bounds().ToString());
+  EXPECT_EQ("5,205 290x290", GetSecondaryDisplay().work_area().ToString());

-  UpdateDisplay("600x600,400x400");
-  EXPECT_EQ("0,0 600x600", GetPrimaryDisplay().bounds().ToString());
-  EXPECT_EQ("0,600 400x400", GetSecondaryDisplay().bounds().ToString());
-  EXPECT_EQ("5,605 390x390", GetSecondaryDisplay().work_area().ToString());
+  UpdateDisplay("400x400,200x200");
+  EXPECT_EQ("0,0 400x400", GetPrimaryDisplay().bounds().ToString());
+  EXPECT_EQ("0,400 200x200", GetSecondaryDisplay().bounds().ToString());
+  EXPECT_EQ("5,405 190x190", GetSecondaryDisplay().work_area().ToString());

-  UpdateDisplay("600x600,500x500");
-  EXPECT_EQ("0,0 600x600", GetPrimaryDisplay().bounds().ToString());
-  EXPECT_EQ("0,600 500x500", GetSecondaryDisplay().bounds().ToString());
-  EXPECT_EQ("5,605 490x490", GetSecondaryDisplay().work_area().ToString());
+  UpdateDisplay("400x400,300x300");
+  EXPECT_EQ("0,0 400x400", GetPrimaryDisplay().bounds().ToString());
+  EXPECT_EQ("0,400 300x300", GetSecondaryDisplay().bounds().ToString());
+  EXPECT_EQ("5,405 290x290", GetSecondaryDisplay().work_area().ToString());

-  UpdateDisplay("600x600");
-  EXPECT_EQ("0,0 600x600", GetPrimaryDisplay().bounds().ToString());
+  UpdateDisplay("400x400");
+  EXPECT_EQ("0,0 400x400", GetPrimaryDisplay().bounds().ToString());
   EXPECT_EQ(1, gfx::Screen::GetNumDisplays());

-  UpdateDisplay("700x700,1000x1000");
+  UpdateDisplay("500x500,700x700");
   ASSERT_EQ(2, gfx::Screen::GetNumDisplays());
-  EXPECT_EQ("0,0 700x700", GetPrimaryDisplay().bounds().ToString());
-  EXPECT_EQ("0,700 1000x1000", GetSecondaryDisplay().bounds().ToString());
+  EXPECT_EQ("0,0 500x500", GetPrimaryDisplay().bounds().ToString());
+  EXPECT_EQ("0,500 700x700", GetSecondaryDisplay().bounds().ToString());
 }

 }  // namespace test


Use Long64_t instead of long long for portability reasons.
On Windows Long64_t is a typedef to __int64

git-svn-id: ecbadac9c76e8cf640a0bca86f6bd796c98521e3@6637 27541ba8-7e3a-0410-8455-c3a389f83636

--- base/src/TPluginManager.cxx
+++ base/src/TPluginManager.cxx
@@ -1,4 +1,4 @@
-// @(#)root/base:$Name:  $:$Id: TPluginManager.cxx,v 1.17 2003/05/15 18:02:35 rdm Exp $
+// @(#)root/base:$Name:  $:$Id: TPluginManager.cxx,v 1.18 2003/05/15 19:41:38 brun Exp $
 // Author: Fons Rademakers   26/1/2002

 /*************************************************************************
@@ -274,7 +274,7 @@
          else if (type == "long" || type == "unsigned long")
             args[i] = (Long_t) va_arg(ap, long);
          else if (type == "long long" || type == "unsigned long long")
-            args[i] = (Long_t) va_arg(ap, long long);
+            args[i] = (Long_t) va_arg(ap, Long64_t);
          else if (type == "float") {
             u.f = (Float_t) va_arg(ap, double);  // float is promoted to double
             args[i] = (Long_t) u.l;


Clear DEVACTB register on PIIX4 ACPI reset

--- iodev/acpi.cc
+++ iodev/acpi.cc
@@ -1,5 +1,5 @@
 /////////////////////////////////////////////////////////////////////////
-// $Id: acpi.cc,v 1.14 2008/03/26 16:25:05 sshwarts Exp $
+// $Id: acpi.cc,v 1.15 2008/11/29 19:39:12 sshwarts Exp $
 /////////////////////////////////////////////////////////////////////////
 //
 //  Copyright (C) 2006  Volker Ruppert
@@ -152,33 +152,40 @@

 void bx_acpi_ctrl_c::reset(unsigned type)
 {
-  unsigned i;
-
-  static const struct reset_vals_t {
-    unsigned      addr;
-    unsigned char val;
-  } reset_vals[] = {
-      { 0x04, 0x00 }, { 0x05, 0x00 },  // command_io + command_mem
-      { 0x06, 0x80 }, { 0x07, 0x02 },  // status_devsel_medium
-      { 0x3c, 0x00 },                  // IRQ
-      // PM base 0x40 - 0x43
-      { 0x40, 0x01 }, { 0x41, 0x00 },
-      { 0x42, 0x00 }, { 0x43, 0x00 },
-      // device resources
-      { 0x5f, 0x90 }, { 0x63, 0x60 },
-      { 0x67, 0x98 },
-      // SM base 0x90 - 0x93
-      { 0x90, 0x01 }, { 0x91, 0x00 },
-      { 0x92, 0x00 }, { 0x93, 0x00 }
-  };
-  for (i = 0; i < sizeof(reset_vals) / sizeof(*reset_vals); ++i) {
-    BX_ACPI_THIS s.pci_conf[reset_vals[i].addr] = reset_vals[i].val;
-  }
+  BX_ACPI_THIS s.pci_conf[0x04] = 0x00; // command_io + command_mem
+  BX_ACPI_THIS s.pci_conf[0x05] = 0x00;
+  BX_ACPI_THIS s.pci_conf[0x06] = 0x80; // status_devsel_medium
+  BX_ACPI_THIS s.pci_conf[0x07] = 0x02;
+  BX_ACPI_THIS s.pci_conf[0x3c] = 0x00; // IRQ
+
+  // PM base 0x40 - 0x43
+  BX_ACPI_THIS s.pci_conf[0x40] = 0x01;
+  BX_ACPI_THIS s.pci_conf[0x41] = 0x00;
+  BX_ACPI_THIS s.pci_conf[0x42] = 0x00;
+  BX_ACPI_THIS s.pci_conf[0x43] = 0x00;
+
+  // clear DEVACTB register on PIIX4 ACPI reset
+  BX_ACPI_THIS s.pci_conf[0x58] = 0x00;
+  BX_ACPI_THIS s.pci_conf[0x59] = 0x00;
+
+  // device resources
+  BX_ACPI_THIS s.pci_conf[0x5a] = 0x00;
+  BX_ACPI_THIS s.pci_conf[0x5b] = 0x00;
+  BX_ACPI_THIS s.pci_conf[0x5f] = 0x90;
+  BX_ACPI_THIS s.pci_conf[0x63] = 0x60;
+  BX_ACPI_THIS s.pci_conf[0x67] = 0x98;
+
+  // SM base 0x90 - 0x93
+  BX_ACPI_THIS s.pci_conf[0x90] = 0x01;
+  BX_ACPI_THIS s.pci_conf[0x91] = 0x00;
+  BX_ACPI_THIS s.pci_conf[0x92] = 0x00;
+  BX_ACPI_THIS s.pci_conf[0x93] = 0x00;

   BX_ACPI_THIS s.pmsts = 0;
   BX_ACPI_THIS s.pmen = 0;
   BX_ACPI_THIS s.pmcntrl = 0;
   BX_ACPI_THIS s.tmr_overflow_time = 0xffffff;
+
   BX_ACPI_THIS s.smbus.stat = 0;
   BX_ACPI_THIS s.smbus.ctl = 0;
   BX_ACPI_THIS s.smbus.cmd = 0;
@@ -186,7 +193,8 @@
   BX_ACPI_THIS s.smbus.data0 = 0;
   BX_ACPI_THIS s.smbus.data1 = 0;
   BX_ACPI_THIS s.smbus.index = 0;
-  for (i = 0; i < 32; i++) {
+
+  for (unsigned i = 0; i < 32; i++) {
     BX_ACPI_THIS s.smbus.data[i] = 0;
   }
 }


- implement option to set clock from utc time, on supported platforms

--- iodev/cmos.cc
+++ iodev/cmos.cc
@@ -1,5 +1,5 @@
 /////////////////////////////////////////////////////////////////////////
-// $Id: cmos.cc,v 1.40 2003/08/19 00:10:38 cbothamy Exp $
+// $Id: cmos.cc,v 1.41 2003/09/05 23:17:51 cbothamy Exp $
 /////////////////////////////////////////////////////////////////////////
 //
 //  Copyright (C) 2002  MandrakeSoft S.A.
@@ -118,7 +118,7 @@
   void
 bx_cmos_c::init(void)
 {
-  BX_DEBUG(("Init $Id: cmos.cc,v 1.40 2003/08/19 00:10:38 cbothamy Exp $"));
+  BX_DEBUG(("Init $Id: cmos.cc,v 1.41 2003/09/05 23:17:51 cbothamy Exp $"));
   // CMOS RAM & RTC

   DEV_register_ioread_handler(this, read_handler, 0x0070, "CMOS RAM", 1);
@@ -142,25 +142,47 @@
         244, 0, 0, "cmos"); // one-shot, not-active
   }

-#if BX_USE_SPECIFIED_TIME0 == 0
+#if BX_USE_SPECIFIED_TIME0 != 0
   // ??? this will not be correct for using an image file.
   // perhaps take values in CMOS and work backwards to find
   // s.timeval from values read in.
-  BX_CMOS_THIS s.timeval = time(NULL);
-#else
   BX_CMOS_THIS s.timeval = BX_USE_SPECIFIED_TIME0;
-#endif
+
+#else // BX_USE_SPECIFIED_TIME0 != 0

   // localtime
-  if (bx_options.clock.Otime0->get () == BX_CLOCK_TIME0_LOCAL)
-       BX_CMOS_THIS s.timeval = time(NULL);
-  // utc
-  if (bx_options.clock.Otime0->get () == BX_CLOCK_TIME0_UTC) {
-       BX_ERROR(("Using UTC time is not supported yet"));
+  if (bx_options.clock.Otime0->get () == BX_CLOCK_TIME0_LOCAL) {
+       BX_INFO(("Using local time for initial clock"));
        BX_CMOS_THIS s.timeval = time(NULL);
   }
-  else if (bx_options.clock.Otime0->get () != 0)
+  // utc
+  else if (bx_options.clock.Otime0->get () == BX_CLOCK_TIME0_UTC) {
+       bx_bool utc_ok = 0;
+
+       BX_INFO(("Using utc time for initial clock"));
+
+       BX_CMOS_THIS s.timeval = time(NULL);
+
+#if BX_HAVE_LOCALTIME
+       localtime(&BX_CMOS_THIS s.timeval);
+#if BX_HAVE_TIMEZONE
+       utc_ok = 1;
+       BX_CMOS_THIS s.timeval += timezone;
+#endif // BX_HAVE_TIMEZONE
+#if BX_HAVE_DAYLIGHT
+       BX_CMOS_THIS s.timeval -= (daylight*3600);
+#endif // BX_HAVE_DAYLIGHT
+#endif // BX_HAVE_LOCALTIME
+
+       if (!utc_ok) {
+           BX_ERROR(("UTC time is not supported on your platform. Using current localtime"));
+       }
+  }
+  else {
+       BX_INFO(("Using specified time for initial clock"));
        BX_CMOS_THIS s.timeval = bx_options.clock.Otime0->get ();
+  }
+#endif // BX_USE_SPECIFIED_TIME0 != 0

   char *tmptime;
   while( (tmptime =  strdup(ctime(&(BX_CMOS_THIS s.timeval)))) == NULL) {


Mark unused arguments

Mark unused arguments

--- src/MissionManager/CameraSpec.cc
+++ src/MissionManager/CameraSpec.cc
@@ -143,6 +143,7 @@

 void CameraSpec::save(QJsonObject& json) const
 {
+    Q_UNUSED(json);
 #if 0
     QJsonObject saveObject;

@@ -192,6 +193,8 @@

 bool CameraSpec::load(const QJsonObject& complexObject, QString& errorString)
 {
+    Q_UNUSED(complexObject);
+    Q_UNUSED(errorString);
 #if 0
     QJsonObject v2Object = complexObject;


- hardware reset must be called after initializing everything else (bug found   with valgrind)

--- iodev/ne2k.cc
+++ iodev/ne2k.cc
@@ -1,5 +1,5 @@
 /////////////////////////////////////////////////////////////////////////
-// $Id: ne2k.cc,v 1.50 2003/05/20 15:01:34 yakovlev Exp $
+// $Id: ne2k.cc,v 1.51 2003/05/24 10:50:19 vruppert Exp $
 /////////////////////////////////////////////////////////////////////////
 //
 //  Copyright (C) 2002  MandrakeSoft S.A.
@@ -1272,11 +1272,7 @@
 void
 bx_ne2k_c::init(void)
 {
-  BX_DEBUG(("Init $Id: ne2k.cc,v 1.50 2003/05/20 15:01:34 yakovlev Exp $"));
-
-
-  // Bring the register state into power-up state
-  theNE2kDevice->reset(BX_RESET_HARDWARE);
+  BX_DEBUG(("Init $Id: ne2k.cc,v 1.51 2003/05/24 10:50:19 vruppert Exp $"));

   // Read in values from config file
   BX_NE2K_THIS s.base_address = bx_options.ne2k.Oioaddr->get ();
@@ -1345,6 +1341,9 @@
     if (BX_NE2K_THIS ethdev == NULL)
       BX_PANIC(("could not locate null module"));
   }
+
+  // Bring the register state into power-up state
+  theNE2kDevice->reset(BX_RESET_HARDWARE);
 }

 #if BX_DEBUGGER


INTEGRATION: CWS changefileheader (1.7.46); FILE MERGED 2008/04/01 15:02:00 thb 1.7.46.2: #i85898# Stripping all external header guards 2008/03/28 16:07:49 rt 1.7.46.1: #i87441# Change license header to LPGL v3.

--- basic/source/sbx/sbxsng.cxx
+++ basic/source/sbx/sbxsng.cxx
@@ -1,44 +1,36 @@
 /*************************************************************************
  *
- *  OpenOffice.org - a multi-platform office productivity suite
- *
- *  $RCSfile: sbxsng.cxx,v $
- *
- *  $Revision: 1.7 $
- *
- *  last change: $Author: rt $ $Date: 2007-11-13 15:23:57 $
- *
- *  The Contents of this file are made available subject to
- *  the terms of GNU Lesser General Public License Version 2.1.
- *
- *
- *    GNU Lesser General Public License Version 2.1
- *    =============================================
- *    Copyright 2005 by Sun Microsystems, Inc.
- *    901 San Antonio Road, Palo Alto, CA 94303, USA
- *
- *    This library is free software; you can redistribute it and/or
- *    modify it under the terms of the GNU Lesser General Public
- *    License version 2.1, as published by the Free Software Foundation.
- *
- *    This library is distributed in the hope that it will be useful,
- *    but WITHOUT ANY WARRANTY; without even the implied warranty of
- *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- *    Lesser General Public License for more details.
- *
- *    You should have received a copy of the GNU Lesser General Public
- *    License along with this library; if not, write to the Free Software
- *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
- *    MA  02111-1307  USA
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: sbxsng.cxx,v $
+ * $Revision: 1.8 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org.  If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
  *
  ************************************************************************/

 // MARKER(update_precomp.py): autogen include statement, do not remove
 #include "precompiled_basic.hxx"
-
-#ifndef _ERRCODE_HXX //autogen
 #include <tools/errcode.hxx>
-#endif
 #include <basic/sbx.hxx>
 #include "sbxconv.hxx"


Update benchmark for sum selection

Update benchmark for sum selection

--- benchmark/src/benchmark.cpp
+++ benchmark/src/benchmark.cpp
@@ -228,17 +228,17 @@
 CPM_DIRECT_SECTION_TWO_PASS_NS("ssum [std][sum][s]",
     CPM_SECTION_INIT([](std::size_t d1){ return std::make_tuple(svec(d1)); }),
     CPM_SECTION_FUNCTOR("default", [](svec& a){ float_ref += etl::sum(a); }),
-    CPM_SECTION_FUNCTOR("std", [](svec& a){ float_ref += etl::detail::sum_direct(a, etl::sum_impl::STD); })
-    SSE_SECTION_FUNCTOR("sse", [](svec& a){ float_ref += etl::detail::sum_direct(a, etl::sum_impl::SSE); })
-    AVX_SECTION_FUNCTOR("avx", [](svec& a){ float_ref += etl::detail::sum_direct(a, etl::sum_impl::AVX); })
+    CPM_SECTION_FUNCTOR("std", [](svec& a){ SELECTED_SECTION(etl::sum_impl::STD){ float_ref += etl::sum(a); } }),
+    CPM_SECTION_FUNCTOR("sse", [](svec& a){ SELECTED_SECTION(etl::sum_impl::SSE){ float_ref += etl::sum(a); } }),
+    CPM_SECTION_FUNCTOR("avx", [](svec& a){ SELECTED_SECTION(etl::sum_impl::AVX){ float_ref += etl::sum(a); } })
 )

 CPM_DIRECT_SECTION_TWO_PASS_NS("dsum [std][sum][d]",
     CPM_SECTION_INIT([](std::size_t d1){ return std::make_tuple(dvec(d1)); }),
     CPM_SECTION_FUNCTOR("default", [](dvec& a){ double_ref += etl::sum(a); }),
-    CPM_SECTION_FUNCTOR("std", [](dvec& a){ double_ref += etl::detail::sum_direct(a, etl::sum_impl::STD); })
-    SSE_SECTION_FUNCTOR("sse", [](dvec& a){ double_ref += etl::detail::sum_direct(a, etl::sum_impl::SSE); })
-    AVX_SECTION_FUNCTOR("avx", [](dvec& a){ double_ref += etl::detail::sum_direct(a, etl::sum_impl::AVX); })
+    CPM_SECTION_FUNCTOR("std", [](dvec& a){ SELECTED_SECTION(etl::sum_impl::STD){ double_ref += etl::sum(a); } }),
+    CPM_SECTION_FUNCTOR("sse", [](dvec& a){ SELECTED_SECTION(etl::sum_impl::SSE){ double_ref += etl::sum(a); } }),
+    CPM_SECTION_FUNCTOR("avx", [](dvec& a){ SELECTED_SECTION(etl::sum_impl::AVX){ double_ref += etl::sum(a); } })
 )

 // Bench complex sums


Platform: some const fascism.

Platform: some const fascism.

--- src/Platform/NaClApplication.cpp
+++ src/Platform/NaClApplication.cpp
@@ -45,7 +45,7 @@

     viewportSize = configuration->size();

-    std::int32_t attributes[] = {
+    const std::int32_t attributes[] = {
         PP_GRAPHICS3DATTRIB_ALPHA_SIZE, 8,
         PP_GRAPHICS3DATTRIB_DEPTH_SIZE, 24,
         PP_GRAPHICS3DATTRIB_STENCIL_SIZE, 8,


Move the checking of ranks for early exit

--- tensorflow/core/grappler/optimizers/generic_layout_optimizer_transposer.cc
+++ tensorflow/core/grappler/optimizers/generic_layout_optimizer_transposer.cc
@@ -1049,6 +1049,9 @@
   const auto* output_shape_attr = node->GetAttr(kAttrOutputShape);
   const auto& shape = output_shape_attr->list().shape(0);
   const int rank = shape.dim_size();
+  if (rank != 4 && rank != 5) {
+    return Status::OK();
+  }
   std::string src_format = context->src_format;
   std::string dst_format = context->dst_format;
   // Update the format from 4D to 5D layout if necessary.
@@ -1060,7 +1063,7 @@
     context->AssignDeviceAndDataFormats(context->target_device, src_format_3d,
                                         dst_format_3d);
   }
-  if (!ShouldProcess(*context, *node) || (rank != 4 && rank != 5) ||
+  if (!ShouldProcess(*context, *node) ||
       !IsAfterDstToSrcTransform(*context, *node)) {
     if (allow_5d) {
       context->AssignDeviceAndDataFormats(context->target_device, src_format,


update

update

--- jpeg/main.cpp
+++ jpeg/main.cpp
@@ -8,15 +8,12 @@

 typedef unsigned char BYTE;

-void save_buffer_to_file(const char *filename,BYTE* buffer,unsigned long size)
-{
+void save_buffer_to_file(const char *filename, BYTE *buffer, unsigned long size) {
     FILE *outfile;
     if ((outfile = fopen(filename, "wb")) != NULL) {
         fwrite(buffer, size, 1, outfile);
         fclose(outfile);
-    }
-    else
-    {
+    } else {
         fprintf(stderr, "can't open %s\n", filename);
         exit(1);
     }
@@ -54,17 +51,12 @@
 void tj_compress_jpeg_to_mem(
         /*IN*/BYTE *src, int width, int height, int pixelFormat, int subsamp, int quality, int flags,
         /*OUT*/BYTE **dst, unsigned long *dstLen
-)
-{
+) {
     // NOTICE : we must use tjAlloc() and tjFree() to allocate dst buffer.
     // for compress, we let **tjCompress2** allocate dst buffer.
     // for decompress, we allocate dst buffer by ourself.

     tjhandle handle = tjInitCompress();
-    //tjCompress2(handle, src, width, 0/*pitch*/, height, TJPF::TJPF_GRAY,
-    //    &pOutBuffer, &lOutSize, TJSAMP::TJSAMP_GRAY, quality,
-    //    TJFLAG_FASTDCT); //TJFLAG_FASTDCT
-
     tjCompress2(
             handle, src, width, 0/*pitch*/, height, pixelFormat,
             dst, dstLen, subsamp, quality, flags
@@ -73,26 +65,24 @@
     tjDestroy(handle);
 }

-void tj_compress_gray_jpeg_to_mem(
-        /*IN*/BYTE *src, int width, int height, int quality,
-        /*OUT*/BYTE **dst, unsigned long *dstLen
-)
-{
-    int pixelFormat = TJPF::TJPF_GRAY;
-    int subsamp = TJSAMP::TJSAMP_GRAY;
-    int flags = TJFLAG_FASTDCT;
-
-    tj_compress_jpeg_to_mem(
-            src, width, height, pixelFormat, subsamp, quality, flags,
-            dst, dstLen
-    );
-}
+//void tj_compress_gray_jpeg_to_mem(
+//        /*IN*/BYTE *src, int width, int height, int quality,
+//        /*OUT*/BYTE **dst, unsigned long *dstLen
+//) {
+//    int pixelFormat = TJPF::TJPF_GRAY;
+//    int subsamp = TJSAMP::TJSAMP_GRAY;
+//    int flags = TJFLAG_FASTDCT;
+//
+//    tj_compress_jpeg_to_mem(
+//            src, width, height, pixelFormat, subsamp, quality, flags,
+//            dst, dstLen
+//    );
+//}

 void tj_compress_gray_jpeg_to_file(
         /*IN*/BYTE *src, int width, int height, int quality,
-        /*OUT*/const char* dst_filename
-)
-{
+        /*OUT*/const char *dst_filename
+) {
     int pixelFormat = TJPF::TJPF_GRAY;
     int subsamp = TJSAMP::TJSAMP_GRAY;
     int flags = TJFLAG_FASTDCT;
@@ -116,7 +106,7 @@

 /*
-* Compress image buffer to a JPEG image in memory.
+* Decompress image buffer to a JPEG image in memory.
 *
 * @@input
 *
@@ -144,13 +134,13 @@
         )
 */
 void tj_decompress_jpeg_from_mem(
-        /*IN*/BYTE *src, unsigned long srcLen,int tjPixelFormat,int flags,
-        /*OUT*/BYTE **dst, unsigned long *dstLen, int *width, int *height, int *components, int *jpegSubsamp, int *jpegColorspace)
-{
+        /*IN*/BYTE *src, unsigned long srcLen, int tjPixelFormat, int flags,
+        /*OUT*/BYTE **dst, unsigned long *dstLen, int *width, int *height, int *components, int *jpegSubsamp,
+              int *jpegColorspace) {
     tjhandle handle = tjInitDecompress();
     tjDecompressHeader3(handle, src, srcLen, width, height, jpegSubsamp, jpegColorspace);

-    (*components) = tjPixelSize[(TJPF)tjPixelFormat]; // 1 for GRAY,3 for RGB
+    (*components) = tjPixelSize[(TJPF) tjPixelFormat]; // 1 for GRAY,3 for RGB
     (*dstLen) = (*width) * (*height) * (*components);

     BYTE *tmp_dst = new BYTE[*dstLen]; /* Allocate out buffer */
@@ -164,41 +154,41 @@
     (*dst) = tmp_dst; // pass dst out
 }

-void tj_decompress_gray_jpeg_from_mem(
-        /*IN*/BYTE *src, unsigned long srcLen,
+//void tj_decompress_gray_jpeg_from_mem(
+//        /*IN*/BYTE *src, unsigned long srcLen,
+//        /*OUT*/BYTE **dst, unsigned long *dstLen, int *width, int *height, int *components
+//) {
+////    int pixelFormat = TJPF::TJPF_GRAY;
+//    int pixelFormat = TJPF::TJPF_RGB;
+//    int flags = TJFLAG_ACCURATEDCT;
+//    int subsamp, colorspace; // no use for now  (3 TJSAMP::TJSAMP_GRAY, 2 TJCS::TJCS_GRAY)
+//
+//    tj_decompress_jpeg_from_mem(
+//            src, srcLen, pixelFormat, flags,
+//            dst, dstLen, width, height, components, &subsamp, &colorspace
+//    );
+//}
+
+void tj_decompress_gray_jpeg_from_file(
+        /*IN*/const char *src_filename,
         /*OUT*/BYTE **dst, unsigned long *dstLen, int *width, int *height, int *components
-)
-{
-    int pixelFormat = TJPF::TJPF_GRAY;
-    int flags = TJFLAG_ACCURATEDCT;
-    int subsamp,colorspace; // no use for now  (3 TJSAMP::TJSAMP_GRAY, 2 TJCS::TJCS_GRAY)
-
-    tj_decompress_jpeg_from_mem(
-            src, srcLen, pixelFormat, flags,
-            dst, dstLen, width, height, components, &subsamp, &colorspace
-    );
-}
-
-void tj_decompress_gray_jpeg_from_file(
-        /*IN*/const char* src_filename,
-        /*OUT*/BYTE **dst, unsigned long *dstLen, int *width, int *height, int *components
-)
-{
+) {
     // (0) read src memory buffer from file
     std::ifstream ifs(src_filename, std::ios_base::binary | std::ios_base::in);
     ifs.seekg(0, std::ios::end);
     int len = ifs.tellg();
     printf("file len : %d\n", len);

-    if(len < 0) {
-        return ;
+    if (len < 0) {
+        return;
     }

     uint64_t srcLen = len;
     ifs.seekg(0, std::ios::beg);

+    // 读取文件数据
     BYTE *src = new BYTE[srcLen];
-    ifs.read((char*)src, srcLen);
+    ifs.read((char *) src, srcLen);

     // (2) decompress
     int pixelFormat = TJPF::TJPF_GRAY;
@@ -217,34 +207,32 @@
 }

-void test_compress(std::string& filename)
-{
-    int width = 2000;
-    int height = 1000;
-    int channel = 1;
-
-    unsigned long srcLen = width * height * channel;
-    unsigned char * src = new unsigned char[srcLen]; // new buffer
-    memset(src, 0, srcLen);
-    for (int i = 100; i < 300; i++) // row [height]
-    {
-        for (int j = 0; j < width; j++) // column [width]
-        {
-            *(src + width * i + j) = (char)255;
-        }
-    }
-
-    //========================================================================
-    // compress to file
-    int quality = 90;
-    tj_compress_gray_jpeg_to_file(src, width, height, quality, filename.c_str());
-    //========================================================================
-
-    delete[] src;
-}
-
-void test_decompress(std::string& srcFile, std::string& dstFile)
-{
+//void test_compress(std::string &filename) {
+//    int width = 2000;
+//    int height = 1000;
+//    int channel = 1;
+//
+//    unsigned long srcLen = width * height * channel;
+//    unsigned char *src = new unsigned char[srcLen]; // new buffer
+//    memset(src, 0, srcLen);
+//    for (int i = 100; i < 300; i++) // row [height]
+//    {
+//        for (int j = 0; j < width; j++) // column [width]
+//        {
+//            *(src + width * i + j) = (char) 255;
+//        }
+//    }
+//
+//    //========================================================================
+//    // compress to file
+//    int quality = 90;
+//    tj_compress_gray_jpeg_to_file(src, width, height, quality, filename.c_str());
+//    //========================================================================
+//
+//    delete[] src;
+//}
+
+void test_decompress(std::string &srcFile, std::string &dstFile) {
     // (0) create memory src buffer
     const char *src_filename = srcFile.c_str();

@@ -266,8 +254,8 @@
     // (3) use dst buffer
     //========================================================================
     // compress to file
-    int quality = 90;
-    const char* dst_filename = dstFile.c_str();
+    int quality = 100;
+    const char *dst_filename = dstFile.c_str();
     tj_compress_gray_jpeg_to_file(dst, width, height, quality, dst_filename);
     //========================================================================

@@ -276,64 +264,62 @@
 }

-int IMAGE_COUNT = 10000;
-void test_compress_time()
-{
-    int width = 2000;
-    int height = 1000;
-    int channel = 1;
-
-    unsigned long srcLen = width * height * channel;
-    unsigned char * src = new unsigned char[srcLen]; // new buffer
-    memset(src, 0, srcLen);
-    for (int i = 100; i < 300; i++) // row [height]
-    {
-        for (int j = 0; j < width; j++) // column [width]
-        {
-            *(src + width * i + j) = (char)255;
-        }
-    }
-
-    int quality = 90;
-    time_t start = time(NULL);
-
-    for (int i = 0; i < IMAGE_COUNT; i++)
-    {
-        //========================================================================
-        // (1) init dst memory buffer
-        BYTE *dst = NULL; // memory allocated by TurboJPEG tjAlloc()
-        unsigned long dstLen = 0;
-
-        // (2) compress
-        tj_compress_gray_jpeg_to_mem(
-                src, width, height, quality,
-                &dst, &dstLen
-        );
-
-        // (3) free memory allocated by TurboJPEG
-        tjFree(dst);
-        //========================================================================
-    }
-
-    time_t end = time(NULL);
-    std::cout << "======================================" << std::endl;
-    double ms = (double)(end - start) * 1000;
-    std::cout << " use times = " << ms << "ms; avg = " << ms / IMAGE_COUNT << " ms; " << " #" << IMAGE_COUNT << std::endl;
-    // avg = 4.9 ms  #10000 for jpeg
-    // avg = 4.5 ms  #10000 for turbojpeg
-    std::cout << "======================================" << std::endl;
-
-    delete[] src;
-}
-
-
-
-int main(int argc, char* argv[])
-{
+//int IMAGE_COUNT = 10000;
+//
+//void test_compress_time() {
+//    int width = 2000;
+//    int height = 1000;
+//    int channel = 1;
+//
+//    unsigned long srcLen = width * height * channel;
+//    unsigned char *src = new unsigned char[srcLen]; // new buffer
+//    memset(src, 0, srcLen);
+//    for (int i = 100; i < 300; i++) // row [height]
+//    {
+//        for (int j = 0; j < width; j++) // column [width]
+//        {
+//            *(src + width * i + j) = (char) 255;
+//        }
+//    }
+//
+//    int quality = 90;
+//    time_t start = time(NULL);
+//
+//    for (int i = 0; i < IMAGE_COUNT; i++) {
+//        //========================================================================
+//        // (1) init dst memory buffer
+//        BYTE *dst = NULL; // memory allocated by TurboJPEG tjAlloc()
+//        unsigned long dstLen = 0;
+//
+//        // (2) compress
+//        tj_compress_gray_jpeg_to_mem(
+//                src, width, height, quality,
+//                &dst, &dstLen
+//        );
+//
+//        // (3) free memory allocated by TurboJPEG
+//        tjFree(dst);
+//        //========================================================================
+//    }
+//
+//    time_t end = time(NULL);
+//    std::cout << "======================================" << std::endl;
+//    double ms = (double) (end - start) * 1000;
+//    std::cout << " use times = " << ms << "ms; avg = " << ms / IMAGE_COUNT << " ms; " << " #" << IMAGE_COUNT
+//              << std::endl;
+//    // avg = 4.9 ms  #10000 for jpeg
+//    // avg = 4.5 ms  #10000 for turbojpeg
+//    std::cout << "======================================" << std::endl;
+//
+//    delete[] src;
+//}
+
+
+int main(int argc, char *argv[]) {

     std::string file("/Users/frank/workspace/github/c_practice/jpeg/image/test.jpg");
     std::string file2("/Users/frank/workspace/github/c_practice/jpeg/image/new.jpeg");
 //    test_compress(file);
-    test_decompress(file,file2);
+    test_decompress(file, file2);
     return 0;
 }


Fixed ifdefs.

Fixed ifdefs.

--- src/XPath/MutableNodeRefList.cpp
+++ src/XPath/MutableNodeRefList.cpp
@@ -684,9 +684,7 @@
 void
 MutableNodeRefList::clearNulls()
 {
-#if !defined(XALAN_NO_STD_NAMESPACE)
-	using std::remove;
-#endif
+	XALAN_USING_STD(remove);

 	m_nodeList.erase(
 		remove(
@@ -708,9 +706,11 @@
 void
 MutableNodeRefList::reverse()
 {
-	XALAN_USING_STD(reverse)
-
-	reverse(
+#if defined(XALAN_NO_STD_NAMESPACE)
+	::reverse(
+#else
+	std::reverse(
+#endif
 		m_nodeList.begin(),
 		m_nodeList.end());


- A unit leaving combat will no longer keep any negative auras it has.

git-svn-id: 0a6e3066f5d503b24e8e377b6d170815393887e2@4425 8ad44209-8f18-4ceb-bdfa-99d0be514da2

--- src/ascent-world/AIInterface.cpp
+++ src/ascent-world/AIInterface.cpp
@@ -229,6 +229,7 @@
 			{
 				if( pUnit == NULL ) return;

+				pUnit->RemoveNegativeAuras();
 				//cancel spells that we are casting. Should remove bug where creatures cast a spell after they died
 //				CancelSpellCast();
 				// restart emote


- Missing return; causes anti-cheat to be "lolohwell"

git-svn-id: 0a6e3066f5d503b24e8e377b6d170815393887e2@4472 8ad44209-8f18-4ceb-bdfa-99d0be514da2

--- src/ascent-world/ArathiBasin.cpp
+++ src/ascent-world/ArathiBasin.cpp
@@ -750,6 +750,7 @@
 	{
 		SendChatMessage(CHAT_MSG_BG_EVENT_NEUTRAL, pPlayer->GetGUID(), "%s has been removed from the game for cheating.", pPlayer->GetName());
 		pPlayer->SoftDisconnect();
+		return;
 	}
 #endif


Stabilize bgp_xmpp_ip_test unit test

Stabilize bgp_xmpp_ip_test unit test

Mock agent routes lookup was done in the main thread. This caused invalid
memory access if the route was updated/deleted from another thread at the same
time. Instead use task_util::TaskFire() to lookup the routes in the exclusive
bgp::Config scheduler task

Change-Id: I54d4ce488ff8429a0762efc6cceb04dcb0bb91f2
Closes-Bug: 1759746

--- src/bgp/test/bgp_xmpp_ip_test.cc
+++ src/bgp/test/bgp_xmpp_ip_test.cc
@@ -232,7 +232,7 @@
     }

     const autogen::ItemType *FindRoute(test::NetworkAgentMockPtr agent,
-        const string &prefix) {
+        const string &prefix) const {
         if (family_ == Address::INET) {
             return agent->RouteLookup(master_, prefix);
         } else {
@@ -240,9 +240,10 @@
         }
     }

-    bool CheckRoute(test::NetworkAgentMockPtr agent, string prefix,
+    bool CheckRouteActual(test::NetworkAgentMockPtr agent, string prefix,
         string nexthop, int local_pref, int med,
-        const vector<string> communities) {
+        const vector<string> communities, bool *result) const {
+        *result = false;
         const autogen::ItemType *rt = FindRoute(agent, prefix);
         if (!rt)
             return false;
@@ -260,22 +261,34 @@
         if (!communities.empty() &&
             rt->entry.community_tag_list.community_tag != communities)
             return false;
+        *result = true;
         return true;
     }

+    bool CheckRoute(test::NetworkAgentMockPtr agent, string prefix,
+                    string nexthop, int local_pref, int med,
+                    const vector<string> communities) const {
+        bool result;
+        task_util::TaskFire(boost::bind(&BgpXmppIpTest::CheckRouteActual, this,
+            agent, prefix, nexthop, local_pref, med, communities, &result),
+                "bgp::Config");
+        return result;
+    }
+
     void VerifyRouteExists(test::NetworkAgentMockPtr agent, string prefix,
-        string nexthop, int local_pref = 0, int med = 0) {
+        string nexthop, int local_pref = 0, int med = 0) const {
         TASK_UTIL_EXPECT_TRUE(CheckRoute(
             agent, prefix, nexthop, local_pref, med, vector<string>()));
     }

     void VerifyRouteExists(test::NetworkAgentMockPtr agent, string prefix,
-        string nexthop, const vector<string> &communities) {
+        string nexthop, const vector<string> &communities) const {
         TASK_UTIL_EXPECT_TRUE(
             CheckRoute(agent, prefix, nexthop, 0, 0, communities));
     }

-    void VerifyRouteNoExists(test::NetworkAgentMockPtr agent, string prefix) {
+    void VerifyRouteNoExists(test::NetworkAgentMockPtr agent,
+                             string prefix) const {
         TASK_UTIL_EXPECT_TRUE(FindRoute(agent, prefix) == NULL);
     }


Minor fix

Minor fix

--- src/binder/bind_node_visitor.cpp
+++ src/binder/bind_node_visitor.cpp
@@ -91,7 +91,6 @@
   // TODO: Update columns are not bound because they are char*
   // not TupleValueExpression in update_statement.h

-  update_col_name_ = nullptr;
   context_ = nullptr;
 }


Check sum tool: fix help message.

Check sum tool: fix help message.

--- src/cc/devtools/checksum_main.cc
+++ src/cc/devtools/checksum_main.cc
@@ -36,7 +36,7 @@
         printf("Usage: %s [flags]\n"
                "       flags can be any combination of 'c', 'n', 'd'.\n"
                "       c: test adler32 combine.\n"
-               "       n: pad with 0.\n"
+               "       n: don't pad with 0.\n"
                "       d: debug.\n"
                "       The test reads input from STDIN ended by Ctrl+D.\n",
                argv[0]);


-- NULL-terminate a character array that is used to read a response  from the metaserver.

--- src/cc/libkfsClient/KfsClient.cc
+++ src/cc/libkfsClient/KfsClient.cc
@@ -1726,7 +1726,8 @@
     // whatever else is left

     if (op->contentBufLen == 0) {
-	op->contentBuf = new char[op->contentLength];
+	op->contentBuf = new char[op->contentLength + 1];
+	op->contentBuf[op->contentLength] = '\0';
     }

     // len bytes belongs to the RPC reply.  Whatever is left after


make client side interface obsolete

make client side interface obsolete

--- src/compiler/csharp_generator.cc
+++ src/compiler/csharp_generator.cc
@@ -250,6 +250,8 @@

 void GenerateClientInterface(Printer* out, const ServiceDescriptor *service) {
   out->Print("// client interface\n");
+  out->Print("[System.Obsolete(\"Client side interfaced will be removed "
+             "in the next release. Use client class directly.\")]\n");
   out->Print("public interface $name$\n", "name",
              GetClientInterfaceName(service));
   out->Print("{\n");
@@ -349,8 +351,9 @@
 void GenerateClientStub(Printer* out, const ServiceDescriptor *service) {
   out->Print("// client stub\n");
   out->Print(
-      "public class $name$ : ClientBase<$name$>\n",
-      "name", GetClientClassName(service));
+      "public class $name$ : ClientBase<$name$>, $interface$\n",
+      "name", GetClientClassName(service),
+      "interface", GetClientInterfaceName(service));
   out->Print("{\n");
   out->Indent();

@@ -536,7 +539,6 @@
   }
   GenerateServiceDescriptorProperty(out, service);
   GenerateClientInterface(out, service);
-  //GenerateClientBaseClass(out, service);
   GenerateServerInterface(out, service);
   GenerateServerClass(out, service);
   GenerateClientStub(out, service);


glsl/standalone: Optimize dead variable declarations

We didn't bother with this in the regular compiler because it doesn't
change the generated code.  In the stand-alone compiler, this can
clutter the output with useless variables.  It's especially bad after
functions are inlined but the foo_retval declarations remain.

v2: Use set_foreach.  Suggested by Tapani.

Signed-off-by: Ian Romanick <2b237cafb16dc45038e85df6c85e74e6d899eba9@intel.com>
Reviewed-by: Tapani Pälli <cdcb67a5e49297de94340ca09f25994bd5e7f762@intel.com>
Reviewed-by: Iago Toral Quiroga <a847aabaac44184372f6b1cd1a59aa254daaeb0b@igalia.com>

--- src/compiler/glsl/standalone.cpp
+++ src/compiler/glsl/standalone.cpp
@@ -37,7 +37,64 @@
 #include "standalone_scaffolding.h"
 #include "standalone.h"
 #include "util/string_to_uint_map.h"
+#include "util/set.h"
 #include "opt_add_neg_to_sub.h"
+
+class dead_variable_visitor : public ir_hierarchical_visitor {
+public:
+   dead_variable_visitor()
+   {
+      variables = _mesa_set_create(NULL,
+                                   _mesa_hash_pointer,
+                                   _mesa_key_pointer_equal);
+   }
+
+   virtual ~dead_variable_visitor()
+   {
+      _mesa_set_destroy(variables, NULL);
+   }
+
+   virtual ir_visitor_status visit(ir_variable *ir)
+   {
+      /* If the variable is auto or temp, add it to the set of variables that
+       * are candidates for removal.
+       */
+      if (ir->data.mode != ir_var_auto && ir->data.mode != ir_var_temporary)
+         return visit_continue;
+
+      _mesa_set_add(variables, ir);
+
+      return visit_continue;
+   }
+
+   virtual ir_visitor_status visit(ir_dereference_variable *ir)
+   {
+      struct set_entry *entry = _mesa_set_search(variables, ir->var);
+
+      /* If a variable is dereferenced at all, remove it from the set of
+       * variables that are candidates for removal.
+       */
+      if (entry != NULL)
+         _mesa_set_remove(variables, entry);
+
+      return visit_continue;
+   }
+
+   void remove_dead_variables()
+   {
+      struct set_entry *entry;
+
+      set_foreach(variables, entry) {
+         ir_variable *ir = (ir_variable *) entry->key;
+
+         assert(ir->ir_type == ir_type_variable);
+         ir->remove();
+      }
+   }
+
+private:
+   set *variables;
+};

 static const struct standalone_options *options;

@@ -445,6 +502,10 @@
          add_neg_to_sub_visitor v;
          visit_list_elements(&v, shader->ir);

+         dead_variable_visitor dv;
+         visit_list_elements(&dv, shader->ir);
+         dv.remove_dead_variables();
+
          shader->Program = rzalloc(shader, gl_program);
          init_gl_program(shader->Program, shader->Stage);
       }


CID 121: unCHECKED_RETURN for Stream::code

--- src/condor_startd.V6/command.cpp
+++ src/condor_startd.V6/command.cpp
@@ -232,14 +232,18 @@
 int
 command_give_state( Service*, int, Stream* stream )
 {
+	int rval = TRUE;
 	char* tmp;
 	dprintf( D_FULLDEBUG, "command_give_state() called.\n" );
 	stream->encode();
 	tmp = strdup( state_to_string(resmgr->state()) );
-	stream->code( tmp );
-	stream->end_of_message();
+	if ( ! stream->code( tmp ) ||
+		 ! stream->end_of_message() ) {
+		dprintf( D_FULLDEBUG, "command_give_state(): failed to send state\n" );
+		rval = FALSE;
+	}
 	free( tmp );
-	return TRUE;
+	return rval;
 }

 int


remove backdoor hack to test claim swapping without a schedd #4280 ===VersionHistory:None===

--- src/condor_startd.V6/command.cpp
+++ src/condor_startd.V6/command.cpp
@@ -691,7 +691,7 @@
 	return rval;
 }

-#if 1
+#if 0 // temporary code for testing swap_claim_and_activation
 void hack_test_claim_swap(StringList & args)
 {
 	args.rewind();
@@ -704,7 +704,6 @@
 	dprintf(D_ALWAYS, "Got command to swap claims for '%s' and '%s'\n", ida ? ida : "NULL", idb ? idb : "NULL");
 	if (ida && idb) {
 		Resource* ripa = resmgr->get_by_name(ida);
-#if 1
 		if ( ! ripa) {
 			dprintf(D_ALWAYS, "Could not find Resource for '%s'\n", ida);
 		} else {
@@ -722,17 +721,6 @@
 			int iret = swap_claim_and_activation(ripa, opts, NULL);
 			dprintf(D_ALWAYS, "swap_claim_and_activation returned %d\n", iret);
 		}
-#else
-		Resource* ripb = resmgr->get_by_name(idb);
-		if (ripa && ripb) {
-			dprintf(D_ALWAYS, "Swapping claims\n");
-			Resource::swap_claims(ripa, ripb);
-			dprintf(D_ALWAYS, "Claims swapped\n");
-		} else {
-			if ( ! ripa) dprintf(D_ALWAYS, "Could not find resource for %s\n", ida);
-			if ( ! ripb) dprintf(D_ALWAYS, "Could not find resource for %s\n", idb);
-		}
-#endif
 	}
 }
 #endif
@@ -763,7 +751,7 @@
    int      dc_publish_flags = daemonCore->dc_stats.PublishFlags;
    queryAd.LookupString("STATISTICS_TO_PUBLISH",stats_config);
    if ( ! stats_config.IsEmpty()) {
-#if 1 // HACK to test config swap
+#if 0 // HACK to test swapping claims without a schedd
        dprintf(D_ALWAYS, "Got QUERY_STARTD_ADS with stats config: %s\n", stats_config.c_str());
        if (starts_with_ignore_case(stats_config.c_str(), "swap:")) {
 		   StringList swap_args(stats_config.c_str()+5);


Core: Portinspector, include fix

Core: Portinspector, include fix

--- src/core/ports/portinspector.cpp
+++ src/core/ports/portinspector.cpp
@@ -32,6 +32,10 @@
 #include <inviwo/core/io/serialization/serialization.h>
 #include <inviwo/core/util/stringconversion.h>
 #include <inviwo/core/metadata/processormetadata.h>
+#include <inviwo/core/processors/processorfactory.h>
+#include <inviwo/core/metadata/metadatafactory.h>
+#include <inviwo/core/properties/propertyfactory.h>
+#include <inviwo/core/ports/portfactory.h>

 namespace inviwo {
 PortInspector::PortInspector(std::string portClassIdentifier,


Correct position of cone

Correct position of cone


send the correct bool types

send the correct bool types

git-svn-id: 70c090ec7b6ed40508c529e3b5f81186e5e21ff0@11 76f3bc84-83be-48bd-939e-545709b08832

--- maiaObject.cpp
+++ maiaObject.cpp
@@ -72,7 +72,7 @@

 	} case QVariant::Bool: {

-		QString textValue = arg.toBool() ? "true" : "false";
+		QString textValue = arg.toBool() ? "1" : "0";

 		QDomElement tag = doc.createElement("boolean");
 		QDomText text = doc.createTextNode(textValue);


Fix sqlite3_key call

Fix sqlite3_key call

--- src/detail/connection_handle.cpp
+++ src/detail/connection_handle.cpp
@@ -48,7 +48,7 @@
 #ifdef SQLITE_HAS_CODEC
         if (conf.password.size()>0)
         {
-          int ret = sqlite3_key(sqlite, conf.password.data(),conf.password.size()+1);
+          int ret = sqlite3_key(sqlite, conf.password.data(),conf.password.size());
           if (ret!=SQLITE_OK)
           {
             const std::string msg = sqlite3_errmsg(sqlite);


Delete mainNumber.cpp

Delete mainNumber.cpp

--- mainNumber.cpp
+++ mainNumber.cpp
@@ -1,64 +0,0 @@
-#include "atom.h"
-#include "variable.h"
-#include "number.h"
-
-#include <string>
-
-#include <iostream>
-using namespace std;
-
-bool Number::match(Atom *A){
-    return false;
-}
-
-
-bool Number::match(Variable *V){
-    if(!assignFlag && V->get_assign()){
-        assignFlag = true;
-        V->setNptr(this);
-        V->set_assign_false();
-        return true;
-    }
-    else{
-        ptr1 = this;
-        ptr2 = V->getNptr();
-        if(ptr1 == ptr2) return true;
-        else return false;
-    }
-
-}
-
-bool Number::match(Number *N){
-    if(vFlag){
-        if(this->value().compare(N->value()) == 0) return true;
-        else return false;
-    }
-    else return false;
-}
-
-
-
-
-bool Number::match(Atom A){
-    return false;
-}
-
-bool Number::match(Variable &V){
-    if(!this->assignFlag && V.get_assign()){
-        //this->assignFlag = true;
-        V.setX(this->symbol());
-        V.set_assign_false();
-        return true;
-    }
-    else{
-        s1 = this->symbol();
-        s2 = V.getX();
-        if(s1.compare(s2)==0) return true;
-        else return false;
-    }
-}
-
-bool Number::match(Number N){
-    this->match(&N);
-}
-


Fix history records when VMs are imported in POWEROFF state

--- src/dm/DispatchManagerActions.cc
+++ src/dm/DispatchManagerActions.cc
@@ -101,6 +101,10 @@
     {
         vm->set_state(VirtualMachine::POWEROFF);
         vm->set_state(VirtualMachine::LCM_INIT);
+
+        //Close this History Record
+        vm->set_etime(the_time);
+        vm->set_running_etime(the_time);
     }
     else
     {


RC input: Always report DSM state

RC input: Always report DSM state

--- src/drivers/rc_input/RCInput.cpp
+++ src/drivers/rc_input/RCInput.cpp
@@ -717,12 +717,13 @@
 		case RC_SCAN_SBUS:
 			PX4_INFO("SBUS frame drops: %u", sbus_dropped_frames());
 			break;
-#if defined(SPEKTRUM_POWER)
+

 		case RC_SCAN_DSM:
 			// DSM status output
-			break;
+#if defined(SPEKTRUM_POWER)
 #endif
+			break;

 		case RC_SCAN_PPM:
 			// PPM status output


interpmodule.cc: fix name clash around 'equal'

obviously an reference to 'equal' has been introduced between boost 1.40 and
boost 1.52.

The compile warnings about  'dereferencing type-punned pointer will break
strict-aliasing rules' can be safely ignored.

--- src/emc/rs274ngc/interpmodule.cc
+++ src/emc/rs274ngc/interpmodule.cc
@@ -250,7 +250,7 @@
 static double get_z(EmcPose &p) { return p.tran.z; }

 // those are exposed here because they look useful for regression testing
-static bool equal(double a, double b) { return fabs(a - b) < TOLERANCE_EQUAL; }
+static bool __equal(double a, double b) { return fabs(a - b) < TOLERANCE_EQUAL; }
 // see interp_convert.cc
 static bool is_near_int(double value) {
     int i = (int)(value + .5);
@@ -383,7 +383,7 @@
     scope().attr("CONSTANT_RPM") =  (int) CONSTANT_RPM;
     scope().attr("CONSTANT_SURFACE") =  (int) CONSTANT_SURFACE;

-    def("equal", &equal);  // EMC's perception of equality of doubles
+    def("equal", &__equal);  // EMC's perception of equality of doubles
     def("is_near_int", &is_near_int);  // EMC's perception of closeness to an int
     def("nearest_int", &nearest_int);


interp/named params: comment brokenness of startup logging

--- src/emc/rs274ngc/rs274ngc_pre.cc
+++ src/emc/rs274ngc/rs274ngc_pre.cc
@@ -112,7 +112,7 @@
     : log_file(0)
 {
     _setup.py_module_stat = PYMOD_NONE;
-    init_named_parameters();  // need this before Python init
+    init_named_parameters();  // need this before Python init. FIXME logging broken - too early in startup
     if (trace) fprintf(stderr,"---> new Interp() pid=%d\"",getpid());
 }

@@ -773,6 +773,7 @@
           } else {
 	      log_file = stderr;
 	  }
+
           _setup.use_lazy_close = 1;

 	  _setup.wizard_root[0] = 0;


fix 64-bit build warning

fix 64-bit build warning

--- kdb+/zlib.cpp
+++ kdb+/zlib.cpp
@@ -74,7 +74,7 @@
 		switch (bytes->t) {
 		case KG:
 		case KC:
-			assert((0 <= bytes->n) && (bytes->n <= std::numeric_limits<size_t>::max()));
+			assert((0 <= bytes->n) && (static_cast<size_t>(bytes->n) <= std::numeric_limits<size_t>::max()));
 			length = static_cast<size_t>(bytes->n);
 			return kG(bytes);
 		default:


Pluralize message: some languages have different plural forms for numbers > 1.

--- mainwindow.cpp
+++ mainwindow.cpp
@@ -67,7 +67,7 @@
         setWindowTitle(i18n("Send files - %1", fileNames.trimmed()));

         ui->messageLabel->setText(i18n("You are about to send these files"));
-        ui->filesInfoLabel->setText(i18n("%1 files selected", QString::number(urls.count())));
+        ui->filesInfoLabel->setText(i18np("1 file selected", "%1 files selected",  QString::number(urls.count())));
         ui->fileNameLabel->setText(fileNames.replace(" ", "<br />"));
     }


Revert removal of folder from recipe name. This breaks ability to open file.

--- mainwindow.cpp
+++ mainwindow.cpp
@@ -72,7 +72,7 @@
     filesTable->setRowCount(0);

     for (auto iter = files.rbegin(); iter != files.rend(); ++iter){
-        QTableWidgetItem *fileNameItem = new QTableWidgetItem(iter->second.split('/')[1]);
+        QTableWidgetItem *fileNameItem = new QTableWidgetItem(iter->second);
         fileNameItem->setFlags(fileNameItem->flags() ^ Qt::ItemIsEditable);
         QTableWidgetItem *rankItem = new QTableWidgetItem(tr("%1").arg(int(round(iter->first)) ));
         rankItem->setTextAlignment(Qt::AlignCenter | Qt::AlignVCenter);


Добавлена проверка на неодинаковость объединений, дополнена проверка обязательных полей

--- mainwindow.cpp
+++ mainwindow.cpp
@@ -132,7 +132,7 @@
         QString docType = ui->docType->currentText();
         QString gender = ui->gender->currentText();

-        if (surname == "" || name == "" || docNum == "" || schoolNum == "" || phone == "" || docType == "" || gender == "" || (ui->ass1->currentIndex() == 0 && ui->ass2->currentIndex() == 0 && ui->ass3->currentIndex() == 0))
+        if (surname == "" || name == "" || docNum == "" || schoolNum == "" || phone == "" || docType == "" || gender == "" || (ui->ass1->currentIndex() == 0 && ui->ass2->currentIndex() == 0 && ui->ass3->currentIndex() == 0) || ui->gender->currentIndex() == 0)
         {
             // Если одно или несколько обязательных полей не заполнены
             // Сообщаем об этом пользователю
@@ -201,7 +201,7 @@
             isPatrName = match.hasMatch();
         }

-        if (!isName || !isSurname || !isPatrName || (ui->parentType1->currentIndex() == 0 && ui->parentType2->currentIndex() == 0))
+        if (!isName || !isSurname || !isPatrName || (ui->parentType1->currentIndex() == 0 && ui->parentType2->currentIndex() == 0) || ((ui->ass1->currentIndex() == ui->ass2->currentIndex()  || ui->ass1->currentIndex() == ui->ass3->currentIndex()) && ui->ass1->currentIndex()!=0) || (ui->ass2->currentIndex() == ui->ass3->currentIndex() && ui->ass2->currentIndex()!=0))
         {
             QMessageBox messageBox(QMessageBox::Warning,
                                    tr("Сохранение"),


remove unnecessary emit

remove unnecessary emit

--- mainwindow.cpp
+++ mainwindow.cpp
@@ -220,22 +220,22 @@
             {
                 // hide search widget on Escape key press
                 if (keyEvent->key() == Qt::Key_Escape)
-                    emit ui->searchButton->toggle();
+                    ui->searchButton->toggle();
             }
             else
             {
                 // show search widget on Ctrl-F
                 if (keyEvent->key() == Qt::Key_F && keyEvent->modifiers() == Qt::ControlModifier)
-                    emit ui->searchButton->toggle();
+                    ui->searchButton->toggle();
             }
             if (target == search_input)
             {
                 if (keyEvent->key() == Qt::Key_Return)
                 {
                     if (keyEvent->modifiers() == Qt::ShiftModifier)
-                        emit search_prev_button->click();
+                        search_prev_button->click();
                     else
-                        emit search_next_button->click();
+                        search_next_button->click();
                 }
             }


Fixed Save/Open dialog accept mode

Fixed Save/Open dialog accept mode

--- mainwindow.cpp
+++ mainwindow.cpp
@@ -257,6 +257,8 @@
     if (acceptMode == QFileDialog::AcceptSave) {
         dialog.setDefaultSuffix("png");
     }
+
+    dialog.setAcceptMode(acceptMode);
 }

 void MainWindow::delay(int millisecondsToWait)


hide file tags widget on start up.

hide file tags widget on start up.

--- mainwindow.cpp
+++ mainwindow.cpp
@@ -35,6 +35,7 @@

     // ui: tags
     FileTagsWidget *w = new FileTagsWidget(tp_,this);
+    w->hide();
     ui->centralWidget->layout()->addWidget(w);
     connect(file_exp_widget_, SIGNAL(sigFilePath(QString)),
             w, SLOT(setFileName(QString)));


Fix an assert in attemptQuadOptimization

Change-Id: I076df1ee83e6be6cbb61c01e48d848fa25f179cd
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/428478
Reviewed-by: John Stiles <f4fcf42d3bb5924557f1eeb3be66747535e585da@google.com>
Commit-Queue: Chris Dalton <ef7fc3a08ada7d31f16e9a18b5f3c728256e041e@google.com>

--- src/gpu/GrSurfaceDrawContext.cpp
+++ src/gpu/GrSurfaceDrawContext.cpp
@@ -525,8 +525,12 @@
     SkASSERT(result.fEffect == GrClip::Effect::kClipped && result.fIsRRect);
     SkRect clippedBounds = result.fRRect.getBounds();
     clippedBounds.intersect(rtRect);
+    if (!drawBounds.intersect(clippedBounds)) {
+        // Our fractional bounds aren't actually inside the clip. GrClip::preApply() can sometimes
+        // think in terms of rounded-out bounds. Discard the draw.
+        return QuadOptimization::kDiscarded;
+    }
     // Guard against the clipped draw turning into a hairline draw after intersection
-    SkAssertResult(drawBounds.intersect(clippedBounds));
     if (drawBounds.width() < 1.f || drawBounds.height() < 1.f) {
         return QuadOptimization::kCropped;
     }


correct error message should be returned if connection fails

--- kwmc/kwmc.cpp
+++ kwmc/kwmc.cpp
@@ -50,7 +50,7 @@
     std::memset(&srv_addr.sin_zero, '\0', 8);

     if(connect(KwmcSockFD, (struct sockaddr*) &srv_addr, sizeof(struct sockaddr)) == -1)
-        Fatal("Connection failed! Make sure the YTD server is running...");
+        Fatal("Connection failed! Make sure the Kwm daemon is running...");
 }

 int main(int argc, char **argv)


Make tcamsrc handle resolution ranges correctly

--- src/gstreamer-1.0/gsttcambin.cpp
+++ src/gstreamer-1.0/gsttcambin.cpp
@@ -463,12 +463,6 @@

     guint fourcc = 0;

-    for (unsigned int i = 0; i < gst_caps_get_size(available_caps); ++i)
-    {
-        GstCaps* single_caps = gst_caps_copy_nth(available_caps, i);
-        gst_caps_unref(single_caps);
-    }
-
     GstCaps* input = gst_caps_copy(wanted);

     GST_DEBUG("Comparing '%s' <==  to  ==> '%s'", gst_caps_to_string(wanted), gst_caps_to_string(available_caps));
@@ -486,40 +480,40 @@
         gint height = 0;
         double framerate = 0.0;

+        gst_structure_fixate_field_nearest_int (structure, "width", G_MAXINT);
+        gst_structure_fixate_field_nearest_int (structure, "height", G_MAXINT);
+        gst_structure_fixate_field_nearest_fraction (structure, "framerate", G_MAXINT, 1);
         gst_structure_get_int (structure, "width", &width);
         gst_structure_get_int (structure, "height", &height);
+
         const GValue* fps = gst_structure_get_value (structure, "framerate");
-        int frame_rate_numerator;
-        int frame_rate_denominator;
-        gst_util_double_to_fraction(framerate,
-                                    &frame_rate_numerator,
-                                    &frame_rate_denominator);
-
-
-        GstCaps* caps = gst_caps_new_simple ("video/x-bayer",
-                                             "framerate", GST_TYPE_FRACTION,
-                                             gst_value_get_fraction_numerator (fps),
-                                             gst_value_get_fraction_denominator (fps),
-                                             "width", G_TYPE_INT, width,
-                                             "height", G_TYPE_INT, height,
-                                             NULL);
+
+        GstCaps* caps;
+        if (gst_value_get_fraction_numerator (fps) == G_MAXINT)
+        {
+            caps = gst_caps_new_simple ("video/x-bayer",
+                                        "framerate", GST_TYPE_FRACTION,
+                                        10,
+                                        1,
+                                        "width", G_TYPE_INT, 460,
+                                        "height", G_TYPE_INT, 480,
+                                        NULL);
+        }
+        else
+        {
+            caps = gst_caps_new_simple ("video/x-bayer",
+                                        "framerate", GST_TYPE_FRACTION,
+                                        gst_value_get_fraction_numerator (fps),
+                                        gst_value_get_fraction_denominator (fps),
+                                        "width", G_TYPE_INT, width,
+                                        "height", G_TYPE_INT, height,
+                                        NULL);
+        }
         GST_INFO("Testing caps: '%s'", gst_caps_to_string(caps));

         intersection = gst_caps_intersect(caps, available_caps);

-
-        if (gst_caps_is_empty(intersection))
-        {
-            GST_ERROR("Unable to determine caps for source.");
-
-            return modules;
-        }
-        else
-        {
-            GST_INFO("Using caps for source element: '%s'", gst_caps_to_string(intersection));
-
-            modules.caps = gst_caps_copy(intersection);
-        }
+        modules.bayer = TRUE;

         structure = gst_caps_get_structure(caps, 0);
         if (gst_structure_get_field_type (structure, "format") == G_TYPE_STRING)
@@ -643,7 +637,6 @@
         gst_element_link(previous_element, self->exposure);
         previous_element = self->exposure;
     }
-

     if (tcam_prop_get_tcam_property_type(TCAM_PROP(self->src), "Focus") != nullptr
         && tcam_prop_get_tcam_property_type(TCAM_PROP(self->src), "Auto Focus") == nullptr)


Fix compilation

Fix compilation

--- src/image/ImageManagerActions.cc
+++ src/image/ImageManagerActions.cc
@@ -243,9 +243,7 @@
         case Image::USED:
         case Image::CLONE:

-            int cloning = img->dec_cloning(clone_img_id);
-
-            if ( cloning == 0  && img->get_running() == 0 )
+            if (img->dec_cloning(clone_img_id) == 0  && img->get_running() == 0)
             {
                 img->set_state(Image::READY);
             }


Cosmetic improvement.

Cosmetic improvement.

--- src/ingameelements/character.cpp
+++ src/ingameelements/character.cpp
@@ -324,13 +324,16 @@
 void Character::serialize(Gamestate *state, WriteBuffer *buffer, bool fullupdate)
 {
     MovingEntity::serialize(state, buffer, fullupdate);
+
     buffer->write<float>(hp.normal);
     buffer->write<float>(hp.armor);
     buffer->write<float>(hp.shields);
+
     pressed_keys.serialize(buffer);
     held_keys.serialize(buffer);
     buffer->write<float>(mouse_x);
     buffer->write<float>(mouse_y);
+
     Weapon *w = state->get<Weapon>(weapon);
     w->serialize(state, buffer, fullupdate);
 }
@@ -338,13 +341,16 @@
 void Character::deserialize(Gamestate *state, ReadBuffer *buffer, bool fullupdate)
 {
     MovingEntity::deserialize(state, buffer, fullupdate);
+
     hp.normal = buffer->read<float>();
     hp.armor = buffer->read<float>();
     hp.shields = buffer->read<float>();
+
     pressed_keys.deserialize(buffer);
     held_keys.deserialize(buffer);
     mouse_x = buffer->read<float>();
     mouse_y = buffer->read<float>();
+
     Weapon *w = state->get<Weapon>(weapon);
     w->deserialize(state, buffer, fullupdate);
 }


tried B.cpp to 'B'

tried B.cpp to 'B'


Restore window before forcing size

Restore window before forcing size

--- frontend/services/opengl_glfw/gl/OpenGL_GLFW_Service.cpp
+++ frontend/services/opengl_glfw/gl/OpenGL_GLFW_Service.cpp
@@ -304,6 +304,7 @@
     int fbo_width = 0, fbo_height = 0;
     int window_width = 0, window_height = 0;

+    glfwRestoreWindow(window); // Maximized windows do not allow resize (at least with X11).
     glfwSetWindowSizeLimits(window, width, height, width, height);
     glfwSetWindowSize(window, width, height);
     glfwGetFramebufferSize(window, &fbo_width, &fbo_height);


Protect possibly predefined preprocessor symbol

On my systems (RHEL7 and Android Termux) PAGE_SIZE is defined to 4096 in /usr/include/sys/user.h .  The enum then produces a compile-term error.
Adding this change resolves this error for me.

--- interpreter/cling/lib/Interpreter/ValuePrinter.cpp
+++ interpreter/cling/lib/Interpreter/ValuePrinter.cpp
@@ -297,7 +297,9 @@
     if (IsValid) {
       // If we're gonnd do this, better make sure the end is valid too
       // FIXME: getpagesize() & GetSystemInfo().dwPageSize might be better
+#if !defined(PAGE_SIZE)
       enum { PAGE_SIZE = 1024 };
+#endif
       while (!(IsValid = utils::isAddressValid(End)) && N > 1024) {
         N -= PAGE_SIZE;
         End = Start + N;


Draw cicles centred as intended so that folding margin markers look correct.

--- gtk/PlatGTK.cxx
+++ gtk/PlatGTK.cxx
@@ -822,7 +822,7 @@

 void SurfaceImpl::Ellipse(PRectangle rc, ColourDesired fore, ColourDesired back) {
 	PenColour(back);
-	cairo_arc(context, (rc.left + rc.right) / 2 + 0.5, (rc.top + rc.bottom) / 2 + 0.5,
+	cairo_arc(context, (rc.left + rc.right) / 2, (rc.top + rc.bottom) / 2,
 		Platform::Minimum(rc.Width(), rc.Height()) / 2, 0, 2*kPi);
 	cairo_fill_preserve(context);
 	PenColour(fore);


Patch from Shane Caraveo at ActiveState to make UTF-8 work on GTK+.

--- gtk/PlatGTK.cxx
+++ gtk/PlatGTK.cxx
@@ -7,6 +7,7 @@
 #include <stdio.h>
 #include <stdlib.h>

+#include <gdk/gdk.h>
 #include <gtk/gtk.h>
 #include <gdk/gdkkeysyms.h>

@@ -14,11 +15,14 @@

 #include "Scintilla.h"
 #include "ScintillaWidget.h"
+#include "UniConversion.h"

 /* Use fast way of getting char data on win32 to work around problems
    with gdk_string_extents. */
+#define FAST_WAY
+
 #ifdef G_OS_WIN32
-#define FAST_WAY
+#define snprintf _snprintf
 #endif

 #ifdef _MSC_VER
@@ -29,7 +33,7 @@
 // X has a 16 bit coordinate space, so stop drawing here to avoid wrapping
 static const int maxCoordinate = 32000;

-static GdkFont *PFont(Font &f)  {
+static GdkFont *PFont(Font &f) {
 	return reinterpret_cast<GdkFont *>(f.GetID());
 }

@@ -72,7 +76,7 @@
 	if (want) {
 		for (int i = 0; i < used; i++) {
 			if (entries[i].desired == cp.desired)
-				return ;
+				return;
 		}

 		if (used < numEntries) {
@@ -84,7 +88,7 @@
 		for (int i = 0; i < used; i++) {
 			if (entries[i].desired == cp.desired) {
 				cp.allocated = entries[i].allocated;
-				return ;
+				return;
 			}
 		}
 		cp.allocated.Set(cp.desired.AsLong());
@@ -94,8 +98,8 @@
 void Palette::Allocate(Window &w) {
 	if (allocatedPalette) {
 		gdk_colormap_free_colors(gtk_widget_get_colormap(PWidget(w)),
-		        reinterpret_cast<GdkColor *>(allocatedPalette),
-			allocatedLen);
+		                         reinterpret_cast<GdkColor *>(allocatedPalette),
+		                         allocatedLen);
 		delete [](reinterpret_cast<GdkColor *>(allocatedPalette));
 		allocatedPalette = 0;
 		allocatedLen = 0;
@@ -171,39 +175,194 @@
 	}
 }

-void Font::Create(const char *faceName, int characterSet,
+void GenerateFontSpecStrings(const char *fontName, int characterSet,
+                             char *foundary, int foundary_len,
+                             char *faceName, int faceName_len,
+                             char *charset, int charset_len) {
+	// supported font strings include:
+	// foundary-fontface-isoxxx-x
+	// fontface-isoxxx-x
+	// foundary-fontface
+	// fontface
+	if (strchr(fontName, '-')) {
+		char tmp[300];
+		char *d1 = NULL, *d2 = NULL, *d3 = NULL;
+		strncpy(tmp, fontName, sizeof(tmp) - 1);
+		d1 = strchr(tmp, '-');
+		// we know the first dash exists
+		d2 = strchr(d1 + 1, '-');
+		if (d2)
+			d3 = strchr(d2 + 1, '-');
+		if (d3) {
+			// foundary-fontface-isoxxx-x
+			*d2 = '\0';
+			foundary[0] = '-';
+			foundary[1] = '\0';
+			strncpy(faceName, tmp, foundary_len - 1);
+			strncpy(charset, d2 + 1, charset_len - 1);
+		} else if (d2) {
+			// fontface-isoxxx-x
+			*d1 = '\0';
+			strcpy(foundary, "-*-");
+			strncpy(faceName, tmp, faceName_len - 1);
+			strncpy(charset, d1 + 1, charset_len - 1);
+		} else {
+			// foundary-fontface
+			foundary[0] = '-';
+			foundary[1] = '\0';
+			strncpy(faceName, tmp, faceName_len - 1);
+			strncpy(charset, CharacterSetName(characterSet), charset_len - 1);
+		}
+	} else {
+		strncpy(foundary, "-*-", foundary_len);
+		strncpy(faceName, fontName, faceName_len - 1);
+		strncpy(charset, CharacterSetName(characterSet), charset_len - 1);
+	}
+}
+
+void Font::Create(const char *fontName, int characterSet,
                   int size, bool bold, bool italic) {
 	Release();
+	char fontset[1024];
+	char fontspec[300];
+	char foundary[50];
+	char faceName[100];
+	char charset[50];
+	fontset[0] = '\0';
+	fontspec[0] = '\0';
+	foundary[0] = '\0';
+	faceName[0] = '\0';
+	charset[0] = '\0';
+
 	// If name of the font begins with a '-', assume, that it is
 	// a full fontspec.
-	if (faceName[0] == '-') {
-		id = gdk_font_load(faceName);
+	if (fontName[0] == '-') {
+		if (strchr(fontName, ',')) {
+			id = gdk_fontset_load(fontName);
+		} else {
+			id = gdk_font_load(fontName);
+		}
+		if (!id) {
+			// Font not available so substitute a reasonable code font
+			// iso8859 appears to only allow western characters.
+			id = gdk_font_load("-*-*-*-*-*-*-*-*-*-*-*-*-iso8859-*");
+		}
+		return;
+	}
+
+	// it's not a full fontspec, build one.
+
+	// This supports creating a FONT_SET
+	// in a method that allows us to also set size, slant and
+	// weight for the fontset.  The expected input is multiple
+	// partial fontspecs seperated by comma
+	// eg. adobe-courier-iso10646-1,*-courier-iso10646-1,*-*-*-*
+	if (strchr(fontName, ',')) {
+		// build a fontspec and use gdk_fontset_load
+		int remaining = sizeof(fontset);
+		char fontNameCopy[1024];
+		strncpy(fontNameCopy, fontName, sizeof(fontNameCopy) - 1);
+		char *fn = fontNameCopy;
+		char *fp = strchr(fn, ',');
+		for (;;) {
+			const char *spec = "%s%s%s%s-*-*-*-%0d-*-*-*-*-%s";
+			if (fontset[0] != '\0') {
+				// if this is not the first font in the list,
+				// append a comma seperator
+				spec = ",%s%s%s%s-*-*-*-%0d-*-*-*-*-%s";
+			}
+
+			if (fp)
+				*fp = '\0'; // nullify the comma
+			GenerateFontSpecStrings(fn, characterSet,
+			                        foundary, sizeof(foundary),
+			                        faceName, sizeof(faceName),
+			                        charset, sizeof(charset));
+
+			snprintf(fontspec,
+			         sizeof(fontspec) - 1,
+			         spec,
+			         foundary, faceName,
+			         bold ? "-bold" : "-medium",
+			         italic ? "-i" : "-r",
+			         size * 10,
+			         charset);
+
+			// if this is the first font in the list, and
+			// we are doing italic, add an oblique font
+			// to the list
+			if (italic && fontset[0] == '\0') {
+				strncat(fontset, fontspec, remaining - 1);
+				remaining -= strlen(fontset);
+
+				snprintf(fontspec,
+				         sizeof(fontspec) - 1,
+				         ",%s%s%s-o-*-*-*-%0d-*-*-*-*-%s",
+				         foundary, faceName,
+				         bold ? "-bold" : "-medium",
+				         size * 10,
+				         charset);
+			}
+
+			strncat(fontset, fontspec, remaining - 1);
+			remaining -= strlen(fontset);
+
+			if (!fp)
+				break;
+
+			fn = fp + 1;
+			fp = strchr(fn, ',');
+		}
+
+		id = gdk_fontset_load(fontset);
 		if (id)
-			return ;
-	}
-	char fontspec[300];
-	fontspec[0] = '\0';
-	strcat(fontspec, "-*-");
-	strcat(fontspec, faceName);
-	if (bold)
-		strcat(fontspec, "-bold");
-	else
-		strcat(fontspec, "-medium");
-	if (italic)
-		strcat(fontspec, "-i");
-	else
-		strcat(fontspec, "-r");
-	strcat(fontspec, "-*-*-*");
-	char sizePts[100];
-	sprintf(sizePts, "-%0d", size * 10);
-	strcat(fontspec, sizePts);
-	strcat(fontspec, "-*-*-*-*-");
-	strcat(fontspec, CharacterSetName(characterSet));
+			return;
+
+		// if fontset load failed, fall through, we'll use
+		// the last font entry and continue to try and
+		// get something that matches
+	}
+
+	// single fontspec support
+
+	GenerateFontSpecStrings(fontName, characterSet,
+	                        foundary, sizeof(foundary),
+	                        faceName, sizeof(faceName),
+	                        charset, sizeof(charset));
+
+	snprintf(fontspec,
+	         sizeof(fontspec) - 1,
+	         "%s%s%s%s-*-*-*-%0d-*-*-*-*-%s",
+	         foundary, faceName,
+	         bold ? "-bold" : "-medium",
+	         italic ? "-i" : "-r",
+	         size * 10,
+	         charset);
 	id = gdk_font_load(fontspec);
+	if (!id) {
+		// some fonts have oblique, not italic
+		snprintf(fontspec,
+		         sizeof(fontspec) - 1,
+		         "%s%s%s%s-*-*-*-%0d-*-*-*-*-%s",
+		         foundary, faceName,
+		         bold ? "-bold" : "-medium",
+		         italic ? "-o" : "-r",
+		         size * 10,
+		         charset);
+		id = gdk_font_load(fontspec);
+	}
+	if (!id) {
+		snprintf(fontspec,
+		         sizeof(fontspec) - 1,
+		         "-*-*-*-*-*-*-*-%0d-*-*-*-*-%s",
+		         size * 10,
+		         charset);
+		id = gdk_font_load(fontspec);
+	}
 	if (!id) {
 		// Font not available so substitute a reasonable code font
 		// iso8859 appears to only allow western characters.
-		id = gdk_font_load("*-*-*-*-*-*-*-*-*-*-*-*-iso8859-*");
+		id = gdk_font_load("-*-*-*-*-*-*-*-*-*-*-*-*-iso8859-*");
 	}
 }

@@ -342,15 +501,17 @@
 }

 void SurfaceImpl::LineTo(int x_, int y_) {
-	gdk_draw_line(drawable, gc,
-	              x, y,
-	              x_, y_);
+	if (drawable && gc) {
+		gdk_draw_line(drawable, gc,
+		              x, y,
+		              x_, y_);
+	}
 	x = x_;
 	y = y_;
 }

 void SurfaceImpl::Polygon(Point *pts, int npts, ColourAllocated fore,
-                      ColourAllocated back) {
+                          ColourAllocated back) {
 	GdkPoint gpts[20];
 	if (npts < static_cast<int>((sizeof(gpts) / sizeof(gpts[0])))) {
 		for (int i = 0;i < npts;i++) {
@@ -418,15 +579,15 @@
 	if (((rc.right - rc.left) > 4) && ((rc.bottom - rc.top) > 4)) {
 		// Approximate a round rect with some cut off corners
 		Point pts[] = {
-		    Point(rc.left + 2, rc.top),
-		    Point(rc.right - 2, rc.top),
-		    Point(rc.right, rc.top + 2),
-		    Point(rc.right, rc.bottom - 2),
-		    Point(rc.right - 2, rc.bottom),
-		    Point(rc.left + 2, rc.bottom),
-		    Point(rc.left, rc.bottom - 2),
-		    Point(rc.left, rc.top + 2),
-		};
+		                  Point(rc.left + 2, rc.top),
+		                  Point(rc.right - 2, rc.top),
+		                  Point(rc.right, rc.top + 2),
+		                  Point(rc.right, rc.bottom - 2),
+		                  Point(rc.right - 2, rc.bottom),
+		                  Point(rc.left + 2, rc.bottom),
+		                  Point(rc.left, rc.bottom - 2),
+		                  Point(rc.left, rc.top + 2),
+		              };
 		Polygon(pts, sizeof(pts) / sizeof(pts[0]), fore, back);
 	} else {
 		RectangleDraw(rc, fore, back);
@@ -459,30 +620,52 @@
 	}
 }

+#define MAX_US_LEN 5000
+
 void SurfaceImpl::DrawTextNoClip(PRectangle rc, Font &font_, int ybase, const char *s, int len,
-                       ColourAllocated fore, ColourAllocated back) {
+                                 ColourAllocated fore, ColourAllocated back) {
 	FillRectangle(rc, back);
 	PenColour(fore);
 	if (gc && drawable) {
 		// Draw text as a series of segments to avoid limitations in X servers
-		// TODO: make this DBCS and UTF-8 safe by not splitting multibyte characters
 		const int segmentLength = 1000;
 		int x = rc.left;
-		while ((len > 0) && (x < maxCoordinate)) {
-			int lenDraw = Platform::Minimum(len, segmentLength);
-			gdk_draw_text(drawable, PFont(font_), gc, x, ybase, s, lenDraw);
-			len -= lenDraw;
-			if (len > 0) {
-				x += gdk_text_width(PFont(font_), s, lenDraw);
+		if (unicodeMode) {
+			GdkWChar wctext[MAX_US_LEN];
+			GdkWChar *wcp = (GdkWChar *) & wctext;
+			size_t wclen = UCS2FromUTF8(s, len, (wchar_t *)wctext,
+			                            sizeof(wctext) / sizeof(GdkWChar) - 1);
+			wctext[wclen] = L'\0';
+			int lenDraw;
+			while ((wclen > 0) && (x < maxCoordinate)) {
+				lenDraw = Platform::Minimum(wclen, segmentLength);
+				gdk_draw_text_wc(drawable, PFont(font_), gc,
+				                 x, ybase, wcp, lenDraw);
+				wclen -= lenDraw;
+				if (wclen > 0) {
+					x += gdk_text_width_wc(PFont(font_),
+					                       wcp, lenDraw);
+				}
+				wcp += lenDraw;
 			}
-			s += lenDraw;
+		} else {
+			while ((len > 0) && (x < maxCoordinate)) {
+				int lenDraw = Platform::Minimum(len, segmentLength);
+				gdk_draw_text(drawable, PFont(font_), gc,
+				              x, ybase, s, lenDraw);
+				len -= lenDraw;
+				if (len > 0) {
+					x += gdk_text_width(PFont(font_), s, lenDraw);
+				}
+				s += lenDraw;
+			}
 		}
 	}
 }

 // On GTK+, exactly same as DrawTextNoClip
 void SurfaceImpl::DrawTextClipped(PRectangle rc, Font &font_, int ybase, const char *s, int len,
-                              ColourAllocated fore, ColourAllocated back) {
+                                  ColourAllocated fore, ColourAllocated back) {
 	DrawTextNoClip(rc, font_, ybase, s, len, fore, back);
 }

@@ -490,10 +673,47 @@
 	if (font_.GetID()) {
 		int totalWidth = 0;
 		GdkFont *gf = PFont(font_);
-		for (int i = 0; i < len; i++) {
-			int width = gdk_char_width(gf, s[i]);
-			totalWidth += width;
-			positions[i] = totalWidth;
+		if (unicodeMode) {
+			GdkWChar wctext[MAX_US_LEN];
+			size_t wclen = UCS2FromUTF8(s, len, (wchar_t *)wctext, sizeof(wctext) / sizeof(GdkWChar) - 1);
+			wctext[wclen] = L'\0';
+			int poses[MAX_US_LEN];
+			size_t i;
+			for (i = 0; i < wclen; i++) {
+				int width = gdk_char_width_wc(gf, wctext[i]);
+				totalWidth += width;
+				poses[i] = totalWidth;
+			}
+			// map widths back to utf-8 input string
+			size_t ui = 0;
+			i = 0;
+			const unsigned char *us = reinterpret_cast<const unsigned char *>(s);
+			unsigned char uch;
+			while (ui < wclen) {
+				uch = us[i];
+				positions[i++] = poses[ui];
+				if (uch >= 0x80) {
+					if (uch < (0x80 + 0x40 + 0x20)) {
+						positions[i++] = poses[ui];
+					} else {
+						positions[i++] = poses[ui];
+						positions[i++] = poses[ui];
+					}
+				}
+				ui++;
+			}
+			int lastPos = 0;
+			if (i > 0)
+				lastPos = positions[i - 1];
+			while (i < static_cast<size_t>(len)) {
+				positions[i++] = lastPos;
+			}
+		} else {
+			for (int i = 0; i < len; i++) {
+				int width = gdk_char_width(gf, s[i]);
+				totalWidth += width;
+				positions[i] = totalWidth;
+			}
 		}
 	} else {
 		for (int i = 0; i < len; i++) {
@@ -503,10 +723,18 @@
 }

 int SurfaceImpl::WidthText(Font &font_, const char *s, int len) {
-	if (font_.GetID())
-		return gdk_text_width(PFont(font_), s, len);
-	else
+	if (font_.GetID()) {
+		if (unicodeMode) {
+			GdkWChar wctext[MAX_US_LEN];
+			size_t wclen = UCS2FromUTF8(s, len, (wchar_t *)wctext, sizeof(wctext) / sizeof(GdkWChar) - 1);
+			wctext[wclen] = L'\0';
+			int width = gdk_text_width_wc(PFont(font_), wctext, wclen);
+			return width;
+		} else
+			return gdk_text_width(PFont(font_), s, len);
+	} else {
 		return 1;
+	}
 }

 int SurfaceImpl::WidthChar(Font &font_, char ch) {
@@ -544,7 +772,7 @@
 	gint descent;

 	gdk_string_extents(PFont(font_), sizeString,
-	                   &lbearing, &rbearing, &width, &ascent, &descent);
+					   &lbearing, &rbearing, &width, &ascent, &descent);
 	return ascent;
 #endif
 }
@@ -562,7 +790,7 @@
 	gint descent;

 	gdk_string_extents(PFont(font_), sizeString,
-	                   &lbearing, &rbearing, &width, &ascent, &descent);
+					   &lbearing, &rbearing, &width, &ascent, &descent);
 	return descent;
 #endif
 }
@@ -600,7 +828,7 @@
 void SurfaceImpl::FlushCachedState() {}

 void SurfaceImpl::SetUnicodeMode(bool unicodeMode_) {
-	unicodeMode=unicodeMode_;
+	unicodeMode = unicodeMode_;
 }

 Surface *Surface::Allocate() {
@@ -733,7 +961,7 @@
 }

 ListBox::ListBox() : list(0), current(0), desiredVisibleRows(5), maxItemCharacters(0),
-	doubleClickAction(NULL), doubleClickActionData(NULL) {}
+doubleClickAction(NULL), doubleClickActionData(NULL) {}

 ListBox::~ListBox() {}

@@ -851,7 +1079,6 @@
 			rc.right = rc.right + 16;
 	}
 	return rc;
-
 }

 void ListBox::Clear() {
@@ -981,6 +1208,7 @@
 #ifdef G_OS_WIN32
 	return 10;
 #else
+
 	return 12;
 #endif
 }
@@ -1005,8 +1233,8 @@

 long Platform::SendScintillaPointer(
     WindowID w, unsigned int msg, unsigned long wParam, void *lParam) {
-	return scintilla_send_message(SCINTILLA(w), msg, wParam,
-	    reinterpret_cast<sptr_t>(lParam));
+	return scintilla_send_message(SCINTILLA(w), msg, wParam,
+	                              reinterpret_cast<sptr_t>(lParam));
 }

 bool Platform::IsDBCSLeadByte(int /*codePage*/, char /*ch*/) {


pragma to avoid MSVC warning.

pragma to avoid MSVC warning.

--- gtk/PlatGTK.cxx
+++ gtk/PlatGTK.cxx
@@ -1371,6 +1371,11 @@
 	gtk_clist_sort(GTK_CLIST(list));
 }

+// g_return_if_fail causes unnecessary compiler warning in release compile.
+#ifdef _MSC_VER
+#pragma warning(disable: 4127)
+#endif
+
 void ListBox::SetTypeXpm(int type, const char **xpm_data) {
 	ListImage *list_image;
 	g_return_if_fail(xpm_data);


GTK: Fix auto-completion popup sizing on some themes

--- gtk/PlatGTK.cxx
+++ gtk/PlatGTK.cxx
@@ -1423,6 +1423,7 @@

 class ListBoxX : public ListBox {
 	WindowID widCached;
+	WindowID frame;
 	WindowID list;
 	WindowID scroller;
 	void *pixhash;
@@ -1435,7 +1436,7 @@
 	CallBackAction doubleClickAction;
 	void *doubleClickActionData;

-	ListBoxX() : widCached(0), list(0), scroller(0), pixhash(NULL), pixbuf_renderer(0),
+	ListBoxX() : widCached(0), frame(0), list(0), scroller(0), pixhash(NULL), pixbuf_renderer(0),
 		desiredVisibleRows(5), maxItemCharacters(0),
 		aveCharWidth(1), doubleClickAction(NULL), doubleClickActionData(NULL) {
 	}
@@ -1577,9 +1578,9 @@

 	wid = widCached = gtk_window_new(GTK_WINDOW_POPUP);

-	GtkWidget *frame = gtk_frame_new(NULL);
-	gtk_widget_show(frame);
-	gtk_container_add(GTK_CONTAINER(GetID()), frame);
+	frame = gtk_frame_new(NULL);
+	gtk_widget_show(PWidget(frame));
+	gtk_container_add(GTK_CONTAINER(GetID()), PWidget(frame));
 	gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_OUT);
 	gtk_container_set_border_width(GTK_CONTAINER(frame), 0);

@@ -1682,9 +1683,9 @@
 		// This, apparently unnecessary call, ensures gtk_tree_view_column_cell_get_size
 		// returns reasonable values.
 #if GTK_CHECK_VERSION(3,0,0)
-		gtk_widget_get_preferred_size(GTK_WIDGET(scroller), NULL, &req);
-#else
-		gtk_widget_size_request(GTK_WIDGET(scroller), &req);
+		gtk_widget_get_preferred_size(GTK_WIDGET(frame), NULL, &req);
+#else
+		gtk_widget_size_request(GTK_WIDGET(frame), &req);
 #endif
 		int height;

@@ -1693,16 +1694,15 @@
 		// Get cell height
 		int row_height = GetRowHeight();
 #if GTK_CHECK_VERSION(3,0,0)
-		GtkStyleContext *styleContextList = gtk_widget_get_style_context(PWidget(list));
+		GtkStyleContext *styleContextFrame = gtk_widget_get_style_context(PWidget(frame));
 		GtkBorder padding;
-		gtk_style_context_get_padding(styleContextList, GTK_STATE_FLAG_NORMAL, &padding);
+		gtk_style_context_get_padding(styleContextFrame, GTK_STATE_FLAG_NORMAL, &padding);
 		height = (rows * row_height
 		          + padding.top + padding.bottom
 		          + 2 * (gtk_container_get_border_width(GTK_CONTAINER(PWidget(list))) + 1));
 #else
-		int ythickness = PWidget(list)->style->ythickness;
 		height = (rows * row_height
-		          + 2 * (ythickness
+		          + 2 * (PWidget(frame)->style->ythickness
 		                 + GTK_CONTAINER(PWidget(list))->border_width));
 #endif
 		rc.bottom = height;
@@ -1720,7 +1720,7 @@
 		rc.right += (padding.left + padding.right
 		             + 2 * (gtk_container_get_border_width(GTK_CONTAINER(PWidget(list))) + 1));
 #else
-		rc.right += 2 * (PWidget(list)->style->xthickness
+		rc.right += 2 * (PWidget(frame)->style->xthickness
 		                 + GTK_CONTAINER(PWidget(list))->border_width);
 #endif
 		if (Length() > rows) {


[libOption] - Replace std::pair with helper struct. NFC.

Splitted from D35476.

git-svn-id: 0ff597fd157e6f4fc38580e8d64ab130330d2411@308293 91177308-0d34-0410-b5e6-96231b3b80d8

--- lib/Option/OptTable.cpp
+++ lib/Option/OptTable.cpp
@@ -390,27 +390,29 @@
   return Name;
 }

+namespace {
+struct OptionInfo {
+  std::string Name;
+  StringRef HelpText;
+};
+} // namespace
+
 static void PrintHelpOptionList(raw_ostream &OS, StringRef Title,
-                                std::vector<std::pair<std::string,
-                                const char*>> &OptionHelp) {
+                                std::vector<OptionInfo> &OptionHelp) {
   OS << Title << ":\n";

   // Find the maximum option length.
   unsigned OptionFieldWidth = 0;
   for (unsigned i = 0, e = OptionHelp.size(); i != e; ++i) {
-    // Skip titles.
-    if (!OptionHelp[i].second)
-      continue;
-
     // Limit the amount of padding we are willing to give up for alignment.
-    unsigned Length = OptionHelp[i].first.size();
+    unsigned Length = OptionHelp[i].Name.size();
     if (Length <= 23)
       OptionFieldWidth = std::max(OptionFieldWidth, Length);
   }

   const unsigned InitialPad = 2;
   for (unsigned i = 0, e = OptionHelp.size(); i != e; ++i) {
-    const std::string &Option = OptionHelp[i].first;
+    const std::string &Option = OptionHelp[i].Name;
     int Pad = OptionFieldWidth - int(Option.size());
     OS.indent(InitialPad) << Option;

@@ -419,7 +421,7 @@
       OS << "\n";
       Pad = OptionFieldWidth + InitialPad;
     }
-    OS.indent(Pad + 1) << OptionHelp[i].second << '\n';
+    OS.indent(Pad + 1) << OptionHelp[i].HelpText << '\n';
   }
 }

@@ -458,8 +460,7 @@

   // Render help text into a map of group-name to a list of (option, help)
   // pairs.
-  using helpmap_ty =
-      std::map<std::string, std::vector<std::pair<std::string, const char*>>>;
+  using helpmap_ty = std::map<std::string, std::vector<OptionInfo>>;
   helpmap_ty GroupedOptionHelp;

   for (unsigned i = 0, e = getNumOptions(); i != e; ++i) {
@@ -478,7 +479,7 @@
     if (const char *Text = getOptionHelpText(Id)) {
       const char *HelpGroup = getOptionHelpGroup(*this, Id);
       const std::string &OptName = getOptionHelpName(*this, Id);
-      GroupedOptionHelp[HelpGroup].push_back(std::make_pair(OptName, Text));
+      GroupedOptionHelp[HelpGroup].push_back({OptName, Text});
     }
   }