-
Notifications
You must be signed in to change notification settings - Fork 71
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
Copy-pasting between multiple instances of MidiEditor #102
base: master
Are you sure you want to change the base?
Conversation
spamming user clipboard with base64 string
Fixed tempo not being preseved across windows |
@@ -37,6 +37,7 @@ | |||
#include "math.h" | |||
|
|||
#include <QtCore/qmath.h> | |||
#include <iostream> |
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.
classes and functions ain't used anywhere in that file
channels[i] = new MidiChannel(this, i); | ||
} | ||
|
||
QDataStream* stream = new QDataStream(raw_midi); |
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 can add constructor from QDataStream to avoid code duplication
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 agree. There was already some duplication present before. Would probably make sense to fix all of this at once.
MidiFile(QString path, bool* ok, QStringList* log = 0); | ||
MidiFile(); | ||
// needed to protocol fileLength | ||
MidiFile(int maxTime, Protocol* p); | ||
bool save(QString path); | ||
QByteArray writeDeltaTime(int time); | ||
QByteArray toByteArray(); | ||
static QByteArray writeDeltaTime(int 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.
It really should be static?
|
||
if (copiedEvents->size() == 0) { | ||
if(!ok){ |
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.
Fine... But how it can be false? Okay...
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.
Probably should never be false, but since the MidiFile constructor already has a check-mechanism, why not use it
|
||
QByteArray copyFileBytes = copyFile.toByteArray(); | ||
int MAX_COPY_SIZE = 1073741824; //1GB | ||
if (copyFileBytes.size() > MAX_COPY_SIZE){ |
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.
Why do we have any MAX_COPY_SIZE? Is it a restriction of QSharedMemory or something?
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 create buffer of some size, so we should set some size, MAX_COPY_SIZE in our case.
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 size of QSharedMemory needs to be specified before allocation, as far as i know. One can of course argue about what this size should be...
This would be a very cool feature to merge! |
This is currently not possible as copied events are simply stored in a variable of each instance of MidiEditor.
I added this feature by converting the selected events into a
MidiFile
object and saving this inQSharedMemory
.When pasting, the reverse happens. See the commit message and the subsequent comment for more details.
This would resolve #84.