LGTM: [skip ci] fix: Local variable hides global variable

A local variable or parameter that hides a global variable of the same name.
This may be confusing. Consider renaming one of the variables.
This commit is contained in:
wmayer
2020-07-26 19:30:24 +02:00
parent 7a5be2d42e
commit 99121b75c9
4 changed files with 15 additions and 43 deletions

View File

@@ -57,7 +57,7 @@
using namespace Gui;
/* XPM */
static const char *px[]={
static const char *not_found[]={
"24 24 2 1",
"# c #000000",
". c #ffffff",
@@ -293,7 +293,7 @@ QPixmap BitmapFactoryInst::pixmap(const char* name) const
}
Base::Console().Warning("Cannot find icon: %s\n", name);
return QPixmap(px);
return QPixmap(not_found);
}
QPixmap BitmapFactoryInst::pixmapFromSvg(const char* name, const QSize& size) const

View File

@@ -216,32 +216,32 @@ void Gui::SoFCDB::finish()
}
// buffer acrobatics for inventor ****************************************************
static char * buffer;
static size_t buffer_size = 0;
static char * static_buffer;
static size_t static_buffer_size = 0;
static std::string cReturnString;
static void *
buffer_realloc(void * bufptr, size_t size)
{
buffer = (char *)realloc(bufptr, size);
buffer_size = size;
return buffer;
static_buffer = (char *)realloc(bufptr, size);
static_buffer_size = size;
return static_buffer;
}
const std::string& Gui::SoFCDB::writeNodesToString(SoNode * root)
{
SoOutput out;
buffer = (char *)malloc(1024);
buffer_size = 1024;
out.setBuffer(buffer, buffer_size, buffer_realloc);
static_buffer = (char *)malloc(1024);
static_buffer_size = 1024;
out.setBuffer(static_buffer, static_buffer_size, buffer_realloc);
if (root && root->getTypeId().isDerivedFrom(SoVRMLParent::getClassTypeId()))
out.setHeaderString("#VRML V2.0 utf8");
SoWriteAction wa(&out);
wa.apply(root);
cReturnString = buffer;
free(buffer);
cReturnString = static_buffer;
free(static_buffer);
return cReturnString;
}

View File

@@ -34,6 +34,7 @@
#include <Inventor/nodes/SoSeparator.h>
#include <Inventor/nodes/SoSwitch.h>
#include <Inventor/details/SoDetail.h>
#include "SoFCDB.h"
#include "ViewProvider.h"
#include "WidgetFactory.h"
@@ -621,37 +622,10 @@ void ViewProviderPy::setSwitchNode(Py::Object)
}
static char * buffer;
static size_t buffer_size = 0;
static void *
buffer_realloc(void * bufptr, size_t size)
{
buffer = (char *)realloc(bufptr, size);
buffer_size = size;
return buffer;
}
static SbString
buffer_writeaction(SoNode * root)
{
SoOutput out;
buffer = (char *)malloc(1024);
buffer_size = 1024;
out.setBuffer(buffer, buffer_size, buffer_realloc);
SoWriteAction wa(&out);
wa.apply(root);
SbString s(buffer);
free(buffer);
return s;
}
Py::String ViewProviderPy::getIV(void) const
{
SbString buf = buffer_writeaction(getViewProviderPtr()->getRoot());
return Py::String(buf.getString());
std::string buf = Gui::SoFCDB::writeNodesToString(getViewProviderPtr()->getRoot());
return Py::String(buf);
}
Py::Object ViewProviderPy::getIcon(void) const

View File

@@ -50,8 +50,6 @@ using namespace std;
PROPERTY_SOURCE(Drawing::FeaturePage, App::DocumentObjectGroup)
const char *group = "Drawing view";
FeaturePage::FeaturePage(void) : numChildren(0)
{
static const char *group = "Drawing view";