Jump to content

UniGUIDialogs ShowMessage not displayed


misc
 Share

Recommended Posts

I have an application that uses ZeosDb to access a mySQL database. When mySQL is restarted on the server, the app looses connection, and "Dataset.Active:= true;" raises an "ODBC call failed" exception, passing into the catch-all below:

procedure TUniServerModule.UniGUIServerModuleException(Sender: TUniGUIMainModule; AException: Exception; var Handled: Boolean);
begin
  if LikeList(AException.Message, ['*odbc*', '*sql server*']) then begin
    ShowMessage(rsDBReconnect);  //<--not shown

  end else
    ShowMessage(Sender.Name + ': ' + AException.Message);  //<--shown

  Handled:= true;
end;

Problem 1: the red message above is not displayed, even though we definitely pass here in debug mode. If a non-odbc error is encountered, the blue message is shown.

 

Problem 2: after this event, all uniGUI menus are gone and the app does not really work anymore

 

My guess is, that the exception itsself already puts the application into some strange state, where things like menus & dialogs dont work anymore.

 

Any ideas how I can handle this?

 

Link to comment
Share on other sites

Hello Farshad,

 

as I am working heavily with databases, it is unfortunately very hard to catch every DB exception where it occurs. Also, when an exception occurs the app goes into some strange crash state, where the menus and some of the controls no longer work. Do you know anything about this? Why does it happen and how can I prevent it? Or in other words: if a database connection exception occurs (Zeos controls), why do the unigui menus no longer work. What does one thing have to do with the other?!

 

And how can I handle the message problem? Any tricks? If I could show a message in the general UniGUIServerModuleException, then I could ask the user to restart the app, or even do it for him. At the moment, due to the crashed state after an exception, the user experiences the uniGUI application as unstable and with undetermined outcome.

  • Upvote 1
Link to comment
Share on other sites

They are empty, ie only a tiny square pops up. I suppose that means they are empty.

 

Or in not so technical terms: It seems the DB connection exception eats up the unigui menu items ;-)

Link to comment
Share on other sites

@ Oliver: sorry, can you rephrase?

 

Farshad wrote in post #2:

 

OnException event is only for non-visual code.

ShowMessage() and etc. will not work here.

...

 

I think ServerModule is another thread/context and something like ShowMessage() there will produce other problems.

Link to comment
Share on other sites

DelphiDeveloper helped me find the problem, which is also described here:
http://www.sencha.com/forum/showthread.php?260320-4.2.0-Ext.suspendLayouts-causes-a-menu-to-be-not-rendered

 

I used UniSession.AddJS('Ext.suspendLayouts()') in heavy control creation in order to eliminate unnecessary control painting, and in unhandled exceptions I dont reach UniSession.AddJS('Ext.resumeLayouts(true)');

 

So solved this, not an uniGUI bug, but the global exception problem stll persists: How do I create a global exception handler?

 

I tried this, but it is not called at all:
 

procedure TMainForm.UniFormCreate(Sender: TObject);
begin
  Application.OnException:= AppException;
end;

procedure TMainForm.AppException(Sender: TObject; E: Exception);
//not called!
begin
  UniGUIDialogs.ShowMessage(E.Message);
end;
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...