From: konrad Date: Mon, 10 Mar 2008 12:39:44 +0000 (+0000) Subject: fix crash, still needs fix in PHP for creating new customer X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=b10ad7cff348e7f4ceeac026ab48ac20443fa3a5;p=web%2Fkonrad%2Fsmoke.git fix crash, still needs fix in PHP for creating new customer git-svn-id: https://silmor.de/svn/softmagic/smoke/trunk@112 6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33 --- diff --git a/src/customer.cpp b/src/customer.cpp index 40a2a29..69c3784 100644 --- a/src/customer.cpp +++ b/src/customer.cpp @@ -23,9 +23,9 @@ #include #include -MCustomer::MCustomer() +MCustomer::MCustomer(MWebRequest*r) { - m_req=0; + m_req=r; m_id=-1; m_iscomplete=false; } @@ -65,6 +65,10 @@ void MCustomer::scanXml(const QDomElement&el) void MCustomer::getUpdate() { if(m_id<0)return; + if(m_req==0){ + qDebug("Warning: trying to call MCustomer::getUpdate without MWebRequest!"); + return; + } if(!m_req->request("getcustomer",QString::number(m_id).toAscii()))return; QDomDocument doc; if(!doc.setContent(m_req->responseBody()))return; @@ -148,6 +152,10 @@ void MCustomer::setComment(QString c){m_comment=c;} void MCustomer::save() { + if(m_req==0){ + qDebug("Warning: trying to call MCustomer::save without MWebRequest!"); + return; + } //create XML QDomDocument doc; QDomElement cse=doc.createElement("Customer"); @@ -250,7 +258,7 @@ MCustomer MCustomerListDialog::getCustomer() void MCustomerListDialog::newCustomer() { - MCustomerDialog cd(MCustomer(),this); + MCustomerDialog cd(MCustomer(m_req),this); if(cd.exec()==QDialog::Accepted) updateList(); } diff --git a/src/customer.h b/src/customer.h index eead30b..b7e17a6 100644 --- a/src/customer.h +++ b/src/customer.h @@ -24,7 +24,7 @@ class MCustomer { public: /**creates an empty/invalid customer*/ - MCustomer(); + MCustomer(MWebRequest*r=0); /**creates a customer from XML*/ MCustomer(MWebRequest*,const QDomElement&); /**copies a customer*/