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 {
var mouseY = 0
val window = SkiaWindow()
window.defaultCloseOperation = WindowConstants.EXIT_ON_CLOSE
window.defaultCloseOperation = WindowConstants.DISPOSE_ON_CLOSE
window.title = title
// 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 {
fun SwingSkia() = SwingUtilities.invokeLater {
val window = JFrame()
window.defaultCloseOperation = WindowConstants.EXIT_ON_CLOSE
window.defaultCloseOperation = WindowConstants.DISPOSE_ON_CLOSE
window.title = "SwingSkiaWindow"
val panel = SkiaPanel()
......
......@@ -61,8 +61,6 @@
@end
NSMutableArray *unknownWindows = nil;
NSMutableSet *layerStorage = nil;
LayerHandler * findByObject(JNIEnv *env, jobject object)
......@@ -120,33 +118,21 @@ JNIEXPORT void JNICALL Java_org_jetbrains_skiko_HardwareLayer_init(JNIEnv *env,
jobject canvasGlobalRef = (*env)->NewGlobalRef(env, canvas);
[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]];
for (LayerHandler* value in layerStorage)
{
NSMutableArray<NSWindow *> *windows = [NSMutableArray arrayWithArray: [[NSApplication sharedApplication] windows]];
for (NSWindow* value in unknownWindows)
{
[windows removeObject: value];
}
for (LayerHandler* value in layerStorage)
if (layersSet.container == value.container)
{
if (layersSet.container == value.container)
{
layersSet.window = value.window;
}
}
if (layersSet.window == NULL)
{
layersSet.window = [windows lastObject];
layersSet.window = value.window;
}
}
if (layersSet.window == NULL)
{
layersSet.window = [windows lastObject];
}
[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