Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. International
  3. Chinese
  4. 使用QLibrary遇到的问题
Forum Updated to NodeBB v4.3 + New Features

使用QLibrary遇到的问题

Scheduled Pinned Locked Moved Chinese
1 Posts 1 Posters 2.2k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Z Offline
    Z Offline
    zixialang
    wrote on last edited by
    #1

    在开发中遇到了这样的问题,使用QLibrary加载动态库,每调用一次,句柄数就会增加,因为我的程序要频繁的调用动态库,最终导致程序崩溃。调用的代码如下:

    typedef long LPARAM;
    typedef unsigned int WPARAM;
    typedef void (DLLFUN_Init)(void, void*);
    typedef void (*DLLFUN_UnInit)();
    typedef void (*DLLFUN_MakeProduction)(LPARAM lParam, WPARAM wParam);

    QLibrary library(appPath+"/"+pModule.ModuleName);
    DLLFUN_Init init = (DLLFUN_Init) library.resolve("Init");
    DLLFUN_UnInit uninit = (DLLFUN_UnInit) library.resolve("UnInit");
    DLLFUN_MakeProduction makepro = (DLLFUN_MakeProduction) library.resolve("MakeProduction");

    if ((init) && (uninit) && (makepro))
    {
    QString CurrentPath=QDir::currentPath();
    QDir::setCurrent(appPath);

            init(&filehead, databuffer);
            makepro((LPARAM)&ProductNameAndParam, (WPARAM)&ProductPath);
            uninit();
    
            QDir::setCurrent(CurrentPath);
        }
        library.unload();
    

    在QT4.7.0环境下,每次调用都会增加10个左右句柄;在QT4.6.2环境下,每次调用增加的句柄数降为1。

    请问,如何才能使句柄数彻底不涨???

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved