-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
egm supp #138
egm supp #138
Conversation
if (!EnigmaRoot.filePath().isEmpty()) { | ||
_event_data = std::make_unique<EventData>(ParseEventFile((EnigmaRoot.absolutePath() + "/events.ey").toStdString())); | ||
} else { | ||
qDebug() << "Error: Failed to locate ENIGMA sources. Loading internal events.ey.\n" << "Search Paths:\n" << MainWindow::EnigmaSearchPaths; | ||
QFile internal_events(":/events.ey"); | ||
internal_events.open(QIODevice::ReadOnly | QFile::Text); | ||
std::stringstream ss; | ||
ss << internal_events.readAll().toStdString(); | ||
_event_data = std::make_unique<EventData>(ParseEventFile(ss)); | ||
} | ||
|
||
egm = egm::EGM(_event_data.get()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A lot of this should probably go into its own project handling class, like Josh had me do for recent files. Jamming everything into the main window class is not a good, we want to design this with loose coupling of components, something that signals and slots help accomplish.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds like a task for another day.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is new code, all new code should be written correctly the first time. I did it correctly with recent files the first time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is just the first draft to make it work/build against enigma. As long as you hold up this pr over nonsense design choices the enigma CI remains broken. This pr was meant to be merged the same time as the enigma side one. You can refactor it later but it needs to go in now.
@@ -155,7 +188,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), _ui(new Ui::MainW | |||
openNewProject(); | |||
} | |||
|
|||
MainWindow::~MainWindow() { delete _ui; } | |||
MainWindow::~MainWindow() { diagnosticTextEdit = nullptr; delete _ui; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't necessary it uses the Qt ownership mechanism (its parent is specified in the constructor). This is C++, not C, we're not concerned about zero'ing out our pointers. Remove this, it's not idiomatic Qt or C++ at all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The editor segfaults on close without this. You're referencing another pointer so it's never cleared.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's the signals queueing messages, something else is wrong, this is only a bandaid. The correct fix is to disconnect the output/log signals so it stops trying to reference that after it's gone.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it also correct to null the pointer
@@ -302,7 +337,7 @@ void MainWindow::openFile(QString fName) { | |||
|
|||
MainWindow::setWindowTitle(fileInfo.fileName() + " - ENIGMA"); | |||
_recentFiles->prependFile(fName); | |||
openProject(std::unique_ptr<buffers::Project>(loadedProject)); | |||
openProject(std::move(loadedProject)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should document somewhere, maybe in the header, that openProject
takes ownership of the buffer.
|
||
void openSubWindow(buffers::TreeNode *item); | ||
void readSettings(); | ||
void writeSettings(); | ||
void setTabbedMode(bool enabled); | ||
static QFileInfo getEnigmaRoot(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a horrible function name, also add comments to clarify what it does.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It gets the root of enigma :/ I dunno what else you'd name it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ENIGMA root could be anything, is my point, it could be interpreted as meaning the protobuf/tree root or etc. Probably GetEnigmaFileSystemRoot
would be miles better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
none of the things you listed are enigma
std::unique_ptr<buffers::Project> _project; | ||
QPointer<RecentFiles> _recentFiles; | ||
|
||
std::unique_ptr<EventData> _event_data; | ||
egm::EGM egm; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move all of this stuff to the private section.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is in private....
@@ -100,5 +100,6 @@ | |||
<file alias="banner.png">Images/banner.png</file> | |||
<file alias="icon.ico">Images/icon.ico</file> | |||
<file alias="transparent.png">Images/transparent.png</file> | |||
<file alias="events.ey">Submodules/enigma-dev/events.ey</file> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should rename images.qrc or create a separate resources.qrc because the user will later replace icon packs dynamically. We don't want them to have to put events.ey
into their icon pack.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, I was going to rename this file but didn't care to do it here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really wouldn't put it in with the images.
https://doc.qt.io/qt-5/resources.html#external-binary-resources
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), _ui(new Ui::MainWindow), _event_data(nullptr), egm(nullptr) { | ||
|
||
if (!EnigmaRoot.filePath().isEmpty()) { | ||
_event_data = std::make_unique<EventData>(ParseEventFile((EnigmaRoot.absolutePath() + "/events.ey").toStdString())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ask @JoshDreamland why ParseEventFile
doesn't just return a unique_ptr
for me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
EventData should be an object not a pointer but because it doesn't have a default constructor I need to conditionally initialize it with different constructors by making it a pointer.
RadialGM.pro
Outdated
@@ -178,4 +178,5 @@ FORMS += \ | |||
RESOURCES += \ | |||
images.qrc | |||
|
|||
DISTFILES += | |||
DISTFILES += \ | |||
Submodules/enigma-dev/events.ey |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know if this was necessary, the documentation says it only works on Unix, and you've already put it in the resources file.
https://stackoverflow.com/a/38102991
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
qtcreator did this not me
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hrm idk then.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok start but this needs cleaned up more.
enigma-dev/enigma-dev#2089