简体   繁体   English

如何释放物体? [Java-GNOME]

[英]How to release objects? [Java-GNOME]

how do i release objects in java-gnome library? 如何在java-gnome库中释放对象? first, i give an example... 首先,我举个例子...

package gui;

import org.gnome.gdk.Event;
import org.gnome.gtk.Button;
import org.gnome.gtk.Widget;
import org.gnome.gtk.Window;

public class A extends Window implements Window.DeleteEvent
{
    private Button b;

    public A()
    {
        this.b = new Button();
    }

    public boolean onDeleteEvent(Widget w, Event e)
    {
        this.b.destroy();
        this.destroy();
        this.release();
        return false;
    }
}

should i use destroy and release functions like i do at this code? 我应该像在此代码中那样使用销毁和释放功能吗? how to i finally release the objects? 我如何最终释放对象?

java-gnome api website: http://java-gnome.sourceforge.net/4.0/doc/api/index.html?org/gnome/pango/package-summary.html java-gnome api网站: http : //java-gnome.sourceforge.net/4.0/doc/api/index.html?org /gnome/pango/ package - summary.html

its free open source, if u can check it for me: http://ftp.gnome.org/pub/gnome/sources/java-gnome/4.0/ 它的免费开放源代码,如果您可以为我检查的话: http : //ftp.gnome.org/pub/gnome/sources/java-gnome/4.0/

download the file: "java-gnome-4.0.19.tar.gz" thanks for help :) 下载文件:“ java-gnome-4.0.19.tar.gz”谢谢您的帮助:)

Based on this link: http://java-gnome.sourceforge.net/doc/api/4.1/org/gnome/gtk/Widget.html#destroy%28%29 基于此链接: http : //java-gnome.sourceforge.net/doc/api/4.1/org/gnome/gtk/Widget.html#destroy%28%29

It seems it will. 看来会的。 Of course, like the text in italics says, it may not remove all references to the object in java just the GObject system. 当然,就像斜体文字所示,它可能不会删除GObject系统中所有对Java对象的引用。 But otherwise, this looks correct. 但是否则,这看起来是正确的。 Once your reference to this goes out of scope, it should be completely dereferenced, along with all children you may have skipped. 一旦您对此的引用超出范围,则应将其与您可能已跳过的所有子项完全取消引用。

I would also recommend if you are destroying a window with lots of children, and you plan on destroying every single one of them, call this.hide() as your first step in the onDeleteEvent. 我还建议您,如果要破坏一个有很多子项的窗口,并且打算破坏每个子项,请在onDeleteEvent中将this.hide()作为第一步。 See: http://java-gnome.sourceforge.net/doc/api/4.1/org/gnome/gtk/Window.html 请参阅: http : //java-gnome.sourceforge.net/doc/api/4.1/org/gnome/gtk/Window.html

After reading through the docs looking for release() , I couldn't find it listed anywhere but in org.gnome.glib.Object, but there are not any actual direct methods from Object. 阅读了寻找release()的文档之后,我找不到它在org.gnome.glib.Object中列出的任何地方,但是Object没有任何实际的直接方法。 I would recommend against using it. 我建议不要使用它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM