Form receiver gets unique ptr.
This commit is contained in:
13
src/form.cc
13
src/form.cc
@ -117,7 +117,7 @@ public: //BUG: for now everything is public
|
||||
|
||||
int num_entry_fields;
|
||||
|
||||
DilloHtmlReceiver *form_receiver;
|
||||
std::unique_ptr< DilloHtmlReceiver > form_receiver;
|
||||
|
||||
public:
|
||||
DilloHtmlForm (DilloHtml *html,
|
||||
@ -138,10 +138,15 @@ class DilloHtmlReceiver:
|
||||
public Resource::ActivateReceiver,
|
||||
public Resource::ClickedReceiver
|
||||
{
|
||||
private:
|
||||
friend class DilloHtmlForm;
|
||||
DilloHtmlForm* form;
|
||||
|
||||
public:
|
||||
DilloHtmlReceiver (DilloHtmlForm* form2) { form = form2; }
|
||||
~DilloHtmlReceiver () { }
|
||||
|
||||
private:
|
||||
void activate (Resource *resource);
|
||||
void enter (Resource *resource);
|
||||
void leave (Resource *resource);
|
||||
@ -1011,7 +1016,7 @@ DilloHtmlForm::DilloHtmlForm (DilloHtml *html2,
|
||||
num_entry_fields = 0;
|
||||
showing_hiddens = false;
|
||||
this->enabled = enabled;
|
||||
form_receiver = new DilloHtmlReceiver (this);
|
||||
form_receiver= std::make_unique< DilloHtmlReceiver >( this );
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1022,8 +1027,6 @@ DilloHtmlForm::~DilloHtmlForm ()
|
||||
delete action;
|
||||
dFree(submit_charset);
|
||||
inputs.clear();
|
||||
if (form_receiver)
|
||||
delete(form_receiver);
|
||||
}
|
||||
|
||||
void DilloHtmlForm::eventHandler(Resource *resource, EventButton *event)
|
||||
@ -1567,7 +1570,7 @@ void DilloHtmlForm::setEnabled(bool enabled)
|
||||
*/
|
||||
void DilloHtmlForm::addInput(std::unique_ptr< DilloHtmlInput > input, DilloHtmlInputType type)
|
||||
{
|
||||
input->connectTo (form_receiver);
|
||||
input->connectTo (form_receiver.get());
|
||||
input->setEnabled (enabled);
|
||||
inputs.push_back( std::move( input ) );
|
||||
|
||||
|
||||
Reference in New Issue
Block a user