Compare commits
2 commits
e8b9054134
...
92a68925d9
Author | SHA1 | Date | |
---|---|---|---|
92a68925d9 | |||
6d4dc844b3 |
16 changed files with 131 additions and 28 deletions
2
.clangd
Normal file
2
.clangd
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
CompileFlags:
|
||||||
|
Add: [-std=c++20]
|
|
@ -7,7 +7,9 @@
|
||||||
#include <glm/gtc/quaternion.hpp>
|
#include <glm/gtc/quaternion.hpp>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <format>
|
||||||
|
|
||||||
|
#include "logger.h"
|
||||||
#include "objects/part.h"
|
#include "objects/part.h"
|
||||||
#include "rendering/renderer.h"
|
#include "rendering/renderer.h"
|
||||||
#include "physics/simulation.h"
|
#include "physics/simulation.h"
|
||||||
|
@ -29,6 +31,8 @@ void resizeCallback(GLFWwindow* window, int width, int height);
|
||||||
std::shared_ptr<Part> lastPart;
|
std::shared_ptr<Part> lastPart;
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
|
Logger::init();
|
||||||
|
|
||||||
glfwSetErrorCallback(errorCatcher);
|
glfwSetErrorCallback(errorCatcher);
|
||||||
|
|
||||||
glfwInit();
|
glfwInit();
|
||||||
|
@ -85,7 +89,7 @@ int main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void errorCatcher(int id, const char* str) {
|
void errorCatcher(int id, const char* str) {
|
||||||
printf("Something *terrible* happened. Here's the briefing: [%d] %s\n", id, str);
|
Logger::fatalError(std::format("GLFW Error: [{}] {}", id, str));
|
||||||
}
|
}
|
||||||
|
|
||||||
float lastTime;
|
float lastTime;
|
||||||
|
|
|
@ -15,4 +15,9 @@ file(GLOB_RECURSE SOURCES "src/*.cpp" "src/*.h")
|
||||||
add_library(openblocks STATIC ${SOURCES})
|
add_library(openblocks STATIC ${SOURCES})
|
||||||
set_target_properties(openblocks PROPERTIES OUTPUT_NAME "openblocks")
|
set_target_properties(openblocks PROPERTIES OUTPUT_NAME "openblocks")
|
||||||
target_link_libraries(openblocks ${GLEW_LIBRARIES} OpenGL::GL ReactPhysics3D::ReactPhysics3D pugixml::pugixml)
|
target_link_libraries(openblocks ${GLEW_LIBRARIES} OpenGL::GL ReactPhysics3D::ReactPhysics3D pugixml::pugixml)
|
||||||
target_include_directories(openblocks PUBLIC "src" "../include")
|
target_include_directories(openblocks PUBLIC "src" "../include")
|
||||||
|
|
||||||
|
# Windows-specific dependencies
|
||||||
|
if(WIN32)
|
||||||
|
target_link_libraries(openblocks shell32.lib)
|
||||||
|
endif()
|
|
@ -1,6 +1,7 @@
|
||||||
#include "meta.h"
|
#include "meta.h"
|
||||||
#include "datatypes/base.h"
|
#include "datatypes/base.h"
|
||||||
#include "datatypes/cframe.h"
|
#include "datatypes/cframe.h"
|
||||||
|
#include "logger.h"
|
||||||
#include <variant>
|
#include <variant>
|
||||||
|
|
||||||
Data::String Data::Variant::ToString() const {
|
Data::String Data::Variant::ToString() const {
|
||||||
|
@ -17,7 +18,7 @@ void Data::Variant::Serialize(pugi::xml_node* node) const {
|
||||||
|
|
||||||
Data::Variant Data::Variant::Deserialize(pugi::xml_node* node) {
|
Data::Variant Data::Variant::Deserialize(pugi::xml_node* node) {
|
||||||
if (Data::TYPE_MAP.count(node->name()) == 0) {
|
if (Data::TYPE_MAP.count(node->name()) == 0) {
|
||||||
fprintf(stderr, "Unknown type for instance: '%s'\n", node->name());
|
Logger::fatalErrorf("Unknown type for instance: '%s'", node->name());
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
43
core/src/logger.cpp
Normal file
43
core/src/logger.cpp
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
#include "logger.h"
|
||||||
|
#include "platform.h"
|
||||||
|
|
||||||
|
#include <fstream>
|
||||||
|
#include <chrono>
|
||||||
|
#include <format>
|
||||||
|
|
||||||
|
static std::ofstream logStream;
|
||||||
|
|
||||||
|
void Logger::init() {
|
||||||
|
initProgramLogsDir();
|
||||||
|
|
||||||
|
const auto now = std::chrono::system_clock::now();
|
||||||
|
|
||||||
|
std::string fileName = std::format("log_{0:%Y%m%d}_{0:%H%M%S}.txt", now);
|
||||||
|
|
||||||
|
logStream = std::ofstream(getProgramLogsDir() + "/" + fileName);
|
||||||
|
Logger::debug("Logger initialized");
|
||||||
|
}
|
||||||
|
|
||||||
|
void Logger::finish() {
|
||||||
|
Logger::debug("Closing logger...");
|
||||||
|
logStream.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Logger::log(std::string message, Logger::LogLevel logLevel) {
|
||||||
|
std::string logLevelStr = logLevel == Logger::LogLevel::INFO ? "INFO" :
|
||||||
|
logLevel == Logger::LogLevel::DEBUG ? "DEBUG" :
|
||||||
|
logLevel == Logger::LogLevel::WARNING ? "WARN" :
|
||||||
|
logLevel == Logger::LogLevel::ERROR ? "ERROR" :
|
||||||
|
logLevel == Logger::LogLevel::FATAL_ERROR ? "FATAL" : "?";
|
||||||
|
|
||||||
|
const auto now = std::chrono::system_clock::now();
|
||||||
|
|
||||||
|
std::string formattedLogLine = std::format("[{:%Y-%m-%d %X}] [{}] {}", now, logLevelStr, message);
|
||||||
|
|
||||||
|
printf("%s\n", formattedLogLine.c_str());
|
||||||
|
logStream << formattedLogLine << std::endl;
|
||||||
|
|
||||||
|
if (logLevel == Logger::LogLevel::FATAL_ERROR) {
|
||||||
|
displayErrorMessage(formattedLogLine);
|
||||||
|
}
|
||||||
|
}
|
37
core/src/logger.h
Normal file
37
core/src/logger.h
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <format>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
namespace Logger {
|
||||||
|
enum class LogLevel {
|
||||||
|
INFO,
|
||||||
|
DEBUG,
|
||||||
|
WARNING,
|
||||||
|
ERROR,
|
||||||
|
FATAL_ERROR,
|
||||||
|
};
|
||||||
|
|
||||||
|
void init();
|
||||||
|
void finish();
|
||||||
|
|
||||||
|
void log(std::string message, LogLevel logLevel);
|
||||||
|
inline void info(std::string message) { log(message, LogLevel::INFO); }
|
||||||
|
inline void debug(std::string message) { log(message, LogLevel::DEBUG); }
|
||||||
|
inline void warning(std::string message) { log(message, LogLevel::WARNING); }
|
||||||
|
inline void error(std::string message) { log(message, LogLevel::ERROR); }
|
||||||
|
inline void fatalError(std::string message) { log(message, LogLevel::FATAL_ERROR); }
|
||||||
|
|
||||||
|
template <typename ...Args>
|
||||||
|
void logf(std::string format, LogLevel logLevel, Args&&... args) {
|
||||||
|
char message[200];
|
||||||
|
sprintf(message, format.c_str(), args...);
|
||||||
|
log(message, logLevel);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename ...Args> inline void infof(std::string format, Args&&... args) { logf(format, LogLevel::INFO, args...); }
|
||||||
|
template <typename ...Args> inline void debugf(std::string format, Args&&... args) { logf(format, LogLevel::DEBUG, args...); }
|
||||||
|
template <typename ...Args> inline void warningf(std::string format, Args&&... args) { logf(format, LogLevel::WARNING, args...); }
|
||||||
|
template <typename ...Args> inline void errorf(std::string format, Args&&... args) { logf(format, LogLevel::ERROR, args...); }
|
||||||
|
template <typename ...Args> inline void fatalErrorf(std::string format, Args&&... args) { logf(format, LogLevel::FATAL_ERROR, args...);}
|
||||||
|
};
|
|
@ -1,9 +1,10 @@
|
||||||
#include "instance.h"
|
#include "instance.h"
|
||||||
#include "../../common.h"
|
#include "common.h"
|
||||||
#include "../../datatypes/meta.h"
|
#include "datatypes/meta.h"
|
||||||
#include "datatypes/base.h"
|
#include "datatypes/base.h"
|
||||||
#include "objects/base/member.h"
|
#include "objects/base/member.h"
|
||||||
#include "objects/meta.h"
|
#include "objects/meta.h"
|
||||||
|
#include "logger.h"
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
@ -169,7 +170,7 @@ void Instance::Serialize(pugi::xml_node* parent) {
|
||||||
InstanceRef Instance::Deserialize(pugi::xml_node* node) {
|
InstanceRef Instance::Deserialize(pugi::xml_node* node) {
|
||||||
std::string className = node->attribute("class").value();
|
std::string className = node->attribute("class").value();
|
||||||
if (INSTANCE_MAP.count(className) == 0) {
|
if (INSTANCE_MAP.count(className) == 0) {
|
||||||
fprintf(stderr, "Unknown type for instance: '%s'\n", className.c_str());
|
Logger::fatalErrorf("Unknown type for instance: '%s'", className.c_str());
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
// This will error if an abstract instance is used in the file. Oh well, not my prob rn.
|
// This will error if an abstract instance is used in the file. Oh well, not my prob rn.
|
||||||
|
@ -185,7 +186,7 @@ InstanceRef Instance::Deserialize(pugi::xml_node* node) {
|
||||||
std::string propertyName = propertyNode.attribute("name").value();
|
std::string propertyName = propertyNode.attribute("name").value();
|
||||||
auto meta_ = object->GetPropertyMeta(propertyName);
|
auto meta_ = object->GetPropertyMeta(propertyName);
|
||||||
if (!meta_.has_value()) {
|
if (!meta_.has_value()) {
|
||||||
fprintf(stderr, "Attempt to set unknown property '%s' of %s\n", propertyName.c_str(), object->GetClass()->className.c_str());
|
Logger::fatalErrorf("Attempt to set unknown property '%s' of %s", propertyName.c_str(), object->GetClass()->className.c_str());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
Data::Variant value = Data::Variant::Deserialize(&propertyNode);
|
Data::Variant value = Data::Variant::Deserialize(&propertyNode);
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
#include "objects/base/instance.h"
|
#include "objects/base/instance.h"
|
||||||
#include "objects/base/service.h"
|
#include "objects/base/service.h"
|
||||||
#include "workspace.h"
|
#include "workspace.h"
|
||||||
|
#include "logger.h"
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
@ -42,7 +43,7 @@ void DataModel::Init() {
|
||||||
|
|
||||||
void DataModel::SaveToFile(std::optional<std::string> path) {
|
void DataModel::SaveToFile(std::optional<std::string> path) {
|
||||||
if (!path.has_value() && !this->currentFile.has_value()) {
|
if (!path.has_value() && !this->currentFile.has_value()) {
|
||||||
fprintf(stderr, "Cannot save DataModel because no path was provided.\n");
|
Logger::fatalError("Cannot save DataModel because no path was provided.");
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,18 +61,18 @@ void DataModel::SaveToFile(std::optional<std::string> path) {
|
||||||
doc.save(outStream);
|
doc.save(outStream);
|
||||||
currentFile = target;
|
currentFile = target;
|
||||||
name = target;
|
name = target;
|
||||||
printf("Place saved succesfully\n");
|
Logger::info("Place saved succesfully");
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataModel::DeserializeService(pugi::xml_node* node) {
|
void DataModel::DeserializeService(pugi::xml_node* node) {
|
||||||
std::string className = node->attribute("class").value();
|
std::string className = node->attribute("class").value();
|
||||||
if (SERVICE_CONSTRUCTORS.count(className) == 0) {
|
if (SERVICE_CONSTRUCTORS.count(className) == 0) {
|
||||||
fprintf(stderr, "Unknown service: '%s'\n", className.c_str());
|
Logger::fatalErrorf("Unknown service: '%s'", className.c_str());
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (services.count(className) != 0) {
|
if (services.count(className) != 0) {
|
||||||
fprintf(stderr, "Service %s defined multiple times in file\n", className.c_str());
|
Logger::fatalErrorf("Service %s defined multiple times in file", className.c_str());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,7 +85,7 @@ void DataModel::DeserializeService(pugi::xml_node* node) {
|
||||||
std::string propertyName = propertyNode.attribute("name").value();
|
std::string propertyName = propertyNode.attribute("name").value();
|
||||||
auto meta_ = object->GetPropertyMeta(propertyName);
|
auto meta_ = object->GetPropertyMeta(propertyName);
|
||||||
if (!meta_.has_value()) {
|
if (!meta_.has_value()) {
|
||||||
fprintf(stderr, "Attempt to set unknown property '%s' of %s\n", propertyName.c_str(), object->GetClass()->className.c_str());
|
Logger::fatalErrorf("Attempt to set unknown property '%s' of %s", propertyName.c_str(), object->GetClass()->className.c_str());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
Data::Variant value = Data::Variant::Deserialize(&propertyNode);
|
Data::Variant value = Data::Variant::Deserialize(&propertyNode);
|
||||||
|
|
|
@ -22,7 +22,7 @@ std::string getProgramDataDir() {
|
||||||
return std::string(homedir) + "/openblocks";
|
return std::string(homedir) + "/openblocks";
|
||||||
}
|
}
|
||||||
|
|
||||||
void printErrorMessage(std::string message) {
|
void displayErrorMessage(std::string message) {
|
||||||
fprintf(stderr, "%s\n", message.c_str());
|
fprintf(stderr, "%s\n", message.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ std::string getProgramDataDir() {
|
||||||
return localAppData + "/openblocks";
|
return localAppData + "/openblocks";
|
||||||
}
|
}
|
||||||
|
|
||||||
void printErrorMessage(std::string message) {
|
void displayErrorMessage(std::string message) {
|
||||||
fprintf(stderr, "%s\n", message.c_str());
|
fprintf(stderr, "%s\n", message.c_str());
|
||||||
MessageBoxA(NULL, message.c_str(), "Fatal Error", MB_OK);
|
MessageBoxA(NULL, message.c_str(), "Fatal Error", MB_OK);
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,4 +20,4 @@ void initProgramDataDir();
|
||||||
void initProgramLogsDir();
|
void initProgramLogsDir();
|
||||||
|
|
||||||
// Displays an error message box on Windows, or prints to eprintf
|
// Displays an error message box on Windows, or prints to eprintf
|
||||||
void printErrorMessage(std::string message);
|
void displayErrorMessage(std::string message);
|
|
@ -3,6 +3,7 @@
|
||||||
#include <GL/gl.h>
|
#include <GL/gl.h>
|
||||||
#include <glm/gtc/type_ptr.hpp>
|
#include <glm/gtc/type_ptr.hpp>
|
||||||
|
|
||||||
|
#include "logger.h"
|
||||||
#include "shader.h"
|
#include "shader.h"
|
||||||
|
|
||||||
std::string getContents(std::string filePath) {
|
std::string getContents(std::string filePath) {
|
||||||
|
@ -25,7 +26,7 @@ unsigned int compileShader(std::string path, GLenum type) {
|
||||||
if(success != 1) {
|
if(success != 1) {
|
||||||
char infoLog[256];
|
char infoLog[256];
|
||||||
glGetShaderInfoLog(shader, 512, NULL, infoLog);
|
glGetShaderInfoLog(shader, 512, NULL, infoLog);
|
||||||
printf("Fragment shader %s failed to compile: [%d]: %s\n", path.c_str(), success, infoLog);
|
Logger::fatalErrorf("Fragment shader %s failed to compile: [%d]: %s", path.c_str(), success, infoLog);
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,7 +47,7 @@ Shader::Shader(std::string vertexShaderPath, std::string fragmentShaderPath) {
|
||||||
if(success != 1) {
|
if(success != 1) {
|
||||||
char infoLog[256];
|
char infoLog[256];
|
||||||
glGetShaderInfoLog(fragmentShader, 512, NULL, infoLog);
|
glGetShaderInfoLog(fragmentShader, 512, NULL, infoLog);
|
||||||
printf("Shader program failed to link: [%d]: %s\n", success, infoLog);
|
Logger::fatalErrorf("Shader program failed to link: [%d]: %s", success, infoLog);
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#include <GL/gl.h>
|
#include <GL/gl.h>
|
||||||
#include <stb_image.h>
|
#include <stb_image.h>
|
||||||
|
|
||||||
|
#include "logger.h"
|
||||||
#include "skybox.h"
|
#include "skybox.h"
|
||||||
|
|
||||||
Skybox::Skybox(std::array<std::string, 6> faces, unsigned int format) {
|
Skybox::Skybox(std::array<std::string, 6> faces, unsigned int format) {
|
||||||
|
@ -15,7 +16,7 @@ Skybox::Skybox(std::array<std::string, 6> faces, unsigned int format) {
|
||||||
&nrChannels, 0);
|
&nrChannels, 0);
|
||||||
|
|
||||||
if (!data) {
|
if (!data) {
|
||||||
printf("Failed to load texture '%s'\n", faces[i].c_str());
|
Logger::fatalErrorf("Failed to load texture '%s'", faces[i].c_str());
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,8 @@
|
||||||
#include <GL/gl.h>
|
#include <GL/gl.h>
|
||||||
#include <stb_image.h>
|
#include <stb_image.h>
|
||||||
|
|
||||||
|
#include "logger.h"
|
||||||
|
|
||||||
Texture::Texture(const char* texturePath, unsigned int format, bool noMipMaps) {
|
Texture::Texture(const char* texturePath, unsigned int format, bool noMipMaps) {
|
||||||
glGenTextures(1, &this->ID);
|
glGenTextures(1, &this->ID);
|
||||||
glBindTexture(GL_TEXTURE_2D, this->ID);
|
glBindTexture(GL_TEXTURE_2D, this->ID);
|
||||||
|
@ -22,7 +24,7 @@ Texture::Texture(const char* texturePath, unsigned int format, bool noMipMaps) {
|
||||||
&nrChannels, 0);
|
&nrChannels, 0);
|
||||||
|
|
||||||
if (!data) {
|
if (!data) {
|
||||||
printf("Failed to load texture '%s'\n", texturePath);
|
Logger::fatalErrorf("Failed to load texture '%s'", texturePath);
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,8 @@
|
||||||
#include <GL/gl.h>
|
#include <GL/gl.h>
|
||||||
#include <stb_image.h>
|
#include <stb_image.h>
|
||||||
|
|
||||||
|
#include "logger.h"
|
||||||
|
|
||||||
Texture3D::Texture3D(const char* texturePath, unsigned int tileWidth, unsigned int tileHeight, unsigned int tileCount, unsigned int format) {
|
Texture3D::Texture3D(const char* texturePath, unsigned int tileWidth, unsigned int tileHeight, unsigned int tileCount, unsigned int format) {
|
||||||
glGenTextures(1, &this->ID);
|
glGenTextures(1, &this->ID);
|
||||||
glBindTexture(GL_TEXTURE_2D_ARRAY, this->ID);
|
glBindTexture(GL_TEXTURE_2D_ARRAY, this->ID);
|
||||||
|
@ -23,7 +25,7 @@ Texture3D::Texture3D(const char* texturePath, unsigned int tileWidth, unsigned i
|
||||||
&nrChannels, 0);
|
&nrChannels, 0);
|
||||||
|
|
||||||
if (!data) {
|
if (!data) {
|
||||||
printf("Failed to load texture '%s'\n", texturePath);
|
Logger::fatalErrorf("Failed to load texture '%s'", texturePath);
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,20 +1,22 @@
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
|
|
||||||
|
#include "logger.h"
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QLocale>
|
#include <QLocale>
|
||||||
#include <QTranslator>
|
#include <QTranslator>
|
||||||
#include <QStyleFactory>
|
#include <QStyleFactory>
|
||||||
#include <QBasicTimer>
|
#include <QBasicTimer>
|
||||||
|
|
||||||
#include "physics/simulation.h"
|
|
||||||
#include "qcoreevent.h"
|
|
||||||
#include "qobject.h"
|
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
QApplication a(argc, argv);
|
QApplication a(argc, argv);
|
||||||
|
|
||||||
|
Logger::init();
|
||||||
|
|
||||||
MainWindow w;
|
MainWindow w;
|
||||||
w.show();
|
w.show();
|
||||||
return a.exec();
|
int result = a.exec();
|
||||||
|
|
||||||
|
Logger::finish();
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
#include "qwidget.h"
|
#include "qwidget.h"
|
||||||
#include "qmimedata.h"
|
#include "qmimedata.h"
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
#include "logger.h"
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <optional>
|
#include <optional>
|
||||||
|
@ -163,10 +164,10 @@ bool ExplorerModel::moveRows(const QModelIndex &sourceParentIdx, int sourceRow,
|
||||||
Instance* sourceParent = sourceParentIdx.isValid() ? static_cast<Instance*>(sourceParentIdx.internalPointer()) : rootItem.get();
|
Instance* sourceParent = sourceParentIdx.isValid() ? static_cast<Instance*>(sourceParentIdx.internalPointer()) : rootItem.get();
|
||||||
Instance* destinationParent = destinationParentIdx.isValid() ? static_cast<Instance*>(destinationParentIdx.internalPointer()) : rootItem.get();
|
Instance* destinationParent = destinationParentIdx.isValid() ? static_cast<Instance*>(destinationParentIdx.internalPointer()) : rootItem.get();
|
||||||
|
|
||||||
printf("Moved %d from %s\n", count, sourceParent->name.c_str());
|
Logger::infof("Moved %d from %s", count, sourceParent->name.c_str());
|
||||||
|
|
||||||
if ((sourceRow + count) >= sourceParent->GetChildren().size()) {
|
if ((sourceRow + count) >= sourceParent->GetChildren().size()) {
|
||||||
fprintf(stderr, "Attempt to move rows %d-%d from %s (%s) while it only has %zu children.\n", sourceRow, sourceRow + count, sourceParent->name.c_str(), sourceParent->GetClass()->className.c_str(), sourceParent->GetChildren().size());
|
Logger::fatalErrorf("Attempt to move rows %d-%d from %s (%s) while it only has %zu children.", sourceRow, sourceRow + count, sourceParent->name.c_str(), sourceParent->GetClass()->className.c_str(), sourceParent->GetChildren().size());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue