Skip to content
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

Merged
merged 7 commits into from
Aug 7, 2020
Merged

egm supp #138

merged 7 commits into from
Aug 7, 2020

Conversation

fundies
Copy link
Contributor

@fundies fundies commented Jul 25, 2020

@fundies fundies requested a review from RobertBColton August 5, 2020 11:50
Comment on lines +105 to +116
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());
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

@RobertBColton RobertBColton Aug 5, 2020

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.

Copy link
Contributor Author

@fundies fundies Aug 7, 2020

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; }
Copy link
Contributor

@RobertBColton RobertBColton Aug 5, 2020

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.

https://doc.qt.io/qt-5/objecttrees.html

Copy link
Contributor Author

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.

Copy link
Contributor

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.

Copy link
Contributor Author

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));
Copy link
Contributor

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();
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

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.

Copy link
Contributor Author

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

Comment on lines 115 to +119
std::unique_ptr<buffers::Project> _project;
QPointer<RecentFiles> _recentFiles;

std::unique_ptr<EventData> _event_data;
egm::EGM egm;
Copy link
Contributor

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.

Copy link
Contributor Author

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>
Copy link
Contributor

@RobertBColton RobertBColton Aug 5, 2020

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.

Copy link
Contributor Author

@fundies fundies Aug 5, 2020

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

Copy link
Contributor

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()));
Copy link
Contributor

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.

Copy link
Contributor Author

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
Copy link
Contributor

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

Copy link
Contributor Author

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

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hrm idk then.

Copy link
Contributor

@RobertBColton RobertBColton left a 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.

@RobertBColton RobertBColton merged commit 79a68a7 into master Aug 7, 2020
@RobertBColton RobertBColton deleted the egm-supp branch August 7, 2020 23:31
@RobertBColton RobertBColton mentioned this pull request Aug 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants