Skip to content

Commit

Permalink
Merge pull request #484 from daniellasry/fix_launch_crash
Browse files Browse the repository at this point in the history
FIX: crash on launch
  • Loading branch information
daniellasry authored Apr 16, 2019
2 parents 6bfc976 + a678d24 commit a5cb27a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
6 changes: 3 additions & 3 deletions OpenBCI_GUI/Interactivity.pde
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
//------------------------------------------------------------------------

//interpret a keypress...the key pressed comes in as "key"
void keyPressed() {
synchronized void keyPressed() {
// don't allow key presses until setup is complete and the UI is initialized
if (!setupComplete) {
return;
Expand Down Expand Up @@ -441,7 +441,7 @@ void mouseDragged() {
}
}
//switch yard if a click is detected
void mousePressed() {
synchronized void mousePressed() {
// don't allow mouse clicks until setup is complete and the UI is initialized
if (!setupComplete) {
return;
Expand Down Expand Up @@ -486,7 +486,7 @@ void mousePressed() {
redrawScreenNow = true; //command a redraw of the GUI whenever the mouse is pressed
}

void mouseReleased() {
synchronized void mouseReleased() {
// don't allow mouse clicks until setup is complete and the UI is initialized
if (!setupComplete) {
return;
Expand Down
12 changes: 5 additions & 7 deletions OpenBCI_GUI/OpenBCI_GUI.pde
Original file line number Diff line number Diff line change
Expand Up @@ -392,13 +392,6 @@ void delayedSetup() {
//setup topNav
topNav = new TopNav();

//from the user's perspective, the program hangs out on the ControlPanel until the user presses "Start System".
print("Graphics & GUI Library: ");
controlPanel = new ControlPanel(this);
//The effect of "Start System" is that initSystem() gets called, which starts up the connection to the OpenBCI
//hardware (via the "updateSyncState()" process) as well as initializing the rest of the GUI elements.
//Once the hardware is synchronized, the main GUI is drawn and the user switches over to the main GUI.

logo_blue = loadImage("logo_blue.png");
logo_white = loadImage("logo_white.png");
cog = loadImage("cog_1024x1024.png");
Expand Down Expand Up @@ -428,6 +421,11 @@ void delayedSetup() {
println("OpenBCI_GUI::Setup: Has RX joined multicast: "+udpRX.isJoined());

synchronized(this) {
// Instantiate ControlPanel in the synchronized block.
// It's important to avoid instantiating a ControlP5 during a draw() call
// Otherwise we get a crash on launch 10% of the time
controlPanel = new ControlPanel(this);

setupComplete = true; // signal that the setup thread has finished
}
}
Expand Down

0 comments on commit a5cb27a

Please sign in to comment.