Review Request 113197: KMessageBox: Factorize code between regular and *WId functions

Aurélien Gâteau agateau at kde.org
Mon Oct 14 14:00:11 UTC 2013


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
http://git.reviewboard.kde.org/r/113197/
-----------------------------------------------------------

(Updated Oct. 14, 2013, 2 p.m.)


Status
------

This change has been marked as submitted.


Review request for KDE Frameworks.


Repository: kdelibs


Description
-------

Factorize code between regular and *WId functions, reducing the file size by 12%.

This patch adds another level of indirection. For example the sorry() function is changed from:

    void sorry(QWidget *parent, ...args)
    {
        QDialog *dialog = new QDialog(parent);
        /* fill dialog */
    }

to:

    static void sorryInternal(QDialog *dialog, ...args)
    {
        /* fill dialog */
    }

    void sorry(QWidget *parent, ...args)
    {
        sorryInternal(new QDialog(parent), ...args);
    }

This makes it possible to turn the sorryWId() function into a forward function rather than a slightly-different copy of the original sorry() function:

    void sorryWId(WId parent_id, ...args)
    {
        sorryInternal(createWIdDialog(parent_id), ...args);
    }

createWIdDialog() is a helper function to create a dialog which is a child of a window belonging to another process.

Note: I kept most of the code to the place where it originally was in the file. This keeps the diff small, but readability would be improved by grouping together similar functions. Let me know if you think it is worth doing so.


Diffs
-----

  tier1/kwidgetsaddons/src/kmessagebox.cpp 0cfa491 

Diff: http://git.reviewboard.kde.org/r/113197/diff/


Testing
-------

Builds, kmessageboxwidtest.cpp runs correctly. No other tests are available though.


Thanks,

Aurélien Gâteau

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-frameworks-devel/attachments/20131014/2ce7aee3/attachment-0001.html>


More information about the Kde-frameworks-devel mailing list