나는 vala 클래스에서이 문제를 다루는 데 거의 문제가 없습니다. 여기 이 이해할 수없는 동작이
내 코드입니다 : (build_and_send1 및 build_and_send2는 신호 버튼을 눌러 제기되는)using GLib;
using Gtk;
public class Main : Object
{
/*
* Uncomment this line when you are done testing and building a tarball
* or installing
*/
//const string UI_FILE = Config.PACKAGE_DATA_DIR + "/" + "gtk_httpclient.ui";
const string UI_FILE = "src/gtk_httpclient.ui";
/* ANJUTA: Widgets declaration for gtk_httpclient.ui - DO NOT REMOVE */
private Builder builder;
public Main()
{
try
{
this.builder = new Builder();
this.builder.add_from_file (UI_FILE);
this.builder.connect_signals (this);
var window = this.builder.get_object ("window") as Window;
/* ANJUTA: Widgets initialization for gtk_httpclient.ui - DO NOT REMOVE */
window.show_all();
stderr.printf ("constructor:\n");
stderr.printf ("this: %p\n", this);
stderr.printf ("builder: %p\n", this.builder);
}
catch (Error e) {
stderr.printf ("Could not load UI: %s\n", e.message);
}
}
[CCode (instance_pos = -1)]
public void on_destroy (Widget window)
{
Gtk.main_quit();
}
public void build_and_send1 (Widget button)
{
stderr.printf ("\nbuild_and_send1:\n");
stderr.printf ("this: %p\n", this);
stderr.printf ("builder: %p\n", this.builder);
}
[CCode (instance_pos = -1)]
public void build_and_send2 (Widget button)
{
stderr.printf ("\nbuild_and_send2:\n");
stderr.printf ("this: %p\n", this);
stderr.printf ("builder: %p\n", this.builder);
}
static int main (string[] args)
{
Gtk.init (ref args);
new Main();
Gtk.main();
return 0;
}
}
내가이 출력있어 :
constructor:
this: 0x1a524a0
builder: 0x1a6a230
build_and_send1:
this: 0x1aa2030
builder: 0x5a4fe823
build_and_send2:
this: 0x1a524a0
Program has been terminated receiving signal 11 (Segmentation fault)
가 나는 같은하려는 경우 가정을 내 신호의 Main 인스턴스는 [CCode (instance_pos = -1)] 앞에 와야합니다. 그렇다면 의 목표는 무엇입니까? builder.connect_signals (this);?
그리고 this.builder는 build_and_send2 아닌 생성자에서의 세그먼트 오류를 제기하는 이유?
나는 Anjuta 3.6.2와 Glade 3.14.2 –