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;
|
int num_entry_fields;
|
||||||
|
|
||||||
DilloHtmlReceiver *form_receiver;
|
std::unique_ptr< DilloHtmlReceiver > form_receiver;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DilloHtmlForm (DilloHtml *html,
|
DilloHtmlForm (DilloHtml *html,
|
||||||
@ -138,10 +138,15 @@ class DilloHtmlReceiver:
|
|||||||
public Resource::ActivateReceiver,
|
public Resource::ActivateReceiver,
|
||||||
public Resource::ClickedReceiver
|
public Resource::ClickedReceiver
|
||||||
{
|
{
|
||||||
|
private:
|
||||||
friend class DilloHtmlForm;
|
friend class DilloHtmlForm;
|
||||||
DilloHtmlForm* form;
|
DilloHtmlForm* form;
|
||||||
|
|
||||||
|
public:
|
||||||
DilloHtmlReceiver (DilloHtmlForm* form2) { form = form2; }
|
DilloHtmlReceiver (DilloHtmlForm* form2) { form = form2; }
|
||||||
~DilloHtmlReceiver () { }
|
~DilloHtmlReceiver () { }
|
||||||
|
|
||||||
|
private:
|
||||||
void activate (Resource *resource);
|
void activate (Resource *resource);
|
||||||
void enter (Resource *resource);
|
void enter (Resource *resource);
|
||||||
void leave (Resource *resource);
|
void leave (Resource *resource);
|
||||||
@ -1011,7 +1016,7 @@ DilloHtmlForm::DilloHtmlForm (DilloHtml *html2,
|
|||||||
num_entry_fields = 0;
|
num_entry_fields = 0;
|
||||||
showing_hiddens = false;
|
showing_hiddens = false;
|
||||||
this->enabled = enabled;
|
this->enabled = enabled;
|
||||||
form_receiver = new DilloHtmlReceiver (this);
|
form_receiver= std::make_unique< DilloHtmlReceiver >( this );
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -1022,8 +1027,6 @@ DilloHtmlForm::~DilloHtmlForm ()
|
|||||||
delete action;
|
delete action;
|
||||||
dFree(submit_charset);
|
dFree(submit_charset);
|
||||||
inputs.clear();
|
inputs.clear();
|
||||||
if (form_receiver)
|
|
||||||
delete(form_receiver);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DilloHtmlForm::eventHandler(Resource *resource, EventButton *event)
|
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)
|
void DilloHtmlForm::addInput(std::unique_ptr< DilloHtmlInput > input, DilloHtmlInputType type)
|
||||||
{
|
{
|
||||||
input->connectTo (form_receiver);
|
input->connectTo (form_receiver.get());
|
||||||
input->setEnabled (enabled);
|
input->setEnabled (enabled);
|
||||||
inputs.push_back( std::move( input ) );
|
inputs.push_back( std::move( input ) );
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user