Commit 52efd986 authored by Igor Demin's avatar Igor Demin

Fix crash in tests (remove unnecessary unknownWindows)

parent d56864e2
...@@ -25,7 +25,7 @@ fun createWindow(title: String) = SwingUtilities.invokeLater { ...@@ -25,7 +25,7 @@ fun createWindow(title: String) = SwingUtilities.invokeLater {
var mouseY = 0 var mouseY = 0
val window = SkiaWindow() val window = SkiaWindow()
window.defaultCloseOperation = WindowConstants.EXIT_ON_CLOSE window.defaultCloseOperation = WindowConstants.DISPOSE_ON_CLOSE
window.title = title window.title = title
// Create menu. // Create menu.
......
package SkijaInjectSample
import java.awt.BorderLayout
import javax.swing.JFrame
import javax.swing.WindowConstants
fun pureSwing() {
val window = JFrame()
window.defaultCloseOperation = WindowConstants.DISPOSE_ON_CLOSE
window.setSize(800, 600)
window.contentPane.add(Button("Skiko").apply {
addActionListener {
createWindow("Skiko")
}
}, BorderLayout.NORTH)
window.contentPane.add(Button("Swing").apply {
addActionListener {
pureSwing()
}
}, BorderLayout.WEST)
window.contentPane.add(Button("Swing+Skiko").apply {
addActionListener {
SwingSkia()
}
}, BorderLayout.EAST)
window.setVisible(true)
}
\ No newline at end of file
...@@ -19,7 +19,7 @@ fun Button(text: String): JButton { ...@@ -19,7 +19,7 @@ fun Button(text: String): JButton {
fun SwingSkia() = SwingUtilities.invokeLater { fun SwingSkia() = SwingUtilities.invokeLater {
val window = JFrame() val window = JFrame()
window.defaultCloseOperation = WindowConstants.EXIT_ON_CLOSE window.defaultCloseOperation = WindowConstants.DISPOSE_ON_CLOSE
window.title = "SwingSkiaWindow" window.title = "SwingSkiaWindow"
val panel = SkiaPanel() val panel = SkiaPanel()
......
...@@ -61,8 +61,6 @@ ...@@ -61,8 +61,6 @@
@end @end
NSMutableArray *unknownWindows = nil;
NSMutableSet *layerStorage = nil; NSMutableSet *layerStorage = nil;
LayerHandler * findByObject(JNIEnv *env, jobject object) LayerHandler * findByObject(JNIEnv *env, jobject object)
...@@ -120,20 +118,8 @@ JNIEXPORT void JNICALL Java_org_jetbrains_skiko_HardwareLayer_init(JNIEnv *env, ...@@ -120,20 +118,8 @@ JNIEXPORT void JNICALL Java_org_jetbrains_skiko_HardwareLayer_init(JNIEnv *env,
jobject canvasGlobalRef = (*env)->NewGlobalRef(env, canvas); jobject canvasGlobalRef = (*env)->NewGlobalRef(env, canvas);
[layersSet setCanvasGlobalRef: canvasGlobalRef]; [layersSet setCanvasGlobalRef: canvasGlobalRef];
if (unknownWindows == nil)
{
NSMutableArray<NSWindow *> *windows = [NSMutableArray arrayWithArray: [[NSApplication sharedApplication] windows]];
layersSet.window = [windows lastObject];
[windows removeObject: layersSet.window];
unknownWindows = windows;
}
else
{
NSMutableArray<NSWindow *> *windows = [NSMutableArray arrayWithArray: [[NSApplication sharedApplication] windows]]; NSMutableArray<NSWindow *> *windows = [NSMutableArray arrayWithArray: [[NSApplication sharedApplication] windows]];
for (NSWindow* value in unknownWindows)
{
[windows removeObject: value];
}
for (LayerHandler* value in layerStorage) for (LayerHandler* value in layerStorage)
{ {
if (layersSet.container == value.container) if (layersSet.container == value.container)
...@@ -141,11 +127,11 @@ JNIEXPORT void JNICALL Java_org_jetbrains_skiko_HardwareLayer_init(JNIEnv *env, ...@@ -141,11 +127,11 @@ JNIEXPORT void JNICALL Java_org_jetbrains_skiko_HardwareLayer_init(JNIEnv *env,
layersSet.window = value.window; layersSet.window = value.window;
} }
} }
if (layersSet.window == NULL) if (layersSet.window == NULL)
{ {
layersSet.window = [windows lastObject]; layersSet.window = [windows lastObject];
} }
}
[layerStorage addObject: layersSet]; [layerStorage addObject: layersSet];
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment