Skip to content

Commit 8d7adfe

Browse files
committed
fix base not being set on OS X; tweaking single instance use
1 parent cd4b341 commit 8d7adfe

File tree

6 files changed

+52
-39
lines changed

6 files changed

+52
-39
lines changed

app/src/processing/app/Base.java

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -162,37 +162,36 @@ static private void createAndShowGUI(String[] args) {
162162
Preferences.init(null);
163163

164164
// String filename = args.length > 1 ? args[0] : null;
165-
if (SingleInstance.exists(args)) {
166-
return;
167-
}
168-
SingleInstance.createServer(platform);
165+
if (!SingleInstance.exists(args)) {
166+
SingleInstance.createServer(platform);
169167

170-
// Set the look and feel before opening the window
171-
try {
172-
platform.setLookAndFeel();
173-
} catch (Exception e) {
174-
String mess = e.getMessage();
175-
if (mess.indexOf("ch.randelshofer.quaqua.QuaquaLookAndFeel") == -1) {
176-
System.err.println("Non-fatal error while setting the Look & Feel.");
177-
System.err.println("The error message follows, however Processing should run fine.");
178-
System.err.println(mess);
168+
// Set the look and feel before opening the window
169+
try {
170+
platform.setLookAndFeel();
171+
} catch (Exception e) {
172+
String mess = e.getMessage();
173+
if (mess.indexOf("ch.randelshofer.quaqua.QuaquaLookAndFeel") == -1) {
174+
System.err.println("Non-fatal error while setting the Look & Feel.");
175+
System.err.println("The error message follows, however Processing should run fine.");
176+
System.err.println(mess);
177+
}
179178
}
180-
}
181179

182-
// Create a location for untitled sketches
183-
try {
184-
untitledFolder = Base.createTempFolder("untitled", "sketches");
185-
untitledFolder.deleteOnExit();
186-
} catch (IOException e) {
187-
//e.printStackTrace();
188-
Base.showError("Trouble without a name",
189-
"Could not create a place to store untitled sketches.\n" +
190-
"That's gonna prevent us from continuing.", e);
191-
}
180+
// Create a location for untitled sketches
181+
try {
182+
untitledFolder = Base.createTempFolder("untitled", "sketches");
183+
untitledFolder.deleteOnExit();
184+
} catch (IOException e) {
185+
//e.printStackTrace();
186+
Base.showError("Trouble without a name",
187+
"Could not create a place to store untitled sketches.\n" +
188+
"That's gonna prevent us from continuing.", e);
189+
}
192190

193191
// System.out.println("about to create base...");
194-
new Base(args);
192+
new Base(args);
195193
// System.out.println("done creating base...");
194+
}
196195
}
197196

198197

app/src/processing/app/SingleInstance.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,27 +71,38 @@ public void run() {
7171
Socket s = ss.accept(); // blocks (sleeps) until connection
7272
final BufferedReader reader = PApplet.createReader(s.getInputStream());
7373
String receivedKey = reader.readLine();
74+
if (Base.DEBUG) {
75+
System.out.println("key is " + key + ", received is " + receivedKey);
76+
System.out.println("platform base is " + platform.base);
77+
System.out.flush();
78+
}
7479

7580
if (platform.base != null) {
7681
if (key.equals(receivedKey)) {
7782
SwingUtilities.invokeLater(new Runnable() {
7883
public void run() {
7984
try {
85+
if (Base.DEBUG) System.out.println("about to read line");
8086
String filename = reader.readLine();
8187
if (filename != null) {
88+
if (Base.DEBUG) System.out.println("calling open with " + filename);
8289
platform.base.handleOpen(filename);
8390
// see if there is more than one file that was passed in
8491
while ((filename = reader.readLine()) != null) {
92+
if (Base.DEBUG) System.out.println("continuing to call open with " + filename);
8593
platform.base.handleOpen(filename);
8694
}
8795
} else {
96+
if (Base.DEBUG) System.out.println("opening new empty sketch");
8897
platform.base.handleNew();
8998
}
9099
} catch (IOException e) {
91100
e.printStackTrace();
92101
}
93102
}
94103
});
104+
} else {
105+
if (Base.DEBUG) System.out.println("keys do not match");
95106
}
96107
}
97108
} catch (IOException e) {

app/src/processing/app/macosx/Platform.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ public void setLookAndFeel() throws Exception {
5151

5252

5353
public void init(Base base) {
54+
super.init(base);
5455
System.setProperty("apple.laf.useScreenMenuBar", "true");
5556
ThinkDifferent.init(base);
5657
/*

app/src/processing/app/windows/Platform.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ public class Platform extends processing.app.Platform {
5454

5555
public void init(Base base) {
5656
super.init(base);
57-
5857
checkAssociations();
5958
//checkQuickTime();
6059
checkPath();

core/todo.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ o along with 90, 180 and 270 versions of it as well
2222
o tie to glDrawPixels.. how to clear matrix properly for that?
2323
X maybe just disable this for JAVA2D cuz it's silly?
2424

25+
_ add() to add things to lists, sum() for the math (sum is used less after all)
2526

2627
_ consider using BufferStrategy to improve performance
2728
_ there are more improvements to be made ala issue #729

todo.txt

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@ X update to Java 6u29 for Linux and Windows (OS X now updated)
77
X don't show library conflict warning until someone tries to build
88
X with code that actually calls on one of those packages
99
X too many people seem to think this is an error
10-
_ work on code to quit if multiple instances are running
11-
_ need to bring the other instance to front
12-
_ and/or open a new window
10+
X work on code to quit if multiple instances are running
11+
X need to bring the other instance to front
12+
X and/or open a new window
13+
X fix bug with 'base' not getting set in the Mac OS X platform class
1314

1415
fixed in 2.0a3
1516
X Commenting via menu or shortcut does not set sketch to "need save"
@@ -27,16 +28,7 @@ X write quicktime uncompressed (w/o qtjava)
2728
X wrapped into the new moviemaker tool
2829
X http://www.randelshofer.ch/blog/2010/10/writing-quicktime-movies-in-pure-java/
2930

30-
31-
_ move Movie Maker out to its own separate tool package (with separate build)
32-
_ http://code.google.com/p/processing/issues/detail?id=837
33-
34-
_ bad tool brings down the environment
35-
_ http://code.google.com/p/processing/issues/detail?id=798
36-
37-
_ --bgcolor shouldn't be in main() unless 'present' is turned on
38-
_ also add option for FSEM or not
39-
31+
maybe fixed
4032
_ library imports failing for libs that define the same packages in 1.5.1
4133
_ http://code.google.com/p/processing/issues/detail?id=725
4234

@@ -49,6 +41,16 @@ http://code.google.com/p/processing/issues/detail?id=545
4941
recent sketches:
5042
http://code.google.com/p/processing/issues/detail?id=188
5143

44+
45+
_ move Movie Maker out to its own separate tool package (with separate build)
46+
_ http://code.google.com/p/processing/issues/detail?id=837
47+
48+
_ bad tool brings down the environment
49+
_ http://code.google.com/p/processing/issues/detail?id=798
50+
51+
_ --bgcolor shouldn't be in main() unless 'present' is turned on
52+
_ also add option for FSEM or not
53+
5254
_ update the build instructions page
5355
_ http://code.google.com/p/processing/wiki/BuildInstructions
5456
_ sketch.isReadOnly returns false for examples coming from multiple modes

0 commit comments

Comments
 (0)