Skip to content

Commit

Permalink
Fix warnings and MSVC compiler errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
acolwell committed Jul 23, 2024
1 parent e7323b3 commit 86989f0
Show file tree
Hide file tree
Showing 17 changed files with 44 additions and 55 deletions.
6 changes: 5 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,11 @@ set(QTWIDGETS_INCLUDE_DIRS ${Qt5Widgets_INCLUDE_DIRS})
#for QString(const char*) assumes ASCII strings, we may run into troubles
add_compile_definitions(QT_NO_CAST_FROM_ASCII)

if (NOT MSVC)
if (MSVC)
# Allow __cplusplus to properly reflect the c++ standard version.
add_compile_options(/Zc:__cplusplus)
add_compile_definitions(__STDC_LIMIT_MACROS WIN32_LEAN_AND_MEAN _USE_MATH_DEFINES)
else()
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wmissing-prototypes" )
add_compile_options(-Wall -Wextra -Wmissing-declarations -Wno-multichar -Winit-self -Wno-long-long
-Wvla -Wdate-time -Wshift-overflow=2
Expand Down
4 changes: 4 additions & 0 deletions Engine/CLArgs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@
#include <cassert>
#include <stdexcept>

#ifdef __NATRON_WIN32__
#include <shellapi.h> // CommandLineToArgvW
#endif

#include <QtCore/QCoreApplication>
#include <QtCore/QDebug>
#include <QtCore/QFile>
Expand Down
2 changes: 1 addition & 1 deletion Engine/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ target_include_directories(NatronEngine
)
target_compile_definitions(NatronEngine
PRIVATE
NATRON_CUSTOM_BUILD_USER_TOKEN=${BUILD_USER_NAME}
NATRON_CUSTOM_BUILD_USER_TOKEN="${BUILD_USER_NAME}"
NATRON_BUILD_NUMBER=0
${XDG_DEFS}
)
2 changes: 2 additions & 0 deletions Engine/HostOverlaySupport.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
#include <Python.h>
// ***** END PYTHON BLOCK *****

#include <string>

#include "Global/Macros.h"

#include "Engine/EngineFwd.h"
Expand Down
8 changes: 0 additions & 8 deletions Engine/Knob.h
Original file line number Diff line number Diff line change
Expand Up @@ -1938,12 +1938,6 @@ class Knob
ViewSpec view,
int dimension);

/**
* @brief This is called by the plugin when a set value call would happen during an interact action.
**/
void requestSetValueOnUndoStack(const T & value,
ViewSpec view,
int dimension);

/**
* @brief Calls setValueAtTime with a reason of eValueChangedReasonNatronInternalEdited.
Expand Down Expand Up @@ -2147,8 +2141,6 @@ class Knob

void makeKeyFrame(Curve* curve, double time, ViewSpec view, const T& v, KeyFrame* key);

void queueSetValue(const T& v, ViewSpec view, int dimension);

virtual void clearExpressionsResults(int dimension) OVERRIDE FINAL
{
QMutexLocker k(&_valueMutex);
Expand Down
7 changes: 4 additions & 3 deletions Engine/KnobImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -2588,9 +2588,10 @@ Knob<T>::copyValueForTypeAndCheckIfChanged(Knob<OTHERTYPE>* other,
int dimMin = std::min( getDimension(), other->getDimension() );
std::vector<OTHERTYPE> v = other->getValueForEachDimension_mt_safe_vector();
for (int i = 0; i < dimMin; ++i) {
if (_values[i] != v[i]) {
_values[i] = v[i];
_guiValues[i] = v[i];
const T convertedV = static_cast<T>(v[i]);
if (_values[i] != convertedV) {
_values[i] = convertedV;
_guiValues[i] = convertedV;
ret = true;
}
}
Expand Down
4 changes: 2 additions & 2 deletions Engine/NodeGroup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2836,12 +2836,12 @@ NodeCollection::exportGroupToPython(const QString& pluginID,
WRITE_STATIC_LINE(NATRON_PYPLUG_MAGIC);
QString descline = QString( QString::fromUtf8(NATRON_PYPLUG_GENERATED "%1 PyPlug exporter version %2.") ).arg( QString::fromUtf8(NATRON_APPLICATION_NAME) ).arg(NATRON_PYPLUG_EXPORTER_VERSION);
WRITE_STRING(descline);
WRITE_STATIC_LINE();
WRITE_STATIC_LINE("");
QString handWrittenStr = QString::fromUtf8("# Hand-written code should be added in a separate file named %1.py").arg(extModule);
WRITE_STRING(handWrittenStr);
WRITE_STATIC_LINE("# See http://natron.readthedocs.org/en/master/devel/groups.html#adding-hand-written-code-callbacks-etc");
WRITE_STATIC_LINE("# Note that Viewers are never exported");
WRITE_STATIC_LINE();
WRITE_STATIC_LINE("");
WRITE_STATIC_LINE("import " NATRON_ENGINE_PYTHON_MODULE_NAME);
WRITE_STATIC_LINE("import sys");
WRITE_STATIC_LINE("");
Expand Down
1 change: 1 addition & 0 deletions Engine/NodePrivate.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "Global/Macros.h"

#include "Node.h"
#include "Timer.h" // gettimeofday()

#include <QtCore/QWaitCondition>
#include <QtCore/QReadWriteLock>
Expand Down
2 changes: 1 addition & 1 deletion Engine/StandardPaths.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

#include <QtCore/QtGlobal> // for Q_OS_*
#if defined(Q_OS_WIN)
#include <windows.h>
#include <combaseapi.h>
#include <IntShCut.h>
#include <ShlObj.h>
#ifndef CSIDL_MYMUSIC
Expand Down
2 changes: 1 addition & 1 deletion Engine/Timer.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
//----------------------------------------------------------------------------

#if defined(__NATRON_WIN32__) && !defined(__NATRON_MINGW__)
#include <windows.h>
#include <winsock2.h>
#else
#include <sys/time.h>
#endif
Expand Down
1 change: 1 addition & 0 deletions Engine/TrackerContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ CLANG_DIAG_ON(uninitialized)
#include "Engine/KnobTypes.h"
#include "Engine/Project.h"
#include "Engine/Curve.h"
#include "Engine/Timer.h" // gettimeofday()
#include "Engine/TLSHolder.h"
#include "Engine/Transform.h"
#include "Engine/TrackMarker.h"
Expand Down
3 changes: 3 additions & 0 deletions Global/Macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,9 @@ GCC_ONLY_DIAG_OFF(pragmas) // warning: unknown option after '#pragma GCC diagno
/////////////////////////////////////////////////////////////////////////////////////////////

/* COMPILER() - the compiler being used to build the project */
#ifdef COMPILER
#undef COMPILER
#endif
#define COMPILER(NATRON_FEATURE) (NATRON_COMPILER_ ## NATRON_FEATURE)

/* COMPILER_SUPPORTS() - whether the compiler being used to build the project supports the given feature. */
Expand Down
6 changes: 5 additions & 1 deletion Global/ProcInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@
#include <string.h> // strdup
#endif

#ifdef __NATRON_WIN32__
#include <shellapi.h> // CommandLineToArgvW
#endif

#include "StrUtils.h"

NATRON_NAMESPACE_ENTER
Expand Down Expand Up @@ -499,7 +503,7 @@ ProcInfo::getenv_wrapper(const char *varName)
std::vector<char> buffer;
getenv_s(&requiredSize, 0, 0, varName);
if (requiredSize == 0)
return buffer;
return std::string();
buffer.resize(requiredSize);
getenv_s(&requiredSize, &buffer[0], requiredSize, varName);
// requiredSize includes the terminating null, which we don't want.
Expand Down
2 changes: 1 addition & 1 deletion Gui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ target_include_directories(NatronGui
)
target_compile_definitions(NatronGui
PRIVATE
NATRON_CUSTOM_BUILD_USER_TOKEN=${BUILD_USER_NAME}
NATRON_CUSTOM_BUILD_USER_TOKEN="${BUILD_USER_NAME}"
NATRON_BUILD_NUMBER=0
QT_NO_KEYWORDS
)
3 changes: 2 additions & 1 deletion Gui/FileTypeMainWindow_win.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@
#include <stdexcept>

// —— general includes —————————————————————————
#include <windows.h>
#include <Dde.h>

#include <QMessageBox>
#include <QApplication>
#include <QtCore/QDir>
Expand Down
35 changes: 0 additions & 35 deletions Gui/HostOverlay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1006,41 +1006,6 @@ PositionInteract::draw(double time,
glTranslated(direction * shadow.x, -direction * shadow.y, 0);
glMatrixMode(GL_MODELVIEW); // Modelview should be used on Nuke

#warning TODO
#if 0
int numKeys = knob->get;

if (numKeys > 0) {
const double darken = 0.5;
glColor3f(pR * l * darken, pG * l * darken, pB * l * darken);

glPointSize(pointSize() * screenPixelRatio);
glBegin(GL_POINTS);
for (int i=0; i < numKeys; ++i) {
double time = p->getKeyTime(i);
OfxPointD pt;
p->getValueAtTime(time, pt.x, pt.y);
glVertex2d(pt.x, pt.y);

}
glEnd();
glLineWidth(1.5 * screenPixelRatio);
glBegin(GL_LINE_STRIP);
double time = p->getKeyTime(0);
for (int i = 1; i < numKeys; ++i) {
double timeNext = p->getKeyTime(i);
for (int j = (i == 1 ? 0 : 1); j <= steps; ++j) {
double timeStep = time + j * (timeNext - time) / steps;
OfxPointD pt;
p->getValueAtTime(timeStep, pt.x, pt.y);
glVertex2d(pt.x, pt.y);
}
time = timeNext;
}
glEnd();
}
#endif

glColor3f(pR * l, pG * l, pB * l);
glPointSize(pointSize() * screenPixelRatio);
glBegin(GL_POINTS);
Expand Down
11 changes: 11 additions & 0 deletions Tests/OSGLContext_Test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,17 @@

NATRON_NAMESPACE_USING

#if defined(__NATRON_WIN32__) && !defined(__NATRON_MINGW__)
namespace {

// Define nullptr_t operator since MSVC dosn't appear to have one by default.
std::ostream& operator<<(std::ostream& os, const std::nullptr_t p) {
return os << "<nullptr>";
}

} // namespace
#endif

TEST(OSGLContext, Basic)
{
if (!appPTR->isOpenGLLoaded()) {
Expand Down

0 comments on commit 86989f0

Please sign in to comment.