Skip to content

Commit

Permalink
Fix the failing imports
Browse files Browse the repository at this point in the history
Make the service widget initialization lazy as it requires
the "dhcp-server" package which is installed later in the workflow.
  • Loading branch information
lslezak committed Jan 18, 2017
1 parent bbc1d92 commit d2c3a86
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 10 deletions.
9 changes: 7 additions & 2 deletions src/include/dhcp-server/dialogs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,13 @@ def ReadDialog
return :abort if !Confirm.MustBeRoot

ret = DhcpServer.Read
return DhcpServer.WasConfigured ? :next : :wizard if ret
:abort
return :abort unless ret

# initialize the service widget, it needs the "dhcp-server" package
# which might be just installed by the DhcpServer.Read call
DhcpServerUI.InitServiceWidget

DhcpServer.WasConfigured ? :next : :wizard
end

# Write settings dialog
Expand Down
24 changes: 16 additions & 8 deletions src/include/dhcp-server/widgets.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1031,14 +1031,6 @@ def InitWidgets
#FIXME CWM should be able to handle virtual widgets
"widget" => :textentry
},
"service_status" => {
"widget" => :custom,
"custom_widget" => status_widget.widget,
"help" => status_widget.help,
"init" => fun_ref(method(:init_service_status), "void (string)"),
"handle" => fun_ref(method(:handle_service_status), "symbol (string, map)"),
"store" => fun_ref(method(:store_service_status), "void (string, map)")
},
"apply" => {
"widget" => :push_button,
"label" => _("Apply Changes"),
Expand Down Expand Up @@ -1329,5 +1321,21 @@ def InitWidgets

nil
end

# lazy initialization of the service status widget
# it needs the "dhcp-server" package already installed in the system
# otherwise it crashes
def InitServiceWidget
return if @widgets["service_status"]

@widgets["service_status"] = {
"widget" => :custom,
"custom_widget" => status_widget.widget,
"help" => status_widget.help,
"init" => fun_ref(method(:init_service_status), "void (string)"),
"handle" => fun_ref(method(:handle_service_status), "symbol (string, map)"),
"store" => fun_ref(method(:store_service_status), "void (string, map)")
}
end
end
end

0 comments on commit d2c3a86

Please sign in to comment.