Results 1 to 5 of 5

Thread: Destructor for Qtconcurrent::Exception?

  1. #1
    Join Date
    Apr 2011
    Posts
    5
    Qt products

    Default Destructor for Qtconcurrent::Exception?

    I am deriving an exception class from Qtconcurrent::Exception, and am receiving a compilation error
    looser throw specifier for 'virtual SException::~SException()'
    overriding 'virtual QtConcurrent::Exception::~Exception() throw()'
    The class is as follows
    Qt Code:
    1. class SException : public QtConcurrent::Exception
    2. {
    3. public:
    4. SException(const QString& message) : message_(message) {}
    5. void raise() const { throw *this; }
    6. Exception *clone() const { return new SException(*this); }
    7. QString message() const { return message_; }
    8.  
    9. private:
    10. QString message_;
    11. };
    To copy to clipboard, switch view to plain text mode 
    How do you specify the destructor correctly? I have already tried specifying a virtual destructor in the derived class but still get the same error.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Destructor for Qtconcurrent::Exception?

    Did you specify throw() for your destructor?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Apr 2011
    Posts
    5
    Qt products

    Default Re: Destructor for Qtconcurrent::Exception?

    When I add the destructor
    Qt Code:
    1. virtual ~SException() throw();
    To copy to clipboard, switch view to plain text mode 
    the compiler error goes away, but now I get a linking error looking for the implementation of the SException destructor.

    What is the difference between
    Qt Code:
    1. virtual ~SException() throw();
    To copy to clipboard, switch view to plain text mode 
    and
    Qt Code:
    1. virtual ~SException() { throw(); }
    To copy to clipboard, switch view to plain text mode 
    ?

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Destructor for Qtconcurrent::Exception?

    You get a linker error because you didn't implement a destructor that contains a throw declaration. If you declare a method with throw(), you need to implement a method with throw().

    About your question -- the difference is like between a bucket of water and an apple.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Apr 2011
    Posts
    5
    Qt products

    Default Re: Destructor for Qtconcurrent::Exception?

    Thanks, I figured out what throw() does and I added an implementation to the destructor.

Similar Threads

  1. Destructor not being called
    By vieraci in forum Qt Programming
    Replies: 12
    Last Post: 25th January 2012, 15:06
  2. Destructor not called
    By satoshi in forum General Programming
    Replies: 2
    Last Post: 23rd April 2010, 13:55
  3. destructor dilemma
    By Petr_Kropotkin in forum General Programming
    Replies: 3
    Last Post: 17th March 2010, 15:58
  4. Destructor in QT
    By hgedek in forum Newbie
    Replies: 1
    Last Post: 18th September 2007, 10:54
  5. QMap destructor bug
    By Ruud in forum Qt Programming
    Replies: 6
    Last Post: 8th April 2006, 09:08

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.