api 호출을 테스트하기 위해 약간의 http 클라이언트를 작성하고 있습니다. 이것은 vala를 배우고 gtk3을 사용하는 경우입니다.개체 인스턴스 및 vala의 신호 처리기로 세분화 오류가 발생했습니다.
나는 gtk 인터페이스와 http 요청을 다루는 클래스를 만들었다.
using GLib;
using Gtk;
public class RequestHandler : Object
{
public string uri { get; private set; default = ""; }
// Constructor
public RequestHandler()
{
}
[CCode (instance_pos = -1)]
public void on_url_changed (Entry entry, Button button)
{
stderr.printf ("this#%p\n", this);
if (entry.get_text_length() == 0)
{
button.set_sensitive (false);
this.uri = "";
}
else
{
button.set_sensitive (true);
this.uri = entry.get_text();
}
}
[CCode (instance_pos = -1)]
public void on_send_clicked (Button button)
{
assert (this.uri != null);
stderr.printf ("Send request to : %s\n", this.uri);
}
}
라인
stderr.printf ("this#%p\n", this);
// => fprintf (_tmp0_, "this#%p\n", self); in the C file
표시 할 때마다 "이 # 0x1로"프로그램이 라인에서 세그먼트 오류와 함께 실패
this.uri = entry.get_text();
// _g_free0 (self->priv->_uri); in the C file
UI는
var builder = new Builder();
builder.add_from_file (UI_FILE);
var signals_handler = new RequestHandler();
builder.connect_signals (signals_handler);
빌드입니다
저는 정말 신비예요. e in vala와 나는 나의 실수를 보지 않는다.
[편집]
...
<object class="GtkEntry" id="entry2">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="hexpand">True</property>
<property name="invisible_char">●</property>
<property name="input_purpose">url</property>
<signal name="changed" handler="request_handler_on_url_changed" object="button1" swapped="no"/>
</object>
...
인터페이스 잎이 완전히 생성된다.
ui 파일을 게시하십시오 ... 저는 특히 당신이 on_url_Changed에 연결하려는 신호에 관심이 있습니다. – nemequ
관련 객체와 관련된 UI 파일 부분을 추가했습니다. 이제 porterty를 static으로 변경했습니다. –