Skip to content

Commit

Permalink
Merge pull request #1003 from HifiExperiments/warnings_master
Browse files Browse the repository at this point in the history
Fix some warnings
  • Loading branch information
daleglass authored Jun 6, 2024
2 parents 64e9be1 + 2ae2f29 commit a79b714
Show file tree
Hide file tree
Showing 22 changed files with 70 additions and 52 deletions.
8 changes: 4 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -185,11 +185,11 @@ endif()

if(OVERTE_WARNINGS_AS_ERRORS)
if (CMAKE_CXX_COMPILER_ID MATCHES "MSVC" OR (CMAKE_CXX_COMPILER_ID MATCHES "" AND WIN32))
set(ENV{CXXFLAGS} "$ENV{CXXFLAGS} /WX")
set(ENV{CFLAGS} "$ENV{CXXFLAGS} /WX")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /WX")
set(CMAKE_CFLAGS "${CMAKE_CFLAGS} /WX")
else()
set(ENV{CXXFLAGS} "$ENV{CXXFLAGS} -Werror")
set(ENV{CFLAGS} "$ENV{CXXFLAGS} -Werror")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
set(CMAKE_CFLAGS "${CMAKE_CFLAGS} -Werror")
endif()
endif()

Expand Down
2 changes: 1 addition & 1 deletion interface/src/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7657,7 +7657,7 @@ void Application::registerScriptEngineWithApplicationServices(ScriptManagerPoint

{
auto connection = std::make_shared<QMetaObject::Connection>();
*connection = scriptManager->connect(scriptManager.get(), &ScriptManager::scriptEnding, [scriptManager, connection]() {
*connection = scriptManager->connect(scriptManager.get(), &ScriptManager::scriptEnding, [this, scriptManager, connection]() {
// Request removal of controller routes with callbacks to a given script engine
auto userInputMapper = DependencyManager::get<UserInputMapper>();
// scheduleScriptEndpointCleanup will have the last instance of shared pointer to script manager
Expand Down
4 changes: 2 additions & 2 deletions interface/src/LODManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ void LODManager::setRenderTimes(float presentTime, float engineRunTime, float ba
}

void LODManager::autoAdjustLOD(float realTimeDelta) {
std::lock_guard<std::mutex> lock{ _automaticLODLock };
std::lock_guard<std::mutex> lock(_automaticLODLock);

// The "render time" is the worse of:
// - engineRunTime: Time spent in the render thread in the engine producing the gpu::Frame N
Expand Down Expand Up @@ -300,7 +300,7 @@ void LODManager::resetLODAdjust() {
}

void LODManager::setAutomaticLODAdjust(bool value) {
std::lock_guard<std::mutex> lock{ _automaticLODLock };
std::lock_guard<std::mutex> lock(_automaticLODLock);
_automaticLODAdjust = value;
saveSettings();
emit autoLODChanged();
Expand Down
14 changes: 7 additions & 7 deletions interface/src/scripting/WindowScriptingInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ WindowScriptingInterface::~WindowScriptingInterface() {
}

ScriptValue WindowScriptingInterface::hasFocus() {
Q_ASSERT(engine);
Q_ASSERT(engine());
return engine()->newValue(qApp->hasFocus());
}

Expand Down Expand Up @@ -107,7 +107,7 @@ void WindowScriptingInterface::alert(const QString& message) {
/// \param const QString& message message to display
/// \return ScriptValue `true` if 'Yes' was clicked, `false` otherwise
ScriptValue WindowScriptingInterface::confirm(const QString& message) {
Q_ASSERT(engine);
Q_ASSERT(engine());
return engine()->newValue((QMessageBox::Yes == OffscreenUi::question("", message, QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes)));
}

Expand All @@ -117,7 +117,7 @@ ScriptValue WindowScriptingInterface::confirm(const QString& message) {
/// \return ScriptValue string text value in text box if the dialog was accepted, `null` otherwise.
ScriptValue WindowScriptingInterface::prompt(const QString& message, const QString& defaultText) {
QString result = OffscreenUi::getText(nullptr, "", message, QLineEdit::Normal, defaultText);
Q_ASSERT(engine);
Q_ASSERT(engine());
auto sResult = engine()->newValue(result);
if (sResult.equals(engine()->newValue(""))) {
return engine()->nullValue();
Expand Down Expand Up @@ -234,7 +234,7 @@ ScriptValue WindowScriptingInterface::browseDir(const QString& title, const QStr
if (!result.isEmpty()) {
setPreviousBrowseLocation(QFileInfo(result).absolutePath());
}
Q_ASSERT(engine);
Q_ASSERT(engine());
return result.isEmpty() ? engine()->nullValue() : engine()->newValue(result);
}

Expand Down Expand Up @@ -279,7 +279,7 @@ ScriptValue WindowScriptingInterface::browse(const QString& title, const QString
if (!result.isEmpty()) {
setPreviousBrowseLocation(QFileInfo(result).absolutePath());
}
Q_ASSERT(engine);
Q_ASSERT(engine());
return result.isEmpty() ? engine()->nullValue() : engine()->newValue(result);
}

Expand Down Expand Up @@ -327,7 +327,7 @@ ScriptValue WindowScriptingInterface::save(const QString& title, const QString&
if (!result.isEmpty()) {
setPreviousBrowseLocation(QFileInfo(result).absolutePath());
}
Q_ASSERT(engine);
Q_ASSERT(engine());
return result.isEmpty() ? engine()->nullValue() : engine()->newValue(result);
}

Expand Down Expand Up @@ -378,7 +378,7 @@ ScriptValue WindowScriptingInterface::browseAssets(const QString& title, const Q
if (!result.isEmpty()) {
setPreviousBrowseAssetLocation(QFileInfo(result).absolutePath());
}
Q_ASSERT(engine);
Q_ASSERT(engine());
return result.isEmpty() ? engine()->nullValue() : engine()->newValue(result);
}

Expand Down
2 changes: 2 additions & 0 deletions libraries/audio-client/src/AudioClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@
#endif

#ifdef WIN32
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN 1
#endif
#include <windows.h>
#include <Mmsystem.h>
#include <mmdeviceapi.h>
Expand Down
12 changes: 6 additions & 6 deletions libraries/avatars/src/AvatarData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2566,7 +2566,7 @@ QDataStream& operator>>(QDataStream& in, AttachmentData& attachment) {
void AttachmentDataObject::setModelURL(const QString& modelURL) {
AttachmentData data = scriptvalue_cast<AttachmentData>(thisObject());
data.modelURL = modelURL;
Q_ASSERT(engine);
Q_ASSERT(engine());
thisObject() = engine()->toScriptValue(data);
}

Expand All @@ -2577,7 +2577,7 @@ QString AttachmentDataObject::getModelURL() const {
void AttachmentDataObject::setJointName(const QString& jointName) {
AttachmentData data = scriptvalue_cast<AttachmentData>(thisObject());
data.jointName = jointName;
Q_ASSERT(engine);
Q_ASSERT(engine());
thisObject() = engine()->toScriptValue(data);
}

Expand All @@ -2588,7 +2588,7 @@ QString AttachmentDataObject::getJointName() const {
void AttachmentDataObject::setTranslation(const glm::vec3& translation) {
AttachmentData data = scriptvalue_cast<AttachmentData>(thisObject());
data.translation = translation;
Q_ASSERT(engine);
Q_ASSERT(engine());
thisObject() = engine()->toScriptValue(data);
}

Expand All @@ -2599,7 +2599,7 @@ glm::vec3 AttachmentDataObject::getTranslation() const {
void AttachmentDataObject::setRotation(const glm::quat& rotation) {
AttachmentData data = scriptvalue_cast<AttachmentData>(thisObject());
data.rotation = rotation;
Q_ASSERT(engine);
Q_ASSERT(engine());
thisObject() = engine()->toScriptValue(data);
}

Expand All @@ -2610,7 +2610,7 @@ glm::quat AttachmentDataObject::getRotation() const {
void AttachmentDataObject::setScale(float scale) {
AttachmentData data = scriptvalue_cast<AttachmentData>(thisObject());
data.scale = scale;
Q_ASSERT(engine);
Q_ASSERT(engine());
thisObject() = engine()->toScriptValue(data);
}

Expand All @@ -2621,7 +2621,7 @@ float AttachmentDataObject::getScale() const {
void AttachmentDataObject::setIsSoft(bool isSoft) {
AttachmentData data = scriptvalue_cast<AttachmentData>(thisObject());
data.isSoft = isSoft;
Q_ASSERT(engine);
Q_ASSERT(engine());
thisObject() = engine()->toScriptValue(data);
}

Expand Down
4 changes: 4 additions & 0 deletions libraries/graphics-scripting/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,7 @@ set(TARGET_NAME graphics-scripting)
setup_hifi_library()
link_hifi_libraries(shared networking graphics model-serializers image material-networking model-networking script-engine)
include_hifi_library_headers(gpu)

if (WIN32)
add_compile_definitions(_USE_MATH_DEFINES)
endif()
4 changes: 2 additions & 2 deletions libraries/render-utils/src/text/Font.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ void Font::buildVertices(Font::DrawInfo& drawInfo, const QString& str, const glm
std::vector<QuadBuilder> quadBuilders;
quadBuilders.reserve(glyphsAndCorners.size());
{
int i = glyphsAndCorners.size() - 1;
int i = (int)glyphsAndCorners.size() - 1;
while (i >= 0) {
auto nextGlyphAndCorner = glyphsAndCorners[i];
float rightSpacing = rightEdge - (nextGlyphAndCorner.second.x + nextGlyphAndCorner.first.d);
Expand All @@ -410,7 +410,7 @@ void Font::buildVertices(Font::DrawInfo& drawInfo, const QString& str, const glm
}

// The quadBuilders is backwards now because we looped over the glyphs backwards to adjust their alignment
for (int i = quadBuilders.size() - 1; i >= 0; i--) {
for (int i = (int)quadBuilders.size() - 1; i >= 0; i--) {
quint16 verticesOffset = numVertices;
drawInfo.verticesBuffer->append(quadBuilders[i]);
numVertices += VERTICES_PER_QUAD;
Expand Down
14 changes: 7 additions & 7 deletions libraries/script-engine/src/AssetScriptingInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ void AssetScriptingInterface::uploadData(QString data, const ScriptValue& callba
auto upload = DependencyManager::get<AssetClient>()->createUpload(dataByteArray);

Promise deferred = makePromise(__FUNCTION__);
Q_ASSERT(engine);
Q_ASSERT(engine());
auto scriptEngine = engine();
deferred->ready([=](QString error, QVariantMap result) {
auto url = result.value("url").toString();
Expand All @@ -98,7 +98,7 @@ void AssetScriptingInterface::setMapping(QString path, QString hash, const Scrip
auto handler = jsBindCallback(thisObject(), callback);
auto setMappingRequest = assetClient()->createSetMappingRequest(path, hash);
Promise deferred = makePromise(__FUNCTION__);
Q_ASSERT(engine);
Q_ASSERT(engine());
auto scriptEngine = engine();
deferred->ready([=](QString error, QVariantMap result) {
jsCallback(handler, scriptEngine->newValue(error), result);
Expand Down Expand Up @@ -136,7 +136,7 @@ void AssetScriptingInterface::downloadData(QString urlString, const ScriptValue&
auto assetRequest = assetClient->createRequest(hash);

Promise deferred = makePromise(__FUNCTION__);
Q_ASSERT(engine);
Q_ASSERT(engine());
auto scriptEngine = engine();
deferred->ready([=](QString error, QVariantMap result) {
// FIXME: to remain backwards-compatible the signature here is "callback(data, n/a)"
Expand Down Expand Up @@ -200,7 +200,7 @@ void AssetScriptingInterface::getMapping(QString asset, const ScriptValue& callb
JS_VERIFY(AssetUtils::isValidFilePath(path), "invalid ATP file path: " + asset + "(path:"+path+")");
JS_VERIFY(callback.isFunction(), "expected second parameter to be a callback function");
Promise promise = getAssetInfo(path);
Q_ASSERT(engine);
Q_ASSERT(engine());
auto scriptEngine = engine();
promise->ready([=](QString error, QVariantMap result) {
jsCallback(handler, scriptEngine->newValue(error), scriptEngine->newValue(result.value("hash").toString()));
Expand Down Expand Up @@ -234,7 +234,7 @@ Promise AssetScriptingInterface::jsPromiseReady(Promise promise, const ScriptVal
if (!jsVerify(handler.isValid(), "jsPromiseReady -- invalid callback handler")) {
return nullptr;
}
Q_ASSERT(engine);
Q_ASSERT(engine());
auto scriptEngine = engine();
return promise->ready([this, handler, scriptEngine](QString error, QVariantMap result) {
jsCallback(handler, scriptEngine->newValue(error), result);
Expand All @@ -244,7 +244,7 @@ Promise AssetScriptingInterface::jsPromiseReady(Promise promise, const ScriptVal
void AssetScriptingInterface::jsCallback(const ScriptValue& handler,
const ScriptValue& error, const ScriptValue& result) {
Q_ASSERT(thread() == QThread::currentThread());
Q_ASSERT(engine);
Q_ASSERT(engine());
//V8TODO: which kind of script context guard needs to be used here?
ScriptContextGuard scriptContextGuard(_scriptManager->engine()->currentContext());
auto errorValue = !error.toBool() ? engine()->nullValue() : error;
Expand Down Expand Up @@ -546,7 +546,7 @@ void AssetScriptingInterface::loadFromCache(const ScriptValue& options, const Sc
}

bool AssetScriptingInterface::canWriteCacheValue(const QUrl& url) {
Q_ASSERT(engine);
Q_ASSERT(engine());
auto scriptManager = engine()->manager();
if (!scriptManager) {
return false;
Expand Down
8 changes: 4 additions & 4 deletions libraries/script-engine/src/ConsoleScriptingInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,14 @@ ScriptValue ConsoleScriptingInterface::exception(ScriptContext* context, ScriptE
void ConsoleScriptingInterface::time(QString labelName) {
_timerDetails.insert(labelName, QDateTime::currentDateTime().toUTC());
QString message = QString("%1: Timer started").arg(labelName);
Q_ASSERT(engine);
Q_ASSERT(engine());
if (ScriptManager* scriptManager = engine()->manager()) {
scriptManager->scriptPrintedMessage(message, context()->currentFileName(), context()->currentLineNumber());
}
}

void ConsoleScriptingInterface::timeEnd(QString labelName) {
Q_ASSERT(engine);
Q_ASSERT(engine());
if (ScriptManager* scriptManager = engine()->manager()) {
if (!_timerDetails.contains(labelName)) {
scriptManager->scriptErrorMessage("No such label found " + labelName, context()->currentFileName(), context()->currentLineNumber());
Expand Down Expand Up @@ -138,7 +138,7 @@ ScriptValue ConsoleScriptingInterface::assertion(ScriptContext* context, ScriptE
}

void ConsoleScriptingInterface::trace() {
Q_ASSERT(engine);
Q_ASSERT(engine());
ScriptEnginePointer scriptEngine = engine();
if (ScriptManager* scriptManager = scriptEngine->manager()) {
scriptManager->scriptPrintedMessage
Expand All @@ -148,7 +148,7 @@ void ConsoleScriptingInterface::trace() {
}

void ConsoleScriptingInterface::clear() {
Q_ASSERT(engine);
Q_ASSERT(engine());
if (ScriptManager* scriptManager = engine()->manager()) {
scriptManager->clearDebugLogWindow();
}
Expand Down
2 changes: 1 addition & 1 deletion libraries/script-engine/src/Mat4.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ void Mat4::print(const QString& label, const glm::mat4& m, bool transpose) const
QString message = QString("%1 %2").arg(qPrintable(label));
message = message.arg(glm::to_string(out).c_str());
qCDebug(scriptengine) << message;
Q_ASSERT(engine);
Q_ASSERT(engine());
if (ScriptManager* scriptManager = engine()->manager()) {
scriptManager->print(message);
}
Expand Down
2 changes: 1 addition & 1 deletion libraries/script-engine/src/Quat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ void Quat::print(const QString& label, const glm::quat& q, bool asDegrees) {
message = message.arg(glm::to_string(glm::dquat(q)).c_str());
}
qCDebug(scriptengine) << message;
Q_ASSERT(engine);
Q_ASSERT(engine());
if (ScriptManager* scriptManager = engine()->manager()) {
scriptManager->print(message);
}
Expand Down
2 changes: 1 addition & 1 deletion libraries/script-engine/src/ScriptUUID.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ void ScriptUUID::print(const QString& label, const QUuid& id) {
QString message = QString("%1 %2").arg(qPrintable(label));
message = message.arg(id.toString());
qCDebug(scriptengine) << message;
Q_ASSERT(engine);
Q_ASSERT(engine());
if (ScriptManager* scriptManager = engine()->manager()) {
scriptManager->print(message);
}
Expand Down
2 changes: 1 addition & 1 deletion libraries/script-engine/src/Vec3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ void Vec3::print(const QString& label, const glm::vec3& v) {
QString message = QString("%1 %2").arg(qPrintable(label));
message = message.arg(glm::to_string(glm::dvec3(v)).c_str());
qCDebug(scriptengine) << message;
Q_ASSERT(engine);
Q_ASSERT(engine());
if (ScriptManager* scriptManager = engine()->manager()) {
scriptManager->print(message);
}
Expand Down
8 changes: 4 additions & 4 deletions libraries/script-engine/src/v8/ScriptEngineV8.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ void ScriptEngineV8::storeGlobalObjectContents() {
v8::Local<v8::Object> globalMemberObjects = v8::Object::New(_v8Isolate);

auto globalMemberNames = context->Global()->GetPropertyNames(context).ToLocalChecked();
for (size_t i = 0; i < globalMemberNames->Length(); i++) {
for (uint32_t i = 0; i < globalMemberNames->Length(); i++) {
auto name = globalMemberNames->Get(context, i).ToLocalChecked();
if(!globalMemberObjects->Set(context, name, context->Global()->Get(context, name).ToLocalChecked()).FromMaybe(false)) {
Q_ASSERT(false);
Expand Down Expand Up @@ -645,7 +645,7 @@ ScriptValue ScriptEngineV8::evaluateInClosure(const ScriptValue& _closure,
// Since V8 cannot use arbitrary object as global object, objects from main global need to be copied to closure's global object
auto globalObjectContents = _globalObjectContents.Get(_v8Isolate);
auto globalMemberNames = globalObjectContents->GetPropertyNames(globalObjectContents->CreationContext()).ToLocalChecked();
for (size_t i = 0; i < globalMemberNames->Length(); i++) {
for (uint32_t i = 0; i < globalMemberNames->Length(); i++) {
auto name = globalMemberNames->Get(closureContext, i).ToLocalChecked();
if(!closureContext->Global()->Set(closureContext, name, globalObjectContents->Get(globalObjectContents->CreationContext(), name).ToLocalChecked()).FromMaybe(false)) {
Q_ASSERT(false);
Expand All @@ -656,7 +656,7 @@ ScriptValue ScriptEngineV8::evaluateInClosure(const ScriptValue& _closure,
// Objects from closure need to be copied to global object too
// V8TODO: I'm not sure which context to use with Get
auto closureMemberNames = closureObject->GetPropertyNames(closureContext).ToLocalChecked();
for (size_t i = 0; i < closureMemberNames->Length(); i++) {
for (uint32_t i = 0; i < closureMemberNames->Length(); i++) {
auto name = closureMemberNames->Get(closureContext, i).ToLocalChecked();
if(!closureContext->Global()->Set(closureContext, name, closureObject->Get(closureContext, name).ToLocalChecked()).FromMaybe(false)) {
Q_ASSERT(false);
Expand Down Expand Up @@ -717,7 +717,7 @@ ScriptValue ScriptEngineV8::evaluateInClosure(const ScriptValue& _closure,

auto requireMemberNames =
oldRequireObject->GetPropertyNames(oldRequireObject->CreationContext()).ToLocalChecked();
for (size_t i = 0; i < requireMemberNames->Length(); i++) {
for (uint32_t i = 0; i < requireMemberNames->Length(); i++) {
auto name = requireMemberNames->Get(closureContext, i).ToLocalChecked();
v8::Local<v8::Value> oldObject;
if (!oldRequireObject->Get(oldRequireObject->CreationContext(), name).ToLocal(&oldObject)) {
Expand Down
2 changes: 2 additions & 0 deletions libraries/shared/src/PortableHighResolutionClock.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@

#if defined(_MSC_VER) && _MSC_VER < 1900

#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
#include <windows.h>

// The following struct is not compliant with the HF coding standard, but uses underscores to match the classes
Expand Down
2 changes: 2 additions & 0 deletions libraries/shared/src/shared/WebRTC.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@
# define WEBRTC_DATA_CHANNELS 1
# define WEBRTC_WIN 1
# define NOMINMAX 1
#ifndef WIN32_LEAN_AND_MEAN
# define WIN32_LEAN_AND_MEAN 1
#endif
#elif defined(Q_OS_ANDROID)
// I don't yet have a working libwebrtc for android
// # define WEBRTC_AUDIO 1
Expand Down
4 changes: 4 additions & 0 deletions libraries/ui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,7 @@ include_hifi_library_headers(controllers)
# Required for some low level GL interaction in the OffscreenQMLSurface
set(OpenGL_GL_PREFERENCE "GLVND")
target_opengl()

if (WIN32)
add_compile_definitions(_USE_MATH_DEFINES)
endif()
Loading

0 comments on commit a79b714

Please sign in to comment.