Opened 11 years ago
Closed 10 years ago
#4903 closed Enhancement (invalid)
Ability to disable dbus support in Qt client
Reported by: | nzqr | Owned by: | |
---|---|---|---|
Priority: | Normal | Milestone: | None Set |
Component: | Qt Client | Version: | 2.52 |
Severity: | Normal | Keywords: | patch_needed |
Cc: |
Description
Here's sample patch:
-
app.cc
14 14 #include <ctime> 15 15 #include <iostream> 16 16 17 #ifdef MY_DBUS 17 18 #include <QDBusConnection> 18 19 #include <QDBusConnectionInterface> 19 20 #include <QDBusError> 20 21 #include <QDBusMessage> 22 #endif 23 21 24 #include <QDialogButtonBox> 22 25 #include <QIcon> 23 26 #include <QLabel> … … 32 35 33 36 #include "add-data.h" 34 37 #include "app.h" 38 39 #ifdef MY_DBUS 35 40 #include "dbus-adaptor.h" 41 #endif 42 36 43 #include "formatter.h" 37 44 #include "mainwin.h" 38 45 #include "options.h" … … 45 52 46 53 namespace 47 54 { 55 #ifdef MY_DBUS 48 56 const QString DBUS_SERVICE = QString::fromAscii( "com.transmissionbt.Transmission" ); 49 57 const QString DBUS_OBJECT_PATH = QString::fromAscii( "/com/transmissionbt/Transmission" ); 50 58 const QString DBUS_INTERFACE = QString::fromAscii( "com.transmissionbt.Transmission" ); 51 59 #endif 60 52 61 const char * MY_READABLE_NAME( "transmission-qt" ); 53 62 54 63 const tr_option opts[] = … … 245 254 addTorrent( *it ); 246 255 247 256 // register as the dbus handler for Transmission 257 #ifdef MY_DBUS 248 258 new TrDBusAdaptor( this ); 249 259 QDBusConnection bus = QDBusConnection::sessionBus(); 250 260 if( !bus.registerService( DBUS_SERVICE ) ) 251 261 std::cerr << "couldn't register " << qPrintable(DBUS_SERVICE) << std::endl; 252 262 if( !bus.registerObject( DBUS_OBJECT_PATH, this ) ) 253 263 std::cerr << "couldn't register " << qPrintable(DBUS_OBJECT_PATH) << std::endl; 264 #endif 254 265 } 255 266 256 267 /* these functions are for popping up desktop notifications */ … … 282 293 283 294 if( tor && !tor->name().isEmpty() ) 284 295 { 296 #ifdef MY_DBUS 285 297 notify( tr( "Torrent Completed" ), tor->name( ) ); 298 #endif 286 299 287 300 disconnect( tor, SIGNAL(torrentCompleted(int)), this, SLOT(onTorrentCompleted(int)) ); 288 301 } … … 295 308 296 309 if( tor && !tor->name().isEmpty() ) 297 310 { 311 #ifdef MY_DBUS 298 312 const int age_secs = tor->dateAdded().secsTo(QDateTime::currentDateTime()); 299 313 if( age_secs < 30 ) 300 314 notify( tr( "Torrent Added" ), tor->name( ) ); 315 #endif 301 316 302 317 disconnect( tor, SIGNAL(torrentChanged(int)), this, SLOT(onNewTorrentChanged(int)) ); 303 318 … … 439 454 QApplication :: alert ( myWindow ); 440 455 } 441 456 457 #ifdef MY_DBUS 442 458 bool 443 459 MyApp :: notify( const QString& title, const QString& body ) const 444 460 { … … 462 478 //std::cerr << qPrintable(replyMsg.errorMessage()) << std::endl; 463 479 return (replyMsg.type() == QDBusMessage::ReplyMessage) && !replyMsg.arguments().isEmpty(); 464 480 } 481 #endif 465 482 466 483 /*** 467 484 **** … … 481 498 482 499 // try to delegate the work to an existing copy of Transmission 483 500 // before starting ourselves... 501 #ifdef MY_DBUS 484 502 bool delegated = false; 485 503 QDBusConnection bus = QDBusConnection::sessionBus(); 486 504 for( int i=0, n=addme.size(); i<n; ++i ) … … 509 527 510 528 if( delegated ) 511 529 return 0; 530 #endif 512 531 513 532 tr_optind = 1; 514 533 MyApp app( argc, argv );
Attachments (1)
Change History (12)
comment:1 Changed 11 years ago by jordan
comment:2 Changed 11 years ago by nzqr
To conserve ram on older machines, while still using gui.
comment:3 Changed 11 years ago by jordan
How much memory is saved by disabling DBus support?
comment:4 Changed 11 years ago by nzqr
This will vary based on achitecture and compiler options, and every little bit helps. If this is not enough for substantiation, when compiling why do i bother to build dbus when it's not needed for me?
comment:5 Changed 11 years ago by jordan
Top says stock transmission-qt uses 39m RES / 29m SHR.
Top says patched transmission-qt uses 39m RES / 29m SHR.
This patch doesn't seem to save any memory on i686...
comment:6 Changed 11 years ago by jordan
- Resolution set to worksforme
- Status changed from new to closed
comment:7 follow-up: ↓ 9 Changed 11 years ago by nzqr
- Component changed from Transmission to Qt Client
- Resolution worksforme deleted
- Status changed from closed to reopened
- Version changed from 2.51 to 2.52
Seems that you done something wrong, for example qtdbus still is linked, thats my results of
ps -o rss,comm `pgrep 'transmission-qt|dbus'`
without patch:
RSS COMMAND 34452 transmission-qt 724 dbus-launch 668 dbus-daemon
with:
RSS COMMAND 33836 transmission-qt
dbus session daemon included because no other app than transmission uses it on my system.
Btw, what's about porting on windows, has dbus on windows any sense?
comment:8 Changed 11 years ago by jordan
- Keywords patch_needed added
- Resolution set to worksforme
- Status changed from reopened to closed
Thanks for providing some numbers.
So, this is a pretty limited win that few people will notice. I don't care about this ticket, but if it's important enough to you that you'll finish the patch to handle the qmake plumbing and make a patchfile of the unified diffs, then please reopen this ticket and attach the patchfile.
comment:9 in reply to: ↑ 7 Changed 11 years ago by rb07
Replying to nzqr:
Btw, what's about porting on windows, has dbus on windows any sense?
I don't understand why you ask this, but the answer is yes, transmission-qt uses dbus-daemon to implement the file and magnet association (just like it does in Linux).
Perhaps your question is more about dbus on Windows, you probably think it doesn't work there, it does, or that is not used by anyone, is being used by the "KDE on Windows Initiative", and Emacs, and others.
comment:10 Changed 11 years ago by nzqr
- Resolution worksforme deleted
- Status changed from closed to reopened
I have attached the patch, hope it will do.
comment:11 Changed 10 years ago by jordan
- Resolution set to invalid
- Status changed from reopened to closed
I still don't like this ticket because the benefits seem very minimal and difficult to reach -- how many people are going to compile their own version of transmission-qt to disable DBus support?
What is the use case for this?