Hi folks ,

    I'm not sure whether it'll work for you, but I can show you what works for me  :) 
    I didn't use MessageBox directly , instead , I've made wrapper, adapter class around it,  and then, when dialog needs to be destroyed ,  I call delete this;    in the wrapper class;

    Combined with generic factory classes I normally use ,  it does the job fairly well :)   .

    Please checkout code below. I didn't  post the complete code, so wouldn't confuse everybody,  but I believe this lines highlight what I've meant :
   
   
//------------------------------------------   Code  -----------------------------------------------------------------------------------

        void FileUploadDialog::init()  //Called by constructor
        {

            theDialogPtr_ = ExtDialogPtr( new Wt::Ext::Dialog() );


            uploadDialogPtr_ = WFileUploadPtr( new Wt::WFileUpload( theDialogPtr_->contents() ) );
            // Try to catch the fileupload change signal to trigger an upload.
            // We could do like google and at a delay with a WTimer as well...
            uploadDialogPtr_->changed.connect(SLOT( uploadDialogPtr_, Wt::WFileUpload::upload));
            // React to a succesfull upload.
            uploadDialogPtr_->uploaded.connect(SLOT(this, FileUploadDialog::onFileUploaded));
            // React to a fileupload problem.
            uploadDialogPtr_->fileTooLarge.connect(SLOT(this, FileUploadDialog::onFileTooLarge));

            //Wt::WString cancelStr = dictPtr_->translate("cancel");
            cancelButton_ = new Wt::Ext::Button("Cancel",theDialogPtr_->contents());

            //registerButton_->clicked.connect(SLOT(this, UserLoginPanel::okRegisterClicked));
            cancelButton_->clicked.connect( SLOT(this,FileUploadDialog::onCancelClicked) );

            theDialogPtr_->setHidden(false);
        }
        //------------------------------------------------
        void FileUploadDialog::onCancelClicked()
        {
            delete this;
        }

        void FileUploadDialog::onFileUploaded()
        {


            std::string clientFile = uploadDialogPtr_->clientFileName().narrow();
            std::string fileExt  = util::extractFileExt( clientFile );
            std::string serverSideTmpFileName = uploadDialogPtr_->spoolFileName();
            uploadDialogPtr_->stealSpooledFile();

            std::string  newFileName = util::addLastBackSlash( targetFolder_  ) + createRandomString(20) + fileExt;        

            path spoolFilePath( serverSideTmpFileName.c_str() );
            path targetFilePath( newFileName.c_str() );

            boost::filesystem::rename(spoolFilePath,targetFilePath);

            targetFileName_ = targetFilePath.string();          

            if( onDone_ != 0 )  //Calls the event receiver set by user
                onDone_();

            delete this;  //and then destroys the dialog
        } 


//------------------------------------------   Code  -----------------------------------------------------------------------------------

I've just noticed that this isn't my MessageBox class ,  but it shows the point anyway  :-)

Cheers!
Dushan

Goetz Babin-Ebell wrote:
Hello Koen,
Am Dienstag, den 09.12.2008, 14:53 +0100 schrieb Koen Deforche:
  
Hey Goetz,

2008/12/8 Goetz Babin-Ebell <[EMAIL PROTECTED]>:
    
Hello,

the actual implementation of Wt::WMessageBox uses the
recursive event loop.

Unfortunately this feature is not available without threads.

Additionally the actual implementation has the disadvantage
that you have to guarantee that with N threads you have at
most N-1 WMessageBoxes open.

Is it possible to
* change the WMessageBox to not use the recursive event loop or
* change the recursive event loop to stay in the same thread
 (and not needing threads at all)
      
WMessageBox does support the alternative usage, which does not require
blocking a thread:

{
 ...
 box_ = new WMessageBox(...);
 box_->show();
 box_->buttonClicked.connect(SLOT(box, WMessageBox::accept));
 box_->finished.connect(SLOT(this, MyWidget::handleBoxDone));
}

void MyWidget::handleBoxDone()
{
  switch (box_->result()) {
    ...
  }

  delete box_;
}
    
This cores.
Keeping the dialog in the handleBoxDone() succeeds,
but the next Dialog results in a new session...

Goetz

  

------------------------------------------------------------------------------
SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas, Nevada.
The future of the web can't happen without you.  Join us at MIX09 to help
pave the way to the Next Web now. Learn more and register at
http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009.visitmix.com/
_______________________________________________
witty-interest mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/witty-interest

Reply via email to